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

andrei zavada johnhommer at gmail.com
Fri Nov 16 00:50:22 UTC 2012


The following commit has been merged in the master branch:
commit 96ceeef9aefdffbdab8a9af9d748e57f274233fb
Author: andrei zavada <johnhommer at gmail.com>
Date:   Thu Oct 18 19:39:26 2012 +0300

    WIP

diff --git a/src/expdesign/primaries-tree-scanner.cc b/src/expdesign/primaries-tree-scanner.cc
index c4b62eb..9461212 100644
--- a/src/expdesign/primaries-tree-scanner.cc
+++ b/src/expdesign/primaries-tree-scanner.cc
@@ -297,7 +297,7 @@ scan_tree( TMsmtCollectProgressIndicatorFun user_progress_fun)
 	agh::fs::__n_edf_files = 0;
 	nftw( "./", agh::fs::edf_file_counter, 20, 0);
 	printf( "CExpDesign::scan_tree(\"%s\"): %zu edf file(s) found\n",
-		session_dir(), agh::fs::__n_edf_files);
+		session_dir().c_str(), agh::fs::__n_edf_files);
 	if ( agh::fs::__n_edf_files == 0 )
 		return;
 
diff --git a/src/expdesign/primaries.cc b/src/expdesign/primaries.cc
index d6c6f0f..b17611f 100644
--- a/src/expdesign/primaries.cc
+++ b/src/expdesign/primaries.cc
@@ -82,7 +82,7 @@ CExpDesign (const string& session_dir_,
 	if ( fs::exists_and_is_writable( session_dir()) == false )
 		throw invalid_argument (string("Experiment directory ") + _session_dir + " does not exist or is not writable");
 
-	if ( chdir( session_dir()) == -1 )
+	if ( chdir( session_dir().c_str()) == -1 )
 		throw invalid_argument (string("Failed to cd to ") + _session_dir);
 
 	load_settings();
diff --git a/src/expdesign/primaries.hh b/src/expdesign/primaries.hh
index 0501290..51437bb 100644
--- a/src/expdesign/primaries.hh
+++ b/src/expdesign/primaries.hh
@@ -62,7 +62,7 @@ class CSubject {
 
 	sid_type           id() const	{ return _id; }
 	const char      *name() const	{ return _name.c_str(); };
-	const char       *dir() const   { return _dir.c_str(); }
+	const string&     dir() const   { return _dir; }
 
 	CSubject (const string& dir, sid_type id);
        ~CSubject ();
@@ -286,9 +286,9 @@ class CExpDesign {
 			return _status;
 		}
 
-	const char* session_dir() const
+	const string& session_dir() const
 		{
-			return _session_dir.c_str();
+			return _session_dir;
 		}
 
 	string name() const // dirname
diff --git a/src/ui/ed-admit-one.cc b/src/ui/ed-admit-one.cc
index 36c0803..9e0572d 100644
--- a/src/ui/ed-admit-one.cc
+++ b/src/ui/ed-admit-one.cc
@@ -107,7 +107,7 @@ aghui::SExpDesignUI::dnd_maybe_admit_one( const char* fname)
 	{
 		char *dest_path, *dest, *cmd;
 		dest_path = g_strdup_printf( "%s/%s/%s/%s",
-					     ED->session_dir(),
+					     ED->session_dir().c_str(),
 					     selected_group,
 					     F->subject(),
 					     selected_session);
diff --git a/src/ui/ed-measurements_cb.cc b/src/ui/ed-measurements_cb.cc
index 4562245..f3d6164 100644
--- a/src/ui/ed-measurements_cb.cc
+++ b/src/ui/ed-measurements_cb.cc
@@ -191,7 +191,7 @@ iSubjectTimelineSaveAsSVG_activate_cb( GtkMenuItem *checkmenuitem, gpointer user
 	auto J = ED.using_subject;
 
 	snprintf_buf( "%s/%s/%s/%s/%s.svg",
-		      ED.ED->session_dir(), ED.ED->group_of( J->csubject), J->csubject.name(),
+		      ED.ED->session_dir().c_str(), ED.ED->group_of( J->csubject), J->csubject.name(),
 		      ED.AghD(), ED.AghT());
 	string tmp (__buf__);
 	J->is_focused = true;
@@ -209,7 +209,7 @@ iSubjectTimelineBrowse_activate_cb( GtkMenuItem *checkmenuitem, gpointer userdat
 	auto J = ED.using_subject;
 
 	snprintf_buf( "%s '%s/%s/%s/%s' &",
-		      ED.browse_command.c_str(), ED.ED->session_dir(), ED.ED->group_of( J->csubject), J->csubject.name(), ED.AghD());
+		      ED.browse_command.c_str(), ED.ED->session_dir().c_str(), ED.ED->group_of( J->csubject), J->csubject.name(), ED.AghD());
 	if ( system( __buf__) ) {}
 }
 
@@ -221,10 +221,10 @@ iSubjectTimelineResetMontage_activate_cb( GtkMenuItem *checkmenuitem, gpointer u
 
 	if ( not J->is_episode_focused() )
 		snprintf_buf( "find '%s/%s/%s/%s' -name '.*.montage' -delete",
-			      ED.ED->session_dir(), ED.ED->group_of( J->csubject), J->csubject.name(), ED.AghD());
+			      ED.ED->session_dir().c_str(), ED.ED->group_of( J->csubject), J->csubject.name(), ED.AghD());
 	else
 		snprintf_buf( "rm -f '%s/%s/%s/%s/.%s.montage'",
-			      ED.ED->session_dir(), ED.ED->group_of( J->csubject), J->csubject.name(), ED.AghD(), ED.AghE());
+			      ED.ED->session_dir().c_str(), ED.ED->group_of( J->csubject), J->csubject.name(), ED.AghD(), ED.AghE());
 
 	if ( system( __buf__) )
 		pop_ok_message( ED.wMainWindow, "Command '%s' returned a non-zero status. This is weird.", __buf__);
diff --git a/src/ui/ed.cc b/src/ui/ed.cc
index e56e3be..cde1767 100644
--- a/src/ui/ed.cc
+++ b/src/ui/ed.cc
@@ -280,6 +280,7 @@ aghui::SExpDesignUI::
 ~SExpDesignUI ()
 {
 	save_settings();
+	save_artifact_detection_profiles();
 	delete ED;
 }
 
@@ -448,7 +449,7 @@ do_purge_computed()
 	aghui::SBusyBlock bb (wMainWindow);
 
 	snprintf_buf( "find '%s' \\( -name '.*.psd' -or -name '.*.mc' \\) -delete",
-		      ED->session_dir());
+		      ED->session_dir().c_str());
 	set_wMainWindow_interactive( false);
 	if ( system( __buf__) ) {
 		fprintf( stderr, "Command '%s' returned a non-zero status. This is suspicious.\n", __buf__);
@@ -671,9 +672,75 @@ void
 aghui::SExpDesignUI::
 populate_mGlobalADProfiles()
 {
+	load_artifact_detection_profiles();
+	gtk_list_store_clear( mGlobalADProfiles);
+	for ( auto &P : global_artifact_detection_profiles ) {
+		GtkTreeIter iter;
+		gtk_list_store_append( mEEGChannels, &iter);
+		gtk_list_store_set( mEEGChannels, &iter,
+				    0, P.first.c_str(),
+				    -1);
+	}
+}
 
+
+void
+aghui::SExpDesignUI::
+load_artifact_detection_profiles()
+{
+	FILE *domien = fopen( (ED->session_dir() + "/.AD_profiles").c_str(), "r");
+	if ( domien ) {
+		while ( !feof (domien) ) {
+			SDetectArtifactsParamPack P;
+			char *_ = NULL;
+			getline( &_, NULL, domien);
+			fscanf( domien, "%la  %la %la  %la %la %la  %la %la  %la %la %la "
+				"%zu %zu %d %d\n",
+				&P.scope,
+				&P.upper_thr, &P.lower_thr,
+				&P.f0, &P.fc, &P.bandwidth,
+				&P.mc_gain, &P.iir_backpolate,
+				&P.E, &P.dmin, &P.dmax,
+				&P.sssu_hist_size,
+				&P.smooth_side,
+				&P.estimate_E,
+				&P.use_range);
+			global_artifact_detection_profiles[_] = P;
+			free( _);
+		}
+		fclose( domien);
+	} else
+		fprintf( stderr, "failed to open $EXPROOT/.AD_profiles for reading\n");
 }
 
+void
+aghui::SExpDesignUI::
+save_artifact_detection_profiles() const
+{
+	// libconfig::Config conf;
+	// auto&	root = conf.getRoot();
+	// auto&	profiles = root.add("profiles", libconfig::Setting::Type::TypeArray);
+	FILE *domien = fopen( (ED->session_dir() + "/.AD_profiles").c_str(), "w");
+	if ( domien ) {
+		for ( auto &P : global_artifact_detection_profiles ) {
+			fprintf( domien, "%s\n", P.first.c_str());
+			fprintf( domien, "%a  %a %a  %a %a %a  %a %a  %a %a %a "
+				 "%zu %zu %d %d\n",
+				 P.second.scope,
+				 P.second.upper_thr, P.second.lower_thr,
+				 P.second.f0, P.second.fc, P.second.bandwidth,
+				 P.second.mc_gain, P.second.iir_backpolate,
+				 P.second.E, P.second.dmin, P.second.dmax,
+				 P.second.sssu_hist_size,
+				 P.second.smooth_side,
+				 (int)P.second.estimate_E,
+				 (int)P.second.use_range);
+
+		}
+		fclose( domien);
+	} else
+		fprintf( stderr, "failed to open $EXPROOT/.AD_profiles for writing\n");
+}
 
 
 void
@@ -966,7 +1033,7 @@ try_download()
 		      " rm -f \"%s\" && "
 		      " echo \"Sample data set downloaded and unpacked\" && "
 		      " read -p \"Press <Enter> to close this window...\"'",
-		      ED->session_dir(), url, archive_file, archive_file);
+		      ED->session_dir().c_str(), url, archive_file, archive_file);
 	aghui::SBusyBlock bb (wMainWindow);
 
 	if ( system( __buf__) ) {
diff --git a/src/ui/ed.hh b/src/ui/ed.hh
index 6d9130d..d7a389c 100644
--- a/src/ui/ed.hh
+++ b/src/ui/ed.hh
@@ -234,6 +234,8 @@ class SExpDesignUI
 	};
 	map<string, SDetectArtifactsParamPack>
 		global_artifact_detection_profiles;
