[med-svn] [SCM] aghermann branch, master, updated. 4f7a3b774136ffffbaf9b05d90bd568347bc5461
andrei zavada
johnhommer at gmail.com
Fri Nov 16 00:50:23 UTC 2012
The following commit has been merged in the master branch:
commit 9864140ceaa75067d02c50dc74df314a36ed2836
Author: andrei zavada <johnhommer at gmail.com>
Date: Sat Oct 20 03:46:24 2012 +0300
WIP (global AD)
diff --git a/src/expdesign/recording.hh b/src/expdesign/recording.hh
index b715f63..a75a728 100644
--- a/src/expdesign/recording.hh
+++ b/src/expdesign/recording.hh
@@ -93,7 +93,6 @@ class CRecording
return _source.recording_time() * _source.samplerate(_sig_no);
}
-
// cut through, and cache it please
template <typename T>
const valarray<T>
diff --git a/src/ui/ed-construct.cc b/src/ui/ed-construct.cc
index c3537ab..0b05b5c 100644
--- a/src/ui/ed-construct.cc
+++ b/src/ui/ed-construct.cc
@@ -205,8 +205,10 @@ SExpDesignUIWidgets ()
// artifact detection profiles
if ( !AGH_GBGETOBJ (GtkDialog, wGlobalArtifactDetection) ||
- !AGH_GBGETOBJ (GtkComboBox, eGlobalADProfiles) )
+ !AGH_GBGETOBJ (GtkComboBox, eGlobalADProfiles) ||
+ !AGH_GBGETOBJ (GtkCheckButton, eGlobalADKeepExisting) )
throw runtime_error ("Failed to construct widgets");
+
gtk_combo_box_set_model( eGlobalADProfiles,
(GtkTreeModel*)mGlobalADProfiles);
gtk_combo_box_set_id_column( eGlobalADProfiles, 0);
diff --git a/src/ui/ed-populate.cc b/src/ui/ed-populate.cc
index 3d85893..e5f0f96 100644
--- a/src/ui/ed-populate.cc
+++ b/src/ui/ed-populate.cc
@@ -97,6 +97,8 @@ populate( bool do_load)
populate_mGlobalADProfiles();
populate_1();
+ gtk_combo_box_set_active( eGlobalADProfiles, 0);
+
if ( display_profile_type == sigfile::TMetricType::Psd ) {
gtk_combo_box_set_active( eMsmtProfileType, 0);
gtk_widget_set_visible( (GtkWidget*)cMsmtProfileParams2, FALSE);
diff --git a/src/ui/ed-widgets.hh b/src/ui/ed-widgets.hh
index 8c7d824..cab26b9 100644
--- a/src/ui/ed-widgets.hh
+++ b/src/ui/ed-widgets.hh
@@ -306,6 +306,8 @@ struct SExpDesignUIWidgets {
*wGlobalArtifactDetection;
GtkComboBox
*eGlobalADProfiles;
+ GtkCheckButton
+ *eGlobalADKeepExisting;
// colours
enum TColour {
diff --git a/src/ui/ed.cc b/src/ui/ed.cc
index e96c911..d8188b0 100644
--- a/src/ui/ed.cc
+++ b/src/ui/ed.cc
@@ -263,9 +263,10 @@ load_artifact_detection_profiles()
SDetectArtifactsParamPack P;
DEF_UNIQUE_CHARP (_);
int int_estimate_E, int_use_range;
- if ( getline( &_, NULL, domien) > 0 &&
- fscanf( domien, "%la %la %la %la %la %la %la %la %la %la %la "
- "%zu %zu %d %d\n",
+ if ( 16 ==
+ fscanf( domien, "%a[^\n]\n%la %la %la %la %la %la %la %la %la %la %la "
+ "%zu %zu %d %d",
+ &_,
&P.scope,
&P.upper_thr, &P.lower_thr,
&P.f0, &P.fc, &P.bandwidth,
@@ -274,7 +275,7 @@ load_artifact_detection_profiles()
&P.sssu_hist_size,
&P.smooth_side,
&int_estimate_E,
- &int_use_range) == 15 ) {
+ &int_use_range) ) {
P.estimate_E = (bool)int_estimate_E;
P.use_range = (bool)int_use_range;
global_artifact_detection_profiles[_] = P;
diff --git a/src/ui/ed_cb.cc b/src/ui/ed_cb.cc
index 0b23b3a..bde48c2 100644
--- a/src/ui/ed_cb.cc
+++ b/src/ui/ed_cb.cc
@@ -77,26 +77,6 @@ tTaskSelector_switch_page_cb( GtkNotebook*, gpointer, guint page_num, gpointer u
-
-void
-iExpClose_activate_cb( GtkMenuItem*, gpointer userdata)
-{
- auto& ED = *(SExpDesignUI*)userdata;
- gtk_window_get_position( ED.wMainWindow, &ED.geometry.x, &ED.geometry.y);
- gtk_window_get_size( ED.wMainWindow, &ED.geometry.w, &ED.geometry.h);
-
- g_signal_emit_by_name( ED._p->bSessionChooserClose, "clicked");
- // gtk_widget_show( (GtkWidget*)ED.wExpDesignChooser);
- // gtk_widget_hide( (GtkWidget*)ED.wMainWindow);
- // gtk_widget_hide( (GtkWidget*)ED.wGlobalAnnotations);
- // gtk_widget_hide( (GtkWidget*)ED.wEDFFileDetails);
- // gtk_widget_hide( (GtkWidget*)ED.wScanLog);
- // // if ( gtk_widget_get_visible( (GtkWidget*)wScoringFacility) )
- // // gtk_widget_hide( (GtkWidget*)wScoringFacility);
- // // better make sure bExpChange is greyed out on opening any child windows
-}
-
-
void
iExpRefresh_activate_cb( GtkMenuItem*, gpointer userdata)
{
@@ -129,18 +109,18 @@ iExpBasicSADetectUltradianCycles_activate_cb( GtkMenuItem*, gpointer userdata)
aghui::SBusyBlock bb (ED.wMainWindow);
- function<bool( agh::CSubject::SEpisode&)> filter =
+ using namespace agh;
+ CExpDesign::TEpisodeFilterFun filter =
[&ED]( agh::CSubject::SEpisode& E) -> bool
{
return E.recordings.find( ED.AghH()) != E.recordings.end();
};
- function<void( agh::CSubject::SEpisode&)> F =
+ CExpDesign::TEpisodeOpFun F =
[&ED]( agh::CSubject::SEpisode& E)
{
ED.do_detect_ultradian_cycle( E.recordings.at( ED.AghH()));
};
- function<void( const agh::CJGroup&, const agh::CSubject&, const string&, const agh::CSubject::SEpisode&,
- size_t, size_t)> reporter =
+ CExpDesign::TEpisodeReportFun reporter =
[&ED]( const agh::CJGroup&, const agh::CSubject& J, const string&, const agh::CSubject::SEpisode& E,
size_t i, size_t n)
{
@@ -163,18 +143,82 @@ iExpGloballyDetectArtifacts_activate_cb( GtkMenuItem*, gpointer userdata)
auto& ED = *(SExpDesignUI*)userdata;
if ( GTK_RESPONSE_OK ==
- gtk_dialog_run( ED.wGlobalArtifactDetection) )
- FAFA;
+ gtk_dialog_run( ED.wGlobalArtifactDetection) ) {
+ auto& P = ED.global_artifact_detection_profiles[
+ gtk_combo_box_get_active_id(ED.eGlobalADProfiles)];
+ bool keep_existing = gtk_toggle_button_get_active( (GtkToggleButton*)ED.eGlobalADKeepExisting);
+
+ using namespace agh;
+ CExpDesign::TRecordingOpFun F =
+ [&]( CRecording& R)
+ {
+ auto& F = R.F();
+ for ( auto& H : R.F().channel_list() ) {
+ auto sr = F.samplerate(H.c_str());
+ auto af = F.artifacts(H.c_str());
+
+ auto signal_original
+ = F.get_signal_original(H.c_str());
+ auto sssu =
+ sigfile::CBinnedMC::do_sssu_reduction(
+ signal_original,
+ sr, P.scope,
+ P.mc_gain, P.iir_backpolate,
+ P.f0, P.fc, P.bandwidth);
+ valarray<TFloat>
+ sssu_diff =
+ {sssu.first - sssu.second};
+
+ sigproc::smooth( sssu_diff, P.smooth_side);
+
+ double E;
+ if ( P.estimate_E )
+ E = P.use_range
+ ? sigfile::CBinnedMC::estimate_E(
+ sssu_diff,
+ P.sssu_hist_size,
+ P.dmin, P.dmax)
+ : sigfile::CBinnedMC::estimate_E(
+ sssu_diff,
+ P.sssu_hist_size);
+ else
+ E = P.E;
+
+ auto marked =
+ sigfile::CBinnedMC::detect_artifacts(
+ sssu_diff,
+ P.upper_thr, P.lower_thr,
+ E);
+ if ( not keep_existing )
+ af.clear_all();
+ for ( size_t p = 0; p < marked.size(); ++p )
+ af.mark_artifact(
+ marked[p] * P.scope * sr, (marked[p]+1) * P.scope * sr);
+ }
+ };
+ CExpDesign::TRecordingReportFun G =
+ [&]( const CJGroup&, const CSubject& J, const string&, const CSubject::SEpisode& E, const CRecording& R,
+ size_t i, size_t total)
+ {
+ snprintf_buf(
+ "(%zu of %zu) Detect artifacts in %s/%s/%s:%s", i, total,
+ ED.ED->group_of(J), J.name(), E.name(), R.F().channel_by_id(R.h()));
+ ED.buf_on_main_status_bar();
+ gtk_widget_queue_draw( (GtkWidget*)ED.cMeasurements);
+ gdk_window_process_updates(
+ gtk_widget_get_parent_window( (GtkWidget*)ED.cMeasurements),
+ TRUE);
+ };
+ CExpDesign::TRecordingFilterFun filter =
+ [&]( CRecording& R)
+ {
+ return R.signal_type() == sigfile::SChannel::TType::eeg;
+ };
+ ED.ED -> for_all_recordings( F, G, filter);
+ }
}
-void
-iExpQuit_activate_cb( GtkMenuItem*, gpointer userdata)
-{
- auto& ED = *(SExpDesignUI*)userdata;
- g_signal_emit_by_name( ED._p->bSessionChooserQuit, "clicked");
-}
-
void
iMontageSetDefaults_activate_cb( GtkMenuItem*, gpointer userdata)
@@ -251,6 +295,35 @@ iHelpUsage_activate_cb( GtkMenuItem*, gpointer)
}
+inline namespace {
+
+void
+before_ED_close( SExpDesignUI& ED)
+{
+ gtk_window_get_position( ED.wMainWindow, &ED.geometry.x, &ED.geometry.y);
+ gtk_window_get_size( ED.wMainWindow, &ED.geometry.w, &ED.geometry.h);
+}
+
+} // inline namespace
+
+void
+iExpClose_activate_cb( GtkMenuItem*, gpointer userdata)
+{
+ auto& ED = *(SExpDesignUI*)userdata;
+
+ before_ED_close( ED);
+ g_signal_emit_by_name( ED._p->bSessionChooserClose, "clicked");
+}
+
+void
+iExpQuit_activate_cb( GtkMenuItem*, gpointer userdata)
+{
+ auto& ED = *(SExpDesignUI*)userdata;
+
+ before_ED_close( ED);
+ g_signal_emit_by_name( ED._p->bSessionChooserQuit, "clicked");
+}
+
diff --git a/src/ui/sc_cb.cc b/src/ui/sc_cb.cc
index 10c9a57..f58d1c4 100644
--- a/src/ui/sc_cb.cc
+++ b/src/ui/sc_cb.cc
@@ -87,6 +87,9 @@ bSessionChooserQuit_clicked_cb( GtkButton *button, gpointer userdata)
{
auto& SC = *(SSessionChooser*)userdata;
+ if ( SC.ed )
+ SC.close_current_session();
+
// GtkTreeSelection *selection = gtk_tree_view_get_selection( (GtkTreeView*)SC.tvSessionChooserList);
// GtkTreeModel *model;
// GList *paths = gtk_tree_selection_get_selected_rows( selection, &model);
diff --git a/src/ui/sf-artifacts_cb.cc b/src/ui/sf-artifacts_cb.cc
index df6c195..e7f15fd 100644
--- a/src/ui/sf-artifacts_cb.cc
+++ b/src/ui/sf-artifacts_cb.cc
@@ -25,9 +25,11 @@ eSFADProfiles_changed_cb( GtkComboBox* b, gpointer userdata)
auto& SF = *(SScoringFacility*)userdata;
auto& AD = SF.artifact_detection_dialog;
- AD.P = SF._p.global_artifact_detection_profiles[
- gtk_combo_box_get_active_id(b)];
- AD.W_V.up();
+ if ( gtk_combo_box_get_active( b) != -1 ) {
+ AD.P = SF._p.global_artifact_detection_profiles[
+ gtk_combo_box_get_active_id(b)];
+ AD.W_V.up();
+ }
}
void
@@ -41,8 +43,13 @@ bSFADProfileSave_clicked_cb( GtkButton*, gpointer userdata)
AD.W_V.down();
SF._p.global_artifact_detection_profiles[
gtk_entry_get_text( SF.eSFADSaveProfileNameName)] = AD.P;
+
SF._p.populate_mGlobalADProfiles();
SF.populate_mSFADProfiles(); // stupid
+
+ int now_active = SF._p.global_artifact_detection_profiles.size()-1;
+ gtk_combo_box_set_active( SF.eSFADProfiles, now_active);
+ gtk_combo_box_set_active( SF._p.eGlobalADProfiles, now_active);
}
}
@@ -52,7 +59,18 @@ bSFADProfileDelete_clicked_cb( GtkButton*, gpointer userdata)
auto& SF = *(SScoringFacility*)userdata;
auto& AD = SF.artifact_detection_dialog;
-
+ const gchar *deleting_id = gtk_combo_box_get_active_id( SF.eSFADProfiles);
+ int deleting = gtk_combo_box_get_active( SF.eSFADProfiles);
+ SF._p.global_artifact_detection_profiles.erase( deleting_id);
+
+ SF._p.populate_mGlobalADProfiles();
+ SF.populate_mSFADProfiles(); // stupid
+
+ if ( SF._p.global_artifact_detection_profiles.size() > 0 &&
+ deleting > SF._p.global_artifact_detection_profiles.size()-1 )
+ gtk_combo_box_set_active( SF.eSFADProfiles, deleting-1);
+
+ g_signal_emit_by_name( SF.eSFADProfiles, "clocked");
}
--
Sleep experiment manager
More information about the debian-med-commit
mailing list