[med-svn] [SCM] aghermann branch, master, updated. 4f7a3b774136ffffbaf9b05d90bd568347bc5461

Andrei Zavada johnhommer at gmail.com
Fri Nov 16 00:50:55 UTC 2012


The following commit has been merged in the master branch:
commit f9cc96c9853638374245d3e8f7aeacb3643463dd
Author: Andrei Zavada <johnhommer at gmail.com>
Date:   Mon Nov 12 11:56:43 2012 +0200

    ICM

diff --git a/src/expdesign/Makefile.am b/src/expdesign/Makefile.am
index 98c0275..0e42578 100644
--- a/src/expdesign/Makefile.am
+++ b/src/expdesign/Makefile.am
@@ -7,9 +7,9 @@ noinst_LIBRARIES := liba.a
 
 liba_a_SOURCES := \
 	forward-decls.hh \
+	loadsave.cc \
+	tree-scanner.cc \
 	primaries.cc \
-	primaries-loadsave.cc \
-	primaries-tree-scanner.cc \
 	primaries.hh \
 	recording.cc \
 	recording.hh
diff --git a/src/expdesign/primaries-loadsave.cc b/src/expdesign/loadsave.cc
similarity index 97%
rename from src/expdesign/primaries-loadsave.cc
rename to src/expdesign/loadsave.cc
index 4a194c7..d90570b 100644
--- a/src/expdesign/primaries-loadsave.cc
+++ b/src/expdesign/loadsave.cc
@@ -1,6 +1,6 @@
 // ;-*-C++-*-
 /*
- *       File name:  expdesign/primaries-loadsave.cc
+ *       File name:  expdesign/loadsave.cc
  *         Project:  Aghermann
  *          Author:  Andrei Zavada <johnhommer at gmail.com>
  * Initial version:  2008-04-28
diff --git a/src/expdesign/primaries-tree-scanner.cc b/src/expdesign/tree-scanner.cc
similarity index 99%
rename from src/expdesign/primaries-tree-scanner.cc
rename to src/expdesign/tree-scanner.cc
index 99c5160..902930e 100644
--- a/src/expdesign/primaries-tree-scanner.cc
+++ b/src/expdesign/tree-scanner.cc
@@ -1,6 +1,6 @@
 // ;-*-C++-*-
 /*
- *       File name:  expdesign/primaries-tree-scanner.cc
+ *       File name:  expdesign/tree-scanner.cc
  *         Project:  Aghermann
  *          Author:  Andrei Zavada <johnhommer at gmail.com>
  * Initial version:  2012-09-19
diff --git a/src/metrics/swu.cc b/src/metrics/swu.cc
index 3c35d34..b24bcc4 100644
--- a/src/metrics/swu.cc
+++ b/src/metrics/swu.cc
@@ -144,14 +144,6 @@ compute( const SPPack& req_params,
       // so that saved power is usable irrespective of what TFloat is today
 	valarray<double> S = to_vad( _using_F.get_signal_filtered( _using_sig_no));
 
-      // 1. dampen samples marked as artifacts
-	// already done in get_signal_filtered()
-
-      // 2. zero-mean and detrend
-	// zero-mean already done in CEDFFile::get_signal_filtered()
-
-      // 4. obtain power spectrum
-	// prepare
 	for ( size_t p = 0; p < pages(); ++p ) {
 		nmth_bin(p, 0) =
 			sin(p * M_PI);
diff --git a/src/model/beersma.hh b/src/model/beersma.hh
index c00b971..94ca165 100644
--- a/src/model/beersma.hh
+++ b/src/model/beersma.hh
@@ -78,10 +78,10 @@ classic_fit( agh::CRecording&,
 
 struct SUltradianCycle {
 	double	r, T, d, b;
-	SUltradianCycle& operator=( const SUltradianCycle& rv) = default;
+	SUltradianCycle& operator=( const SUltradianCycle&) = default;
 	static constexpr double
 		ir = 0.0001,  iT =   1., id =  .1, ib = .1, // the last one is a normalized value of metric
-		ur = 0.010,   uT = 120., ud =  60., ub = .01,
+		ur = 0.010,   uT = 130., ud =  60., ub = .01,
 		lr = 0.001,   lT =  60., ld = -60., lb = .1;
 };
 
@@ -148,25 +148,6 @@ class FUltradianCycle
 			double A = -(exp(-r*t) * (cos((t+d)/T * 2 * M_PI) - 1)) - b;
 			return (A > 0.) ? A : 0.;
 		}
-
-	// // partial derivatives
-	// double dr( double t) const
-	// 	{
-	// 		return -t * exp(-r*t) * (cos((t+d)/T) - 1);
-	// 	}
-	// double dT( double t) const
-	// 	{
-	// 		return (t + d) * exp(-r*t) * sin((t+d)/T) / gsl_pow_2(T);
-	// 	}
-	// double dd( double t) const
-	// 	{
-	// 		return exp(-r*t) * sin((t+d)/T) / T;
-	// 	}
-	// double db( double t) const
-	// 	{
-	// 		return 1;
-	// 	}
-
 };
 
 // struct SUltradianCycleWeightedData {
diff --git a/src/model/ultradian-cycle.cc b/src/model/ultradian-cycle.cc
index 03352de..3f5cccc 100644
--- a/src/model/ultradian-cycle.cc
+++ b/src/model/ultradian-cycle.cc
@@ -141,13 +141,13 @@ uc_siman_metric( void *xp, void *yp)
 	return agh::beersma::distance( X1, X2);
 }
 
-void
-uc_siman_print( void *xp)
-{
-	auto& P = *(SUltradianCyclePPack*)(xp);
-	printf( "F r = %g, T = %g, d = %g, b = %g\n",
-		P.X[0], P.X[1], P.X[2], P.X[3]);
-}
+// void
+// uc_siman_print( void *xp)
+// {
+// 	auto& P = *(SUltradianCyclePPack*)(xp);
+// 	printf( "F r = %g, T = %g, d = %g, b = %g\n",
+// 		P.X[0], P.X[1], P.X[2], P.X[3]);
+// }
 
 } // inline namespace
 
diff --git a/src/ui/Makefile.am b/src/ui/Makefile.am
index 7ffc9a2..87af932 100644
--- a/src/ui/Makefile.am
+++ b/src/ui/Makefile.am
@@ -10,19 +10,19 @@ noinst_LIBRARIES := liba.a
 
 liba_a_SOURCES := \
 	forward-decls.hh \
-	ui.hh \
-	ui++.hh \
-	misc.hh \
 	globals.hh \
-	libcommon.cc
+	libcommon.cc \
+	misc.hh \
+	ui++.hh \
+	ui.hh
 
 if DO_PCH
 BUILT_SOURCES := \
-	ui.hh.gch \
-	ui++.hh.gch \
-	misc.hh.gch \
+	forward-decls.hh.gch \
 	globals.hh.gch \
-	forward-decls.hh.gch
+	misc.hh.gch \
+	ui++.hh.gch \
+	ui.hh.gch
 %.hh.gch: %.hh
 	$(CXXCOMPILE) -c $<
 CLEANFILES := \
diff --git a/src/ui/libcommon.cc b/src/ui/libcommon.cc
index 52731a8..ad43745 100644
--- a/src/ui/libcommon.cc
+++ b/src/ui/libcommon.cc
@@ -69,7 +69,6 @@ prepare_for_expdesign()
 		return -1;
 	}
 	g_resources_register( gresource);
-	printf( "Loaded  " PACKAGE_DATADIR "/" PACKAGE "/" AGH_UI_GRESOURCE_FILE "\n");
 
 	return 0;
 }
diff --git a/src/ui/mf/Makefile.am b/src/ui/mf/Makefile.am
index e640c29..9560715 100644
--- a/src/ui/mf/Makefile.am
+++ b/src/ui/mf/Makefile.am
@@ -8,11 +8,11 @@ AM_CXXFLAGS := \
 noinst_LIBRARIES := liba.a
 
 liba_a_SOURCES := \
-	mf.hh \
-	mf_cb.hh \
-	mf.cc \
 	mf-construct.cc \
-	mf_cb.cc
+	mf.cc \
+	mf.hh \
+	mf_cb.cc \
+	mf_cb.hh
 
 if DO_PCH
 BUILT_SOURCES := \
diff --git a/src/ui/mw/Makefile.am b/src/ui/mw/Makefile.am
index 8bc2ff4..6499a99 100644
--- a/src/ui/mw/Makefile.am
+++ b/src/ui/mw/Makefile.am
@@ -8,21 +8,22 @@ AM_CXXFLAGS = \
 noinst_LIBRARIES = liba.a
 
 liba_a_SOURCES = \
-	mw.hh \
-	mw-widgets.hh \
-	mw_cb.hh \
-	mw.cc \
-	mw_cb.cc \
+	mw-admit-one.cc \
 	mw-construct.cc \
-	mw-splash.cc \
-	mw-populate.cc \
+	mw-loadsave.cc \
+	mw-mainmenu_cb.cc \
 	mw-measurements.cc \
 	mw-measurements_cb.cc \
-	mw-loadsave.cc \
-	mw-admit-one.cc \
+	mw-populate.cc \
 	mw-settings_cb.cc \
 	mw-simulations.cc \
-	mw-simulations_cb.cc
+	mw-simulations_cb.cc \
+	mw-splash.cc \
+	mw-widgets.hh \
+	mw.cc \
+	mw.hh \
+	mw_cb.cc \
+	mw_cb.hh
 
 if DO_PCH
 BUILT_SOURCES = \
diff --git a/src/ui/mw/mw-mainmenu_cb.cc b/src/ui/mw/mw-mainmenu_cb.cc
new file mode 100644
index 0000000..a6b3cf4
--- /dev/null
+++ b/src/ui/mw/mw-mainmenu_cb.cc
@@ -0,0 +1,367 @@
+// ;-*-C++-*-
+/*
+ *       File name:  ui/mw/mw-mainmenu_cb.cc
+ *         Project:  Aghermann
+ *          Author:  Andrei Zavada <johnhommer at gmail.com>
+ * Initial version:  2012-11-12
+ *
+ *         Purpose:  SExpDesignUI widget callbacks (main menu items)
+ *
+ *         License:  GPL
+ */
+
+#include "ui/misc.hh"
+#include "mw.hh"
+#include "mw_cb.hh"
+#include "ui/sm/sm.hh"
+#include "ui/sf/sf.hh"
+
+using namespace aghui;
+
+extern "C" {
+
+void
+iExpRefresh_activate_cb( GtkMenuItem*, gpointer userdata)
+{
+	auto& ED = *(SExpDesignUI*)userdata;
+	ED.do_rescan_tree( true);
+}
+
+void
+iExpPurgeComputed_activate_cb( GtkMenuItem*, gpointer userdata)
+{
+	auto& ED = *(SExpDesignUI*)userdata;
+	ED.do_purge_computed();
+}
+
+
+void
+iExpAnnotations_activate_cb( GtkMenuItem*, gpointer userdata)
+{
+	auto& ED = *(SExpDesignUI*)userdata;
+	gtk_dialog_run( ED.wGlobalAnnotations);
+}
+
+// annotations dialog
+
+void
+tvGlobalAnnotations_row_activated_cb( GtkTreeView* tree_view,
+				      GtkTreePath* path,
+				      GtkTreeViewColumn *column,
+				      gpointer userdata)
+{
+	auto& ED = *(SExpDesignUI*)userdata;
+	aghui::SExpDesignUI::SAnnotation *ann;
+	GtkTreeIter iter;
+	gtk_tree_model_get_iter( (GtkTreeModel*)ED.mGlobalAnnotations, &iter, path);
+	gtk_tree_model_get( (GtkTreeModel*)ED.mGlobalAnnotations, &iter,
+			    ED.mannotations_ref_col, &ann,
+			    -1);
+	if ( ann == nullptr )
+		return;
+
+	gtk_widget_hide( (GtkWidget*)ED.wGlobalAnnotations);
+	aghui::SScoringFacility* found = nullptr;
+	for ( auto &F : ED.open_scoring_facilities )
+		if ( &F->csubject() == &ann->csubject
+		     && F->session() == ann->session
+		     && &F->sepisode() == &ann->sepisode ) {
+			found = F;
+			break;
+		}
+	if ( found ) {
+		auto pages = ann->page_span( found->vpagesize());
+		gtk_widget_show( (GtkWidget*)found->wScoringFacility);
+		found->set_cur_vpage( pages.a, true);
+	} else {
+		ED.using_subject = ED.subject_presentation_by_csubject( ann->csubject);
+		auto SF = new aghui::SScoringFacility( ann->csubject, ann->session, ann->sepisode.name(), ED);
+		auto pages = ann->page_span( SF->vpagesize());
+		SF->set_cur_vpage( pages.a, true);
+	}
+}
+
+
+
+
+
+void
+iExpBasicSADetectUltradianCycles_activate_cb( GtkMenuItem*, gpointer userdata)
+{
+	auto& ED = *(SExpDesignUI*)userdata;
+
+	aghui::SBusyBlock bb (ED.wMainWindow);
+
+	using namespace agh;
+	CExpDesign::TEpisodeFilterFun filter =
+		[&ED]( agh::CSubject::SEpisode& E) -> bool
+	{
+		return E.recordings.find( ED.AghH()) != E.recordings.end();
+	};
+	CExpDesign::TEpisodeOpFun F =
+		[&ED]( agh::CSubject::SEpisode& E)
+	{
+		ED.do_detect_ultradian_cycle( E.recordings.at( ED.AghH()));
+	};
+	CExpDesign::TEpisodeReportFun reporter =
+		[&ED]( const agh::CJGroup&, const agh::CSubject& J, const string&, const agh::CSubject::SEpisode& E,
+		       size_t i, size_t n)
+	{
+		snprintf_buf(
+			"(%zu of %zu) %s/%s/%s", i, n,
+			ED.ED->group_of(J), J.name(), E.name());
+		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);
+	};
+
+	ED.ED->for_all_episodes( F, reporter, filter);
+}
+
+void
+iExpGloballyDetectArtifacts_activate_cb( GtkMenuItem*, gpointer userdata)
+{
+	auto& ED = *(SExpDesignUI*)userdata;
+
+	if ( ED.global_artifact_detection_profiles.size() < 1 ) {
+		pop_ok_message( ED.wMainWindow,
+				"Create some profiles first",
+				"You can do it by opening a recording in Scoring Facility and"
+				" tweaking default parameters in Artifact Detect dialog."
+				" After saving them as a profile, it will appear here.");
+		return;
+	}
+
+	gtk_label_set_markup(
+		ED.lGlobalADHint,
+		(ED.global_artifact_detection_profiles.size() < 2)
+		? "<small>You can create a custom profile in Scoring Facility,\n"
+		  "after tuning parameters on a real recording.</small>"
+		: ""); // good boy
+
+
+	auto response = gtk_dialog_run( ED.wGlobalArtifactDetection);
+	if ( response == GTK_RESPONSE_CANCEL ||
+	     response == GTK_RESPONSE_DELETE_EVENT )
+		return; // just to save on indents in those lambdas below
+
+	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);
+
+	SBusyBlock bb (ED.wMainWindow);
+
+	using namespace agh;
+	CExpDesign::TRecordingOpFun F;
+	CExpDesign::TRecordingFilterFun filter;
+	CExpDesign::TRecordingReportFun G =
+		[&]( const CJGroup&, const CSubject& J, const string& D, 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:%s", i, total,
+				ED.ED->group_of(J), J.name(), D.c_str(), E.name(), R.F().channel_by_id(R.h()));
+			ED.buf_on_main_status_bar();
+			gtk_flush();
+		};
+	switch ( response ) {
+	case GTK_RESPONSE_OK:
+		F =
+		[&]( CRecording& R)
+		{
+			auto	sr = R.F().samplerate(R.h());
+			auto&	af = R.F().artifacts(R.h());
+
+			auto	signal_original
+				= R.F().get_signal_original(R.h());
+
+			if ( not keep_existing )
+				af.clear_all();
+			auto	marked
+				= metrics::mc::detect_artifacts( signal_original, sr, P);
+			for ( size_t p = 0; p < marked.size(); ++p )
+				af.mark_artifact(
+					marked[p] * P.scope * sr,
+					(marked[p]+1) * P.scope * sr);
+		};
+		filter =
+		[&]( CRecording& R)
+		{
+			return R.signal_type() == sigfile::SChannel::TType::eeg;
+		};
+	    break;
+	case 1: // "Clear All"
+		F =
+		[&]( CRecording& R)
+		{
+			auto& F = R.F();
+			for ( auto& H : R.F().channel_list() ) {
+				auto&	af = F.artifacts(H.c_str());
+				af.clear_all();
+			}
+		};
+		filter =
+		[&]( CRecording&)
+		{
+			return true; // clear in all channels (mark in EEG channels only)
+		};
+	    break;
+	default:
+		throw runtime_error ("Fix AD dialog response?");
+	}
+
+	forward_list<aghui::SBusyBlock*> bbl;
+	for ( auto& SFp : ED.open_scoring_facilities )
+		bbl.push_front( new aghui::SBusyBlock (SFp->wScoringFacility));
+
+	ED.ED -> for_all_recordings( F, G, filter);
+
+	for ( auto& SF : ED.open_scoring_facilities ) {
+		for ( auto& H : SF->channels )
+			if ( H.type == sigfile::SChannel::TType::eeg )
+				H.get_signal_filtered();
+		SF->queue_redraw_all();
+	}
+
+	ED.populate_1();
+
+	for ( auto& bb : bbl )
+		delete bb;
+}
+
+void
+eGlobalADProfiles_changed_cb( GtkComboBox *b, gpointer userdata)
+{
+	auto& ED = *(SExpDesignUI*)userdata;
+
+	gtk_widget_set_sensitive(
+		(GtkWidget*)ED.bGlobalADOK,
+		ED.global_artifact_detection_profiles.size() > 0);
+}
+
+
+
+// iMontageSetDefaults_activate_cb( GtkMenuItem*, gpointer userdata)
+// {
+// 	auto& ED = *(SExpDesignUI*)userdata;
+
+// 	if ( GTK_RESPONSE_OK ==
+// 	     gtk_dialog_run( ED.wMontageDefaults) )
+// 		FAFA;
+// }
+
+
+
+void
+iExpGloballySetFilters_activate_cb( GtkMenuItem*, gpointer userdata)
+{
+	auto& ED = *(SExpDesignUI*)userdata;
+
+	int LPO, HPO, NF;
+	double LPC, HPC;
+	aghui::SUIVarCollection W_V;
+	W_V.reg( ED.eGlobalFiltersLowPassCutoff, &LPC);
+	W_V.reg( ED.eGlobalFiltersLowPassOrder, &LPO);
+	W_V.reg( ED.eGlobalFiltersHighPassCutoff, &HPC);
+	W_V.reg( ED.eGlobalFiltersHighPassOrder, &HPO);
+	W_V.reg( ED.eGlobalFiltersNotchFilter, &NF);
+
+	if ( GTK_RESPONSE_OK ==
+	     gtk_dialog_run( ED.wGlobalFilters) ) {
+		forward_list<aghui::SBusyBlock*> bbl;
+		for ( auto& SFp : ED.open_scoring_facilities )
+			bbl.push_front( new aghui::SBusyBlock (SFp->wScoringFacility));
+		W_V.down();
+		for ( auto &G : ED.ED->groups )
+			for ( auto &J : G.second )
+				for ( auto &D : J.measurements )
+					for ( auto &E : D.second.episodes )
+						for ( auto &F : E.sources )
+							for ( auto &H : F.channel_list() ) {
+								auto& ff = F.filters(H.c_str());
+								ff.low_pass_cutoff = LPC;
+								ff.low_pass_order = LPO;
+								ff.high_pass_cutoff = HPC;
+								ff.high_pass_order = HPO;
+								ff.notch_filter = (sigfile::SFilterPack::TNotchFilter)NF;
+							}
+		ED.ED->sync();
+
+		for ( auto& SF : ED.open_scoring_facilities ) {
+			for ( auto& H : SF->channels )
+				if ( H.type == sigfile::SChannel::TType::eeg )
+					H.get_signal_filtered();
+			SF->queue_redraw_all();
+		}
+		ED.populate_1();
+		for ( auto& bb : bbl )
+			delete bb;
+	}
+}
+
+void
+bGlobalMontageResetAll_clicked_cb( GtkButton*, gpointer userdata)
+{
+	auto& ED = *(SExpDesignUI*)userdata;
+
+	snprintf_buf( "find '%s' -name '.*.montage' -delete",
+		      ED.ED->session_dir().c_str());
+	if ( system( __buf__) )
+		pop_ok_message( ED.wMainWindow, "Command '%s' returned a non-zero status. This is weird.", __buf__);
+}
+
+
+
+void
+iHelpAbout_activate_cb( GtkMenuItem*, gpointer userdata)
+{
+	auto& ED = *(SExpDesignUI*)userdata;
+	gtk_widget_show_all( (GtkWidget*)ED.wAbout);
+}
+
+void
+iHelpUsage_activate_cb( GtkMenuItem*, gpointer)
+{
+//	auto& ED = *(SExpDesignUI*)userdata;
+	gtk_show_uri( NULL,
+		      "http://johnhommer.com/academic/code/aghermann/usage/",
+		      GDK_CURRENT_TIME, NULL);
+}
+
+
+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");
+}
+
+
+
+} // extern "C"
+
+// eof
diff --git a/src/ui/mw/mw_cb.cc b/src/ui/mw/mw_cb.cc
index 57a2b62..92c0b98 100644
--- a/src/ui/mw/mw_cb.cc
+++ b/src/ui/mw/mw_cb.cc
@@ -1,6 +1,6 @@
 // ;-*-C++-*-
 /*
- *       File name:  ui/mw_cb.cc
+ *       File name:  ui/mw/mw_cb.cc
  *         Project:  Aghermann
  *          Author:  Andrei Zavada <johnhommer at gmail.com>
  * Initial version:  2011-06-29
@@ -11,7 +11,6 @@
  */
 
 #include "ui/misc.hh"