+	void load_artifact_detection_profiles();
+	void save_artifact_detection_profiles() const;
 
       // own variables aka saved settings
 	sigfile::TMetricType
diff --git a/src/ui/ed_cb.cc b/src/ui/ed_cb.cc
index 201f7ed..5a4f00e 100644
--- a/src/ui/ed_cb.cc
+++ b/src/ui/ed_cb.cc
@@ -192,7 +192,7 @@ iMontageResetAll_activate_cb( GtkMenuItem*, gpointer userdata)
 	auto& ED = *(SExpDesignUI*)userdata;
 
 	snprintf_buf( "find '%s' -name '.*.montage' -delete",
-		      ED.ED->session_dir());
+		      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__);
 }
diff --git a/src/ui/sf-patterns.cc b/src/ui/sf-patterns.cc
index e28e026..a1f106f 100644
--- a/src/ui/sf-patterns.cc
+++ b/src/ui/sf-patterns.cc
@@ -255,7 +255,7 @@ aghui::SScoringFacility::SFindDialog::
 load_pattern( const char *label, bool do_globally)
 {
 	if ( do_globally ) {
-		snprintf_buf( "%s/.patterns/%s", _p._p.ED->session_dir(), label);
+		snprintf_buf( "%s/.patterns/%s", _p._p.ED->session_dir().c_str(), label);
 	} else {
 		string j_dir = _p._p.ED->subject_dir( _p.csubject());
 		snprintf_buf( "%s/.patterns/%s", j_dir.c_str(), label);
@@ -316,10 +316,10 @@ aghui::SScoringFacility::SFindDialog::
 save_pattern( const char *label, bool do_globally)
 {
 	if ( do_globally ) {
-		snprintf_buf( "%s/.patterns", _p._p.ED->session_dir());
+		snprintf_buf( "%s/.patterns", _p._p.ED->session_dir().c_str());
 		if ( mkdir( __buf__, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) )
 			fprintf( stderr, "SScoringFacility::SFindDialog::save_pattern(): mkdir('%s') failed\n", __buf__);
-		snprintf_buf( "%s/.patterns/%s", _p._p.ED->session_dir(), label);
+		snprintf_buf( "%s/.patterns/%s", _p._p.ED->session_dir().c_str(), label);
 	} else {
 		string j_dir = _p._p.ED->subject_dir( _p.csubject());
 		snprintf_buf( "%s/.patterns", j_dir.c_str());
@@ -348,7 +348,7 @@ aghui::SScoringFacility::SFindDialog::
 discard_pattern( const char *label, bool do_globally)
 {
 	if ( do_globally ) {
-		snprintf_buf( "%s/.patterns/%s", _p._p.ED->session_dir(), label);
+		snprintf_buf( "%s/.patterns/%s", _p._p.ED->session_dir().c_str(), label);
 	} else {
 		string j_dir = _p._p.ED->subject_dir( _p.csubject());
 		snprintf_buf( "%s/.patterns/%s", j_dir.c_str(), label);
@@ -433,7 +433,7 @@ enumerate_patterns_to_combo()
 
 	struct dirent **eps;
 	int n;
-	snprintf_buf( "%s/.patterns", _p._p.ED->session_dir());
+	snprintf_buf( "%s/.patterns", _p._p.ED->session_dir().c_str());
 	n = scandir( __buf__, &eps, scandir_filter, alphasort);
 //	printf( "n = %d in %s\n", n, __buf__);
 	if ( n >= 0 ) {

-- 
Sleep experiment manager



More information about the debian-med-commit mailing list