[med-svn] [aghermann] 03/31: extra rk1968 WIP

andrei zavada hmmr-guest at alioth.debian.org
Sun Nov 10 00:34:14 UTC 2013


This is an automated email from the git hooks/post-receive script.

hmmr-guest pushed a commit to branch WIP
in repository aghermann.

commit 8352b0028f172f39d2ddf96c8b92f5fccdbd3ce9
Author: Andrei Zavada <hmmr at ra>
Date:   Fri Nov 8 16:18:56 2013 +0200

    extra rk1968 WIP
---
 upstream/data/Makefile.am                   |    6 ++++
 upstream/data/basic_score.lua               |   47 +++++++++++++++++++--------
 upstream/data/sf-rk1968.glade               |    6 ++--
 upstream/src/aghermann/rk1968/rk1968.cc     |   32 ++++++++++--------
 upstream/src/aghermann/rk1968/rk1968.hh     |    2 +-
 upstream/src/aghermann/ui/sf/d/rk1968_cb.cc |    8 +++--
 upstream/src/libsigfile/channel.cc          |   43 ++++++++++++------------
 7 files changed, 89 insertions(+), 55 deletions(-)

diff --git a/upstream/data/Makefile.am b/upstream/data/Makefile.am
index df7a080..41c061c 100644
--- a/upstream/data/Makefile.am
+++ b/upstream/data/Makefile.am
@@ -10,6 +10,11 @@ ui_DATA := \
 	idle-bg.svg \
 	experiment-dl.sh
 
+rkdir := $(datadir)/${PACKAGE}/rk1968
+
+rk_DATA := \
+	basic_score.lua
+
 EXTRA_DIST := \
 	aghermann.png \
 	aghermann.desktop.in edfhed-gtk.desktop.in \
@@ -21,6 +26,7 @@ EXTRA_DIST := \
 	mf.glade \
 	edfhed.glade \
 	idle-bg.svg equations1.png equation-uc.png \
+	basic_score.lua \
 	experiment-dl.sh
 
 CLEANFILES := \
diff --git a/upstream/data/basic_score.lua b/upstream/data/basic_score.lua
index 4880231..91d3ec4 100644
--- a/upstream/data/basic_score.lua
+++ b/upstream/data/basic_score.lua
@@ -1,13 +1,34 @@
-                // for ( size_t p = 0; p < F1.n_pages(); ++p ) {
-                //         auto    Di = courses_delta.begin(),
-                //                 Ti = courses_theta.begin();
-                //         int decision = 0;
-                //         for ( ; Di != courses_delta.end(); ++Di, ++Ti ) {
-                //                 decision +=
-                //                         ( (*Di)[p] > (*Ti)[p] * Pp.nrem3_delta_theta_ratio );
-                //         }
-                //         if ( decision > 0 ) {
-                //                 F1[p].mark( sigfile::SPage::TScore::nrem3);
-                //                 ++n_pages_scored;
-                //         }
-                // }
+-- ; -*- mode: Lua -*-
+-- First, you collect necessary pieces
+local A, Fi, Fo = ...
+
+-- (1) A is an opaque structure representing our Scoring Assistant host side;
+--     all you need to do with it is pass it as the first arg to all calls
+--     of Fi and Fo (see below).
+
+-- (2) Fi, a CFunction, is the proxy to get any data related to or describing
+--     the montage being scored. It has the signature
+--        Fi( A, opcode, arg1, arg2, ...)
+--     Think syscall. For what opcode's are available and the corresponding
+--     parameters, see man agherman or the project documentation online.
+
+-- (3) Fo, also a CFunction, is used to deliver the scoring decision to the host;
+--     to be used like so:
+--        Fo( A, page, score)
+
+local cc = {Fi(A, 2, "EEG")}
+print( string.format( "Montage has %d EEG channels", cc[1]))
+
+local H = cc[2]
+local np, nf, ps, sr = Fi(A, 3, H)
+print( string.format( "Looking at channel %q: %d pages @%d sec, sr %d", H, np, ps, sr))
+
+local delta = {Fi(A, 100, H, 0, np-1, 2, 3)}
+local theta = {Fi(A, 100, H, 0, np-1, 4, 8)}
+
+for p=1,np-1 do
+  if delta[p] > theta[p] * 1.5 then
+--    print( "mark page ", p)
+    Fo( A, p - 1, 2)
+  end
+end
diff --git a/upstream/data/sf-rk1968.glade b/upstream/data/sf-rk1968.glade
index 3d6c0b6..25b6066 100644
--- a/upstream/data/sf-rk1968.glade
+++ b/upstream/data/sf-rk1968.glade
@@ -49,10 +49,12 @@
             </child>
             <child>
               <object class="GtkToggleButton" id="bSFRKPreview">