-#include "ui/sm/sm.hh"
 #include "ui/sf/sf.hh"
 #include "mw.hh"
 #include "mw_cb.hh"
@@ -76,310 +75,6 @@ tTaskSelector_switch_page_cb( GtkNotebook*, gpointer, guint page_num, gpointer u
 
 
 
-void
-iExpRefresh_activate_cb( GtkMenuItem*, gpointer userdata)
-{
-	auto& ED = *(SExpDesignUI*)userdata;
-	ED.do_rescan_tree( true);
-}
-
-void
-iExpPurgeComputed_activate_cb( GtkMenuItem*, gpointer userdata)
-{
-	auto& ED = *(SExpDesignUI*)userdata;
-	ED.do_purge_computed();
-}
-
-
-
-
-void
-iExpAnnotations_activate_cb( GtkMenuItem*, gpointer userdata)
-{
-	auto& ED = *(SExpDesignUI*)userdata;
-	gtk_dialog_run( ED.wGlobalAnnotations);
-}
-
-
-void
-iExpBasicSADetectUltradianCycles_activate_cb( GtkMenuItem*, gpointer userdata)
-{
-	auto& ED = *(SExpDesignUI*)userdata;
-
-	aghui::SBusyBlock bb (ED.wMainWindow);
-
-	using namespace agh;
-	CExpDesign::TEpisodeFilterFun filter =
-		[&ED]( agh::CSubject::SEpisode& E) -> bool
-	{
-		return E.recordings.find( ED.AghH()) != E.recordings.end();
-	};
-	CExpDesign::TEpisodeOpFun F =
-		[&ED]( agh::CSubject::SEpisode& E)
-	{
-		ED.do_detect_ultradian_cycle( E.recordings.at( ED.AghH()));
-	};
-	CExpDesign::TEpisodeReportFun reporter =
-		[&ED]( const agh::CJGroup&, const agh::CSubject& J, const string&, const agh::CSubject::SEpisode& E,
-		       size_t i, size_t n)
-	{
-		snprintf_buf(
-			"(%zu of %zu) %s/%s/%s", i, n,
-			ED.ED->group_of(J), J.name(), E.name());
-		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);
-	};
-
-	ED.ED->for_all_episodes( F, reporter, filter);
-}
-
-void
-iExpGloballyDetectArtifacts_activate_cb( GtkMenuItem*, gpointer userdata)
-{
-	auto& ED = *(SExpDesignUI*)userdata;
-
-	if ( ED.global_artifact_detection_profiles.size() < 1 ) {
-		pop_ok_message( ED.wMainWindow,
-				"Create some profiles first",
-				"You can do it by opening a recording in Scoring Facility and"
-				" tweaking default parameters in Artifact Detect dialog."
-				" After saving them as a profile, it will appear here.");
-		return;
-	}
-
-	gtk_label_set_markup(
-		ED.lGlobalADHint,
-		(ED.global_artifact_detection_profiles.size() < 2)
-		? "<small>You can create a custom profile in Scoring Facility,\n"
-		  "after tuning parameters on a real recording.</small>"
-		: ""); // good boy
-
-
-	auto response = gtk_dialog_run( ED.wGlobalArtifactDetection);
-	if ( response == GTK_RESPONSE_CANCEL ||
-	     response == GTK_RESPONSE_DELETE_EVENT )
-		return; // just to save on indents in those lambdas below
-
-	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);
-
-	SBusyBlock bb (ED.wMainWindow);
-
-	using namespace agh;
-	CExpDesign::TRecordingOpFun F;
-	CExpDesign::TRecordingFilterFun filter;
-	CExpDesign::TRecordingReportFun G =
-		[&]( const CJGroup&, const CSubject& J, const string& D, 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:%s", i, total,
-				ED.ED->group_of(J), J.name(), D.c_str(), E.name(), R.F().channel_by_id(R.h()));
-			ED.buf_on_main_status_bar();
-			gtk_flush();
-		};
-	switch ( response ) {
-	case GTK_RESPONSE_OK:
-		F =
-		[&]( CRecording& R)
-		{
-			auto	sr = R.F().samplerate(R.h());
-			auto&	af = R.F().artifacts(R.h());
-
-			auto	signal_original
-				= R.F().get_signal_original(R.h());
-
-			if ( not keep_existing )
-				af.clear_all();
-			auto	marked
-				= metrics::mc::detect_artifacts( signal_original, sr, P);
-			for ( size_t p = 0; p < marked.size(); ++p )
-				af.mark_artifact(
-					marked[p] * P.scope * sr,
-					(marked[p]+1) * P.scope * sr);
-		};
-		filter =
-		[&]( CRecording& R)
-		{
-			return R.signal_type() == sigfile::SChannel::TType::eeg;
-		};
-	    break;
-	case 1: // "Clear All"
-		F =
-		[&]( CRecording& R)
-		{
-			auto& F = R.F();
-			for ( auto& H : R.F().channel_list() ) {
-				auto&	af = F.artifacts(H.c_str());
-				af.clear_all();
-			}
-		};
-		filter =
-		[&]( CRecording&)
-		{
-			return true; // clear in all channels (mark in EEG channels only)
-		};
-	    break;
-	default:
-		throw runtime_error ("Fix AD dialog response?");
-	}
-
-	forward_list<aghui::SBusyBlock*> bbl;
-	for ( auto& SFp : ED.open_scoring_facilities )
-		bbl.push_front( new aghui::SBusyBlock (SFp->wScoringFacility));
-
-	ED.ED -> for_all_recordings( F, G, filter);
-
-	for ( auto& SF : ED.open_scoring_facilities ) {
-		for ( auto& H : SF->channels )
-			if ( H.type == sigfile::SChannel::TType::eeg )
-				H.get_signal_filtered();
-		SF->queue_redraw_all();
-	}
-
-	ED.populate_1();
-
-	for ( auto& bb : bbl )
-		delete bb;
-}
-
-void
-eGlobalADProfiles_changed_cb( GtkComboBox *b, gpointer userdata)
-{
-	auto& ED = *(SExpDesignUI*)userdata;
-
-	gtk_widget_set_sensitive(
-		(GtkWidget*)ED.bGlobalADOK,
-		ED.global_artifact_detection_profiles.size() > 0);
-}
-
-
-
-// iMontageSetDefaults_activate_cb( GtkMenuItem*, gpointer userdata)
-// {
-// 	auto& ED = *(SExpDesignUI*)userdata;
-
-// 	if ( GTK_RESPONSE_OK ==
-// 	     gtk_dialog_run( ED.wMontageDefaults) )
-// 		FAFA;
-// }
-
-
-
-void
-iExpGloballySetFilters_activate_cb( GtkMenuItem*, gpointer userdata)
-{
-	auto& ED = *(SExpDesignUI*)userdata;
-
-	int LPO, HPO, NF;
-	double LPC, HPC;
-	aghui::SUIVarCollection W_V;
-	W_V.reg( ED.eGlobalFiltersLowPassCutoff, &LPC);
-	W_V.reg( ED.eGlobalFiltersLowPassOrder, &LPO);
-	W_V.reg( ED.eGlobalFiltersHighPassCutoff, &HPC);
-	W_V.reg( ED.eGlobalFiltersHighPassOrder, &HPO);
-	W_V.reg( ED.eGlobalFiltersNotchFilter, &NF);
-
-	if ( GTK_RESPONSE_OK ==
-	     gtk_dialog_run( ED.wGlobalFilters) ) {
-		forward_list<aghui::SBusyBlock*> bbl;
-		for ( auto& SFp : ED.open_scoring_facilities )
-			bbl.push_front( new aghui::SBusyBlock (SFp->wScoringFacility));
-		W_V.down();
-		for ( auto &G : ED.ED->groups )
-			for ( auto &J : G.second )
-				for ( auto &D : J.measurements )
-					for ( auto &E : D.second.episodes )
-						for ( auto &F : E.sources )
-							for ( auto &H : F.channel_list() ) {
-								auto& ff = F.filters(H.c_str());
-								ff.low_pass_cutoff = LPC;
-								ff.low_pass_order = LPO;
-								ff.high_pass_cutoff = HPC;
-								ff.high_pass_order = HPO;
-								ff.notch_filter = (sigfile::SFilterPack::TNotchFilter)NF;
-							}
-		ED.ED->sync();
-
-		for ( auto& SF : ED.open_scoring_facilities ) {
-			for ( auto& H : SF->channels )
-				if ( H.type == sigfile::SChannel::TType::eeg )
-					H.get_signal_filtered();
-			SF->queue_redraw_all();
-		}
-		ED.populate_1();
-		for ( auto& bb : bbl )
-			delete bb;
-	}
-}
-
-void
-bGlobalMontageResetAll_clicked_cb( GtkButton*, gpointer userdata)
-{
-	auto& ED = *(SExpDesignUI*)userdata;
-
-	snprintf_buf( "find '%s' -name '.*.montage' -delete",
-		      ED.ED->session_dir().c_str());
-	if ( system( __buf__) )
-		pop_ok_message( ED.wMainWindow, "Command '%s' returned a non-zero status. This is weird.", __buf__);
-}
-
-
-
-void
-iHelpAbout_activate_cb( GtkMenuItem*, gpointer userdata)
-{
-	auto& ED = *(SExpDesignUI*)userdata;
-	gtk_widget_show_all( (GtkWidget*)ED.wAbout);
-}
-
-void
-iHelpUsage_activate_cb( GtkMenuItem*, gpointer)
-{
-//	auto& ED = *(SExpDesignUI*)userdata;
-	gtk_show_uri( NULL,
-		      "http://johnhommer.com/academic/code/aghermann/usage/",
-		      GDK_CURRENT_TIME, NULL);
-}
-
-
-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");
-}
-
-
-
-
-
 // other main toolbar controls
 
 void
