[med-svn] [aghermann] 84/85: RK1968 essential WIP
andrei zavada
hmmr-guest at alioth.debian.org
Thu Sep 26 23:46:37 UTC 2013
This is an automated email from the git hooks/post-receive script.
hmmr-guest pushed a commit to branch master
in repository aghermann.
commit 26b713d74fc0c53c390020ea337b94cf65b5ffbe
Author: Andrei Zavada <johnhommer at gmail.com>
Date: Fri Sep 27 02:43:44 2013 +0300
RK1968 essential WIP
---
upstream/ChangeLog | 2 +
upstream/data/sf-rk1968.glade | 119 +++++++++-----------
upstream/src/aghermann/rk1968/rk1968.cc | 17 ++-
upstream/src/aghermann/rk1968/rk1968.hh | 2 +-
.../src/aghermann/ui/dirlevel-storable-adapter.ii | 26 ++++-
upstream/src/aghermann/ui/sf/d/rk1968.cc | 5 +
upstream/src/aghermann/ui/sf/d/rk1968.hh | 7 ++
upstream/src/aghermann/ui/sf/d/rk1968_cb.cc | 77 +++++++++++--
upstream/src/aghermann/ui/sf/sf.cc | 8 +-
upstream/src/aghermann/ui/sf/sf.hh | 3 +-
10 files changed, 184 insertions(+), 82 deletions(-)
diff --git a/upstream/ChangeLog b/upstream/ChangeLog
index 7c364d5..1685d92 100644
--- a/upstream/ChangeLog
+++ b/upstream/ChangeLog
@@ -8,6 +8,8 @@ v.0.9.2 (2013-xx-xx)
* Use subject ID in place of name if the latter is missing.
* Properly handle various system/user/experiment/subject/session
stored settings packs (patterns, rk1968, etc).
+ * Incorporate edfhed.glade in aghermann.gresources.
+ * SF: basic dialog for RK1968 scoring assistant parameters.
v.0.9.1.1 (2013-07-24)
* Fix 32-bit builds where sizeof(size_t) != sizeof(unsigned long).
diff --git a/upstream/data/sf-rk1968.glade b/upstream/data/sf-rk1968.glade
index efb42f6..e060e98 100644
--- a/upstream/data/sf-rk1968.glade
+++ b/upstream/data/sf-rk1968.glade
@@ -11,7 +11,7 @@
<object class="GtkDialog" id="wSFRK">
<property name="can_focus">False</property>
<property name="border_width">10</property>
- <property name="title" translatable="yes">Find/manage patterns</property>
+ <property name="title" translatable="yes">Rechtschaffen & Kales</property>
<property name="destroy_with_parent">True</property>
<property name="type_hint">normal</property>
<property name="skip_taskbar_hint">True</property>
@@ -19,7 +19,6 @@
<property name="gravity">north</property>
<signal name="close" handler="gtk_widget_hide_on_delete" swapped="no"/>
<signal name="delete-event" handler="gtk_widget_hide_on_delete" swapped="no"/>
- <signal name="response" handler="gtk_widget_hide_on_delete" swapped="no"/>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox19">
<property name="visible">True</property>
@@ -49,7 +48,7 @@
</child>
<child>
<object class="GtkToggleButton" id="bSFRKPreview">
- <property name="label" translatable="yes">Preview</property>
+ <property name="label" translatable="yes">Try</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
@@ -94,16 +93,12 @@
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<child>
- <object class="GtkLabel" id="label45">
+ <object class="GtkLabel" id="lSFRKTopInfo">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
- <property name="xpad">5</property>
- <property name="label" translatable="yes">Rechtschaffen & Kales</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- <attribute name="scale" value="1.1000000000000001"/>
- </attributes>
+ <property name="label" translatable="yes">RK (n channels)</property>
+ <property name="use_markup">True</property>
</object>
<packing>
<property name="expand">True</property>
@@ -196,68 +191,52 @@
</packing>
</child>
<child>
- <object class="GtkHBox" id="hbox6">
+ <object class="GtkTable" id="cSFRKControls">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="margin_top">5</property>
- <property name="spacing">8</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">5</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
<child>
- <object class="GtkTable" id="cSFRKControls">
+ <object class="GtkSpinButton" id="eSFRKNremThetaDeltaRatio">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="n_rows">2</property>
- <property name="n_columns">2</property>
- <property name="column_spacing">5</property>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <object class="GtkSpinButton" id="eSFRKNremThetaDeltaRatio">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">•</property>
- <property name="xalign">1</property>
- <property name="adjustment">jSFRKNremThetaDeltaRatio</property>
- <property name="digits">2</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes">NREM Delta/Theta power ratio:</property>
- </object>
- </child>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">•</property>
+ <property name="xalign">1</property>
+ <property name="adjustment">jSFRKNremThetaDeltaRatio</property>
+ <property name="digits">2</property>
</object>
<packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="padding">2</property>
- <property name="position">0</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
- <placeholder/>
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">NREM Delta/Theta power ratio:</property>
+ </object>
</child>
</object>
<packing>
@@ -266,6 +245,18 @@
<property name="position">2</property>
</packing>
</child>
+ <child>
+ <object class="GtkLabel" id="lSFRKBottomInfo">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">True</property>
@@ -283,7 +274,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">2</property>
+ <property name="position">3</property>
</packing>
</child>
</object>
diff --git a/upstream/src/aghermann/rk1968/rk1968.cc b/upstream/src/aghermann/rk1968/rk1968.cc
index 26e49d3..b3a9ef8 100644
--- a/upstream/src/aghermann/rk1968/rk1968.cc
+++ b/upstream/src/aghermann/rk1968/rk1968.cc
@@ -42,12 +42,16 @@ CScoreAssistant (const string& name_,
int
CScoreAssistant::
-score( agh::SEpisode& E)
+score( agh::SEpisode& E, size_t* n_pages_scored_p)
{
+ size_t n_pages_scored = 0;
+
forward_list<agh::CRecording*> HH;
for ( auto &R : E.recordings )
if ( R.second.psd_profile.have_data() )
HH.push_front( &R.second);
+ if ( HH.empty() )
+ return -1;
forward_list<valarray<TFloat>>
courses_delta,
@@ -68,12 +72,19 @@ score( agh::SEpisode& E)
auto Di = courses_delta.begin(),
Ti = courses_theta.begin();
int decision = 0;
- for ( ; Di != courses_delta.end(); ++Di, ++Ti )
+ for ( ; Di != courses_delta.end(); ++Di, ++Ti ) {
decision +=
( (*Di)[p] > (*Ti)[p] * Pp.nrem3_delta_theta_ratio );
- if ( decision > 0 )
+ }
+ if ( decision > 0 ) {
firstsource[p].mark( sigfile::SPage::TScore::nrem3);
+ ++n_pages_scored;
+ }
}
+
+ if ( n_pages_scored_p )
+ *n_pages_scored_p = n_pages_scored;
+
return 0;
}
diff --git a/upstream/src/aghermann/rk1968/rk1968.hh b/upstream/src/aghermann/rk1968/rk1968.hh
index 69a34e7..9de6fc8 100644
--- a/upstream/src/aghermann/rk1968/rk1968.hh
+++ b/upstream/src/aghermann/rk1968/rk1968.hh
@@ -83,7 +83,7 @@ class CScoreAssistant
return Pp == rv.Pp;
}
- int score( agh::SEpisode&);
+ int score( agh::SEpisode&, size_t* pages_scored_successfuly);
SScoreAssistantPPack
Pp;
diff --git a/upstream/src/aghermann/ui/dirlevel-storable-adapter.ii b/upstream/src/aghermann/ui/dirlevel-storable-adapter.ii
index f7d1f47..44654c4 100644
--- a/upstream/src/aghermann/ui/dirlevel-storable-adapter.ii
+++ b/upstream/src/aghermann/ui/dirlevel-storable-adapter.ii
@@ -198,6 +198,28 @@ bXProfileSave_clicked_cb()
{
g_signal_emit_by_name( eXProfileSaveName, "changed");
+ gtk_entry_set_text(
+ eXProfileSaveName,
+ (current_profile->level != agh::TExpDirLevel::transient)
+ ? current_profile->name.c_str()
+ : "");
+
+ switch ( current_profile->level ) {
+ //case agh::TExpDirLevel::session:
+ case agh::TExpDirLevel::subject:
+ gtk_toggle_button_set_active( (GtkToggleButton*)eXProfileSaveOriginSubject, TRUE);
+ break;
+ //case agh::TExpDirLevel::group:
+ case agh::TExpDirLevel::experiment:
+ gtk_toggle_button_set_active( (GtkToggleButton*)eXProfileSaveOriginExperiment, TRUE);
+ break;
+ case agh::TExpDirLevel::user:
+ gtk_toggle_button_set_active( (GtkToggleButton*)eXProfileSaveOriginUser, TRUE);
+ break;
+ default:
+ break;
+ }
+
if ( GTK_RESPONSE_OK == gtk_dialog_run( wXProfileSaveName) ) {
using namespace agh;
@@ -293,8 +315,10 @@ bXProfileDiscard_clicked_cb()
if ( not profiles.empty() ) {
Pp2 = *current_profile;
-
atomic_up();
+ } else {
+ profiles.emplace_back( Pp2);
+ profiles.back().level = TExpDirLevel::transient;
}
populate_combo();
diff --git a/upstream/src/aghermann/ui/sf/d/rk1968.cc b/upstream/src/aghermann/ui/sf/d/rk1968.cc
index b1fa1b9..30846cf 100644
--- a/upstream/src/aghermann/ui/sf/d/rk1968.cc
+++ b/upstream/src/aghermann/ui/sf/d/rk1968.cc
@@ -33,6 +33,7 @@ SRK1968Dialog (SScoringFacility& p_)
wSFRKProfileSave, eSFRKProfileSaveName,
eSFRKProfileSaveOriginSubject, eSFRKProfileSaveOriginExperiment, eSFRKProfileSaveOriginUser,
bSFRKProfileSaveOK),
+ suppress_preview_handler (false),
_p (p_)
{
// 1. widgets
@@ -47,8 +48,11 @@ SRK1968Dialog (SScoringFacility& p_)
AGH_GBGETOBJ (bSFRKProfileDiscard);
AGH_GBGETOBJ (eSFRKProfileList);
AGH_GBGETOBJ (eSFRKNremThetaDeltaRatio);
+ AGH_GBGETOBJ (lSFRKTopInfo);
+ AGH_GBGETOBJ (lSFRKBottomInfo);
AGH_GBGETOBJ (bSFRKPreview);
AGH_GBGETOBJ (bSFRKApply);
+ AGH_GBGETOBJ (bSFRKDismiss);
AGH_GBGETOBJ (wSFRKProfileSave);
AGH_GBGETOBJ (eSFRKProfileSaveName);
AGH_GBGETOBJ (eSFRKProfileSaveOriginSubject);
@@ -79,6 +83,7 @@ SRK1968Dialog (SScoringFacility& p_)
G_CONNECT_1 (bSFRKPreview, toggled);
G_CONNECT_1 (bSFRKApply, clicked);
+ G_CONNECT_1 (bSFRKDismiss, clicked);
G_CONNECT_1 (eSFRKProfileSaveName, changed);
diff --git a/upstream/src/aghermann/ui/sf/d/rk1968.hh b/upstream/src/aghermann/ui/sf/d/rk1968.hh
index f0e54c3..cf64dc6 100644
--- a/upstream/src/aghermann/ui/sf/d/rk1968.hh
+++ b/upstream/src/aghermann/ui/sf/d/rk1968.hh
@@ -39,6 +39,8 @@ struct SScoringFacility::SRK1968Dialog
vector<sigfile::SPage>
backup;
+ bool suppress_preview_handler;
+
// parent
SScoringFacility&
_p;
@@ -66,8 +68,12 @@ struct SScoringFacility::SRK1968Dialog
GtkToggleButton
*bSFRKPreview;
GtkButton
+ *bSFRKDismiss,
*bSFRKApply;
+ GtkLabel
+ *lSFRKTopInfo,
+ *lSFRKBottomInfo;
GtkDialog
*wSFRKProfileSave;
GtkEntry
@@ -98,6 +104,7 @@ void eSFRK_any_profile_value_changed_cb( GtkSpinButton*, gpointer);
void bSFRKPreview_toggled_cb( GtkToggleButton*, gpointer);
void bSFRKApply_clicked_cb( GtkButton*, gpointer);
+void bSFRKDismiss_clicked_cb( GtkButton*, gpointer);
void eSFRK_any_profile_origin_toggled_cb(GtkRadioButton*, gpointer);
void eSFRKProfileSaveName_changed_cb(GtkEditable*, gpointer);
diff --git a/upstream/src/aghermann/ui/sf/d/rk1968_cb.cc b/upstream/src/aghermann/ui/sf/d/rk1968_cb.cc
index 5351724..9fc8fc0 100644
--- a/upstream/src/aghermann/ui/sf/d/rk1968_cb.cc
+++ b/upstream/src/aghermann/ui/sf/d/rk1968_cb.cc
@@ -35,16 +35,44 @@ wSFRK_show_cb(
{
auto& RK = *(SScoringFacility::SRK1968Dialog*)userdata;
auto& SF = RK._p;
+ SF.rk1968_dialog_shown = true;
+ // 1. profiles
RK.load_profiles();
if ( RK.profiles.empty() )
RK.profiles.emplace_back(
*SF._p.ED,
agh::SExpDirLevelId {SF._p.ED->group_of(SF.csubject()), SF.csubject().id, SF.session()});
+ RK.current_profile = RK.profiles.begin();
RK.populate_combo();
RK.set_profile_manage_buttons_visibility();
+
+ // 2. service backup
+ RK.backup.resize(SF.sepisode().sources.front().n_pages());
+ RK.backup = SF.sepisode().sources.front().pages();
+
+ // 3. info
+ size_t n_available_channels = 0;
+ for ( auto &R : SF.sepisode().recordings )
+ if ( R.second.psd_profile.have_data() )
+ ++n_available_channels;
+ gtk_label_set_markup(
+ RK.lSFRKTopInfo,
+ snprintf_buf(
+ "<b>RK1968</b> (%zu EEG channel%s)",
+ n_available_channels, (n_available_channels == 1) ? "" : "s"));
+ gtk_label_set_markup(
+ RK.lSFRKBottomInfo,
+ "");
+
+ // 4. set up try/apply buttons
+ RK.suppress_preview_handler = true;
+ gtk_toggle_button_set_active( RK.bSFRKPreview, FALSE);
+ RK.suppress_preview_handler = false;
+
+ gtk_widget_set_sensitive( (GtkWidget*)RK.bSFRKApply, FALSE);
}
void
@@ -53,6 +81,8 @@ wSFRK_hide_cb(
gpointer userdata)
{
auto& RK = *(SScoringFacility::SRK1968Dialog*)userdata;
+ auto& SF = RK._p;
+ SF.rk1968_dialog_shown = false;
RK.save_profiles();
}
@@ -74,30 +104,37 @@ bSFRKPreview_toggled_cb(
{
auto& RK = *(SScoringFacility::SRK1968Dialog*)userdata;
auto& SF = RK._p;
+ if ( RK.suppress_preview_handler )
+ return;
if ( gtk_toggle_button_get_active(button) ) {
SBusyBlock bb (RK.wSFRK);
- RK.backup = SF.sepisode().sources.front().pages();
-
RK.W_V.down();
- RK.Pp2.score( SF.sepisode());
+ size_t pages_scored_successfuly;
+ if ( 0 == RK.Pp2.score( SF.sepisode(), &pages_scored_successfuly) )
+ gtk_label_set_markup(
+ RK.lSFRKBottomInfo,
+ snprintf_buf(
+ "<small>Scored %zu page%s</small>", pages_scored_successfuly, (pages_scored_successfuly == 1) ? "" : "s"));
+ else
+ gtk_label_set_markup(
+ RK.lSFRKBottomInfo, "Hm. Something is wrong.");
+
+ SF.get_hypnogram();
gtk_widget_set_sensitive( (GtkWidget*)RK.bSFRKApply, TRUE);
} else {
SF.sepisode().sources.front().pages() = RK.backup;
+ SF.get_hypnogram();
+
gtk_widget_set_sensitive( (GtkWidget*)RK.bSFRKApply, FALSE);
}
- // gtk_label_set_markup(
- // AD.lSFADDirtyPercent,
- // snprintf_buf( "%4.2f%% marked", AD.using_channel->calculate_dirty_percent() * 100));
-
gtk_widget_queue_draw( (GtkWidget*)SF.daSFMontage);
gtk_widget_queue_draw( (GtkWidget*)SF.daSFHypnogram);
-
}
void
@@ -105,7 +142,29 @@ bSFRKApply_clicked_cb(
GtkButton*,
gpointer userdata)
{
-
+ auto& RK = *(SScoringFacility::SRK1968Dialog*)userdata;
+
+ gtk_widget_hide( (GtkWidget*)RK.wSFRK);
+}
+
+void
+bSFRKDismiss_clicked_cb(
+ GtkButton*,
+ const gpointer userdata)
+{
+ auto& RK = *(SScoringFacility::SRK1968Dialog*)userdata;
+ auto& SF = RK._p;
+
+ gtk_widget_hide( (GtkWidget*)RK.wSFRK);
+
+ if ( TRUE == gtk_toggle_button_get_active(RK.bSFRKPreview) ) {
+ SF.sepisode().sources.front().pages() = RK.backup;
+
+ SF.get_hypnogram();
+
+ gtk_widget_queue_draw( (GtkWidget*)SF.daSFMontage);
+ gtk_widget_queue_draw( (GtkWidget*)SF.daSFHypnogram);
+ }
}
diff --git a/upstream/src/aghermann/ui/sf/sf.cc b/upstream/src/aghermann/ui/sf/sf.cc
index ef7d878..f2ce60d 100644
--- a/upstream/src/aghermann/ui/sf/sf.cc
+++ b/upstream/src/aghermann/ui/sf/sf.cc
@@ -68,6 +68,7 @@ SScoringFacility (agh::CSubject& J,
_sepisode (J.measurements.at(D)[E]),
hypnogram_button_down (false),
artifacts_dialog_shown (false),
+ rk1968_dialog_shown (false),
mode (TMode::scoring),
crosshair_at (10),
show_cur_pos_time_relative (false),
@@ -309,9 +310,6 @@ SScoringFacility (agh::CSubject& J,
SScoringFacility::
~SScoringFacility ()
{
- // put scores
- put_hypnogram();
-
// save montage
save_montage();
@@ -572,6 +570,8 @@ SScoringFacility::
do_score_forward( const char score_ch)
{
hypnogram[_cur_page] = score_ch;
+ put_hypnogram();
+
calculate_scored_percent();
draw_score_stats();
set_cur_vpage( _cur_page+1);
@@ -582,6 +582,8 @@ SScoringFacility::
do_score_back( const char score_ch)
{
hypnogram[_cur_page] = score_ch;
+ put_hypnogram();
+
calculate_scored_percent();
draw_score_stats();
set_cur_vpage( _cur_page-1);
diff --git a/upstream/src/aghermann/ui/sf/sf.hh b/upstream/src/aghermann/ui/sf/sf.hh
index 2623262..152744c 100644
--- a/upstream/src/aghermann/ui/sf/sf.hh
+++ b/upstream/src/aghermann/ui/sf/sf.hh
@@ -121,7 +121,8 @@ class SScoringFacility
// volatile
bool suppress_redraw:1,
hypnogram_button_down:1,
- artifacts_dialog_shown:1;
+ artifacts_dialog_shown:1,
+ rk1968_dialog_shown:1;
enum class TMode {
scoring,
marking,
--
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