-                <property name="label" translatable="yes">Try</property>
+                <property name="label" translatable="yes">Tr_y</property>
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
+                <property name="can_focus">False</property>
                 <property name="receives_default">True</property>
+                <property name="use_underline">True</property>
+                <accelerator key="F2" signal="activate"/>
               </object>
               <packing>
                 <property name="expand">False</property>
diff --git a/upstream/src/aghermann/rk1968/rk1968.cc b/upstream/src/aghermann/rk1968/rk1968.cc
index 1a00c5a..637ce5f 100644
--- a/upstream/src/aghermann/rk1968/rk1968.cc
+++ b/upstream/src/aghermann/rk1968/rk1968.cc
@@ -107,6 +107,7 @@ compile()
                 path().c_str());
         if ( ret1 ) {
                 const char* errmsg = lua_tostring( lua_state, -1);
+                specific_error.assign( errmsg);
                 APPLOG_WARN ("compilation failed: %s (%d)", errmsg, ret1);
                 status |= TFlags::ecompile;
         } else
@@ -220,12 +221,10 @@ host_get_data( lua_State *L)
         case op_get_channel_list: {
                 NEED_ARITY_EXACT(0);
 
-                list<const char*> A;
-                for ( auto& H : E.recordings )
-                        A.push_back( H.first.c_str());
                 lua_pushinteger( L, E.recordings.size());
-                lua_pushstring( L, agh::str::join( A, ";").c_str());
-                return 2;
+                for ( auto& H : E.recordings )
+                        lua_pushstring( L, H.first.c_str());
+                return 1 + E.recordings.size();
         }
 
         case op_get_channel_list_of_type: {
@@ -233,13 +232,15 @@ host_get_data( lua_State *L)
 
                 const char* type = lua_tostring( L, 3);
 
-                list<agh::CRecording*> A;
+                size_t hh_of_type = 0;
                 for ( auto& H : E.recordings )
-                        if ( 0 == strcmp( H.first.type_s(), type) )
-                                A.push_back( &H.second);
-                lua_pushinteger( L, E.recordings.size());
-                lua_pushstring( L, agh::str::join( A, ";").c_str());
-                return 2;
+                        if ( 0 == strcasecmp( H.first.type_s(), type) )
+                                ++hh_of_type;
+                lua_pushinteger( L, hh_of_type);
+                for ( auto& H : E.recordings )
+                        if ( 0 == strcasecmp( H.first.type_s(), type) )
+                                lua_pushstring( L, H.first.c_str());
+                return 1 + hh_of_type;
         }
 
         case op_get_channel_data: {
@@ -255,7 +256,7 @@ host_get_data( lua_State *L)
                         lua_pushinteger( L, R.total_pages());
                         lua_pushinteger( L, R.pagesize());
                         lua_pushinteger( L, R.F().samplerate(R.h()));
-                        return 3;
+                        return 4;
                 }
         }
 
@@ -286,12 +287,15 @@ host_get_data( lua_State *L)
                                 make_error_return( "Ill-formed frequency range");
 
                         auto C =
-                                opcode == op_get_psd
+                                (opcode == op_get_psd)
                                 ? R.psd_profile.course( fa, fz)
-                                : opcode == op_get_mc
+                                : (opcode == op_get_mc)
                                 ? R.mc_profile.course( fa)
                                 : R.swu_profile.course( fa);
                         auto p = pa;
+                        if ( !lua_checkstack( L, pz - pa) )
+                                make_error_return( "Failed to grow stack for %zu numbers", pz - pa);
+
                         while ( p <= pz )
                                 lua_pushnumber( L, C[p++]);
                         return pz - pa;
diff --git a/upstream/src/aghermann/rk1968/rk1968.hh b/upstream/src/aghermann/rk1968/rk1968.hh
index 6582786..f7b9dcd 100644
--- a/upstream/src/aghermann/rk1968/rk1968.hh
+++ b/upstream/src/aghermann/rk1968/rk1968.hh
@@ -101,7 +101,7 @@ class CScoreAssistant
     //     friend extern "C" int agh::rk1968::host_mark_page( lua_State*);
         agh::SEpisode*
                 sepisodep;
-        
+        string  specific_error;
 };
 
 