@@ -533,46 +228,6 @@ eMsmtChannel_changed_cb( GtkComboBox *combobox, gpointer userdata)
 
 
 
-// annotations dialog
-
-void
-tvGlobalAnnotations_row_activated_cb( GtkTreeView* tree_view,
-				      GtkTreePath* path,
-				      GtkTreeViewColumn *column,
-				      gpointer userdata)
-{
-	auto& ED = *(SExpDesignUI*)userdata;
-	aghui::SExpDesignUI::SAnnotation *ann;
-	GtkTreeIter iter;
-	gtk_tree_model_get_iter( (GtkTreeModel*)ED.mGlobalAnnotations, &iter, path);
-	gtk_tree_model_get( (GtkTreeModel*)ED.mGlobalAnnotations, &iter,
-			    ED.mannotations_ref_col, &ann,
-			    -1);
-	if ( ann == nullptr )
-		return;
-
-	gtk_widget_hide( (GtkWidget*)ED.wGlobalAnnotations);
-	aghui::SScoringFacility* found = nullptr;
-	for ( auto &F : ED.open_scoring_facilities )
-		if ( &F->csubject() == &ann->csubject
-		     && F->session() == ann->session
-		     && &F->sepisode() == &ann->sepisode ) {
-			found = F;
-			break;
-		}
-	if ( found ) {
-		auto pages = ann->page_span( found->vpagesize());
-		gtk_widget_show( (GtkWidget*)found->wScoringFacility);
-		found->set_cur_vpage( pages.a, true);
-	} else {
-		ED.using_subject = ED.subject_presentation_by_csubject( ann->csubject);
-		auto SF = new aghui::SScoringFacility( ann->csubject, ann->session, ann->sepisode.name(), ED);
-		auto pages = ann->page_span( SF->vpagesize());
-		SF->set_cur_vpage( pages.a, true);
-	}
-}
-
-
 
 
 void
diff --git a/src/ui/sf/Makefile.am b/src/ui/sf/Makefile.am
index 004eca7..ee307b2 100644
--- a/src/ui/sf/Makefile.am
+++ b/src/ui/sf/Makefile.am
@@ -8,27 +8,27 @@ AM_CXXFLAGS := \
 noinst_LIBRARIES := liba.a
 
 liba_a_SOURCES := \
-	sf.hh \
-	sf-widgets.hh \
-	sf_cb.hh \
-	sf.cc \
-	sf-construct.cc \
-	sf-channel.cc \
 	sf-artifacts.cc \
 	sf-artifacts_cb.cc \
+	sf-channel.cc \
+	sf-construct.cc \
+	sf-filter.cc \
+	sf-filter_cb.cc \
+	sf-hypnogram.cc \
+	sf-hypnogram_cb.cc \
 	sf-ica.cc \
 	sf-ica_cb.cc \
-	sf_cb.cc \
 	sf-montage.cc \
 	sf-montage_cb.cc \
-	sf-hypnogram.cc \
-	sf-hypnogram_cb.cc \
 	sf-patterns.cc \
 	sf-patterns_cb.cc \
-	sf-filter.cc \
-	sf-filter_cb.cc \
 	sf-phasediff.cc \
-	sf-phasediff_cb.cc
+	sf-phasediff_cb.cc \
+	sf-widgets.hh \
+	sf.cc \
+	sf.hh \
+	sf_cb.cc \
+	sf_cb.hh
 
 if DO_PCH
 BUILT_SOURCES = \
diff --git a/src/ui/sm/Makefile.am b/src/ui/sm/Makefile.am
index b5bcb62..2371aab 100644
--- a/src/ui/sm/Makefile.am
+++ b/src/ui/sm/Makefile.am
@@ -8,8 +8,8 @@ AM_CXXFLAGS := \
 noinst_LIBRARIES := liba.a
 
 liba_a_SOURCES := \
-	sm.cc \
 	sm-construct.cc \
+	sm.cc \
 	sm.hh \
 	sm_cb.cc \
 	sm_cb.hh

-- 
Sleep experiment manager



More information about the debian-med-commit mailing list