diff --git a/upstream/src/aghermann/ui/sf/d/rk1968_cb.cc b/upstream/src/aghermann/ui/sf/d/rk1968_cb.cc
index 2ea819f..9cfd39e 100644
--- a/upstream/src/aghermann/ui/sf/d/rk1968_cb.cc
+++ b/upstream/src/aghermann/ui/sf/d/rk1968_cb.cc
@@ -63,6 +63,7 @@ wSFRK_show_cb(
         gtk_toggle_button_set_active( RK.bSFRKPreview, FALSE);
         RK.suppress_preview_handler = false;
 
+        gtk_widget_set_sensitive( (GtkWidget*)RK.bSFRKPreview, TRUE);
         gtk_widget_set_sensitive( (GtkWidget*)RK.bSFRKApply, FALSE);
 }
 
@@ -88,9 +89,12 @@ eSFRK_any_profile_value_changed_cb(
         RK.W_V.down();
         if ( RK.Pp2.compile() ) {
                 gtk_widget_set_sensitive( (GtkWidget*)RK.bSFRKPreview, FALSE);
-                // do some beeping perhaps?
+                gtk_label_set_markup(
+                        RK.lSFRKBottomInfo, RK.Pp2.specific_error.c_str());
         } else {
                 gtk_widget_set_sensitive( (GtkWidget*)RK.bSFRKPreview, TRUE);
+                gtk_label_set_markup(
+                        RK.lSFRKBottomInfo, "");
         }
 
         RK.eX_any_profile_value_changed_cb();
@@ -128,8 +132,6 @@ bSFRKPreview_toggled_cb(
                                 (GtkWindow*)RK.wSFRK,
                                 "Scoring script problem",
                                 "%s", agh::rk1968::CScoreAssistant::score_error_s(res));
-                        gtk_label_set_markup(
-                                RK.lSFRKBottomInfo, "Hm. Something is wrong.");
                         RK.suppress_preview_handler = true;
                         gtk_toggle_button_set_active( button, FALSE);
                         RK.suppress_preview_handler = false;
diff --git a/upstream/src/libsigfile/channel.cc b/upstream/src/libsigfile/channel.cc
index c76d0d1..494dd0e 100644
--- a/upstream/src/libsigfile/channel.cc
+++ b/upstream/src/libsigfile/channel.cc
@@ -50,27 +50,6 @@ const map<SChannel::TType, vector<const char*>> _CT_ = {
         },
 };
 
-const map<SChannel::TType, const char*> _ST_ = {
-        {SChannel::TType::embedded_annotation, sigfile::edf_annotations_label},
-        {SChannel::TType::eeg, "EEG"},
-        {SChannel::TType::eog, "EOG"},
-        {SChannel::TType::emg, "EMG"},
-        {SChannel::TType::ecg, "ECG"},
-        {SChannel::TType::erg, "ERG"},
-        {SChannel::TType::nc , "NC" },
-        {SChannel::TType::meg, "MEG"},
-        {SChannel::TType::mcg, "MCG"},
-        {SChannel::TType::ep , "EP" },
-        {SChannel::TType::temp, "Temp"},
-        {SChannel::TType::resp, "Resp"},
-        {SChannel::TType::sao2, "SaO2"},
-        {SChannel::TType::light, "Light"},
-        {SChannel::TType::sound, "Sound"},
-        {SChannel::TType::event, "Event"},
-        {SChannel::TType::freq, "Freq"},
-        {SChannel::TType::other, "(other)"},
-};
-
 } // anonymous namespace
 
 
@@ -78,7 +57,27 @@ const char*
 SChannel::
 type_s( SChannel::TType t)
 {
-        return _ST_.at(t);
+        switch (t) {
+	case SChannel::TType::embedded_annotation: return sigfile::edf_annotations_label;
+        case SChannel::TType::eeg:   return "EEG";
+        case SChannel::TType::eog:   return "EOG";
+        case SChannel::TType::emg:   return "EMG";
+        case SChannel::TType::ecg:   return "ECG";
+        case SChannel::TType::erg:   return "ERG";
+        case SChannel::TType::nc:    return "NC" ;
+        case SChannel::TType::meg:   return "MEG";
+        case SChannel::TType::mcg:   return "MCG";
+        case SChannel::TType::ep:    return "EP" ;
+        case SChannel::TType::temp:  return "Temp";
+        case SChannel::TType::resp:  return "Resp";
+        case SChannel::TType::sao2:  return "SaO2";
+        case SChannel::TType::light: return "Light";
+        case SChannel::TType::sound: return "Sound";
+        case SChannel::TType::event: return "Event";
+        case SChannel::TType::freq:  return "Freq";
+        case SChannel::TType::other: return "(other)";
+        default:                     return "invalid";
+	}
 }
 
 

-- 
Alioth's /git/debian-med/git-commit-notice on /srv/git.debian.org/git/debian-med/aghermann.git



More information about the debian-med-commit mailing list