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

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


The following commit has been merged in the master branch:
commit c2ac66a2e415944a383147e1deea6b44270c7805
Author: Andrei Zavada <johnhommer at gmail.com>
Date:   Sun Oct 21 01:38:45 2012 +0300

    WIP

diff --git a/data/dialogs.glade.in b/data/dialogs.glade.in
index e80091d..0467e8c 100644
--- a/data/dialogs.glade.in
+++ b/data/dialogs.glade.in
@@ -1613,7 +1613,7 @@ GPL-2+</property>
               <object class="GtkButton" id="button7">
                 <property name="label">gtk-cancel</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_stock">True</property>
               </object>
@@ -1621,13 +1621,28 @@ GPL-2+</property>
                 <property name="expand">False</property>
                 <property name="fill">True</property>
                 <property name="position">0</property>
+                <property name="secondary">True</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="bGlobalADClearAll">
+                <property name="label" translatable="yes">Clea_r all</property>
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="receives_default">True</property>
+                <property name="use_underline">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
               </packing>
             </child>
             <child>
               <object class="GtkButton" id="bGlobalADOK">
                 <property name="label">gtk-ok</property>
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
+                <property name="can_focus">False</property>
                 <property name="can_default">True</property>
                 <property name="has_default">True</property>
                 <property name="receives_default">True</property>
@@ -1636,7 +1651,7 @@ GPL-2+</property>
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">True</property>
-                <property name="position">1</property>
+                <property name="position">2</property>
               </packing>
             </child>
           </object>
@@ -1651,6 +1666,7 @@ GPL-2+</property>
     </child>
     <action-widgets>
       <action-widget response="-6">button7</action-widget>
+      <action-widget response="1">bGlobalADClearAll</action-widget>
       <action-widget response="-5">bGlobalADOK</action-widget>
     </action-widgets>
   </object>
diff --git a/data/sf.glade b/data/sf.glade
index e8d4c71..64a53b6 100644
--- a/data/sf.glade
+++ b/data/sf.glade
@@ -2924,15 +2924,15 @@ on individual parameters:</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkButton" id="bScoreWake">
-                        <property name="label" translatable="yes">☺</property>
+                      <object class="GtkButton" id="bScoreClear">
+                        <property name="label" translatable="yes">⌫</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">True</property>
-                        <property name="tooltip_markup" translatable="yes">Wake (<b>w</b>)</property>
+                        <property name="tooltip_markup" translatable="yes">Clear (<b>q</b>)</property>
                         <property name="valign">center</property>
                         <property name="focus_on_click">False</property>
-                        <accelerator key="w" signal="activate"/>
+                        <accelerator key="q" signal="activate"/>
                       </object>
                       <packing>
                         <property name="expand">False</property>
@@ -2941,15 +2941,15 @@ on individual parameters:</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkButton" id="bScoreClear">
-                        <property name="label" translatable="yes">⌫</property>
+                      <object class="GtkButton" id="bScoreWake">
+                        <property name="label" translatable="yes">☺</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">True</property>
-                        <property name="tooltip_markup" translatable="yes">Clear (<b>q</b>)</property>
+                        <property name="tooltip_markup" translatable="yes">Wake (<b>w</b>)</property>
                         <property name="valign">center</property>
                         <property name="focus_on_click">False</property>
-                        <accelerator key="q" signal="activate"/>
+                        <accelerator key="w" signal="activate"/>
                       </object>
                       <packing>
                         <property name="expand">False</property>
@@ -3184,17 +3184,18 @@ on individual parameters:</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkToggleButton" id="bSFShowPhaseDiffDialog">
-                        <property name="label" translatable="yes">Δφ</property>
+                      <object class="GtkToggleButton" id="bSFShowFindDialog">
+                        <property name="label" translatable="yes">_Find</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">True</property>
                         <property name="has_tooltip">True</property>
-                        <property name="tooltip_markup" translatable="yes">Interchannel signal shift (<b>F4</b>)</property>
-                        <property name="tooltip_text" translatable="yes">Interchannel signal shift (F4)</property>
+                        <property name="tooltip_markup" translatable="yes">Find/manage patterns (<b>F3</b>)</property>
+                        <property name="tooltip_text" translatable="yes">Find/manage patterns (F3)</property>
                         <property name="valign">center</property>
+                        <property name="use_underline">True</property>
                         <property name="focus_on_click">False</property>
-                        <accelerator key="F4" signal="activate"/>
+                        <accelerator key="F3" signal="activate"/>
                       </object>
                       <packing>
                         <property name="expand">False</property>
@@ -3204,18 +3205,17 @@ on individual parameters:</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkToggleButton" id="bSFShowFindDialog">
-                        <property name="label" translatable="yes">_Find</property>
+                      <object class="GtkToggleButton" id="bSFShowPhaseDiffDialog">
+                        <property name="label" translatable="yes">Δφ</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">True</property>
                         <property name="has_tooltip">True</property>
-                        <property name="tooltip_markup" translatable="yes">Find/manage patterns (<b>F3</b>)</property>
-                        <property name="tooltip_text" translatable="yes">Find/manage patterns (F3)</property>
+                        <property name="tooltip_markup" translatable="yes">Interchannel signal shift (<b>F4</b>)</property>
+                        <property name="tooltip_text" translatable="yes">Interchannel signal shift (F4)</property>
                         <property name="valign">center</property>
-                        <property name="use_underline">True</property>
                         <property name="focus_on_click">False</property>
-                        <accelerator key="F3" signal="activate"/>
+                        <accelerator key="F4" signal="activate"/>
                       </object>
                       <packing>
                         <property name="expand">False</property>
@@ -5344,6 +5344,8 @@ skew:	𝑔(𝑢) = 𝑢2</property>
     <widgets>
       <widget name="bSFADProfileSave"/>
       <widget name="bSFADProfileDelete"/>
+      <widget name="bPatternSave"/>
+      <widget name="bPatternDiscard"/>
     </widgets>
   </object>
 </interface>
diff --git a/src/libsigfile/Makefile.am b/src/libsigfile/Makefile.am
index 71a4344..fe01818 100644
--- a/src/libsigfile/Makefile.am
+++ b/src/libsigfile/Makefile.am
@@ -32,7 +32,9 @@ libsigfile_la_SOURCES = \
 	psd.cc \
 	psd.hh \
 	mc.cc \
-	mc.hh
+	mc.hh \
+	artifacts.hh \
+	artifacts.cc
 libsigfile_a_SOURCES = \
 	$(libsigfile_la_SOURCES)
 
@@ -82,7 +84,8 @@ BUILT_SOURCES = \
 	page.hh.gch \
 	page-metrics-base.hh \
 	psd.hh.gch \
-	mc.hh.gch
+	mc.hh.gch \
+	artifacts.hh.gch
 %.hh.gch: %.hh
 	$(CXXCOMPILE) -c $<
 endif
diff --git a/src/libsigfile/artifacts.cc b/src/libsigfile/artifacts.cc
new file mode 100644
index 0000000..d216a77
--- /dev/null
+++ b/src/libsigfile/artifacts.cc
@@ -0,0 +1,91 @@
+// ;-*-C++-*-
+/*
+ *       File name:  libsigfile/artifacts.cc
+ *         Project:  Aghermann
+ *          Author:  Andrei Zavada <johnhommer at gmail.com>
+ *
+ * Initial version:  2012-10-21
+ *
+ *         Purpose:  EEG microcontinuity based functions for artifact detection
+ *
+ *         License:  GPL
+ */
+
+#include <gsl/gsl_histogram.h>
+
+#include "../common/lang.hh"
+#include "../sigproc/sigproc.hh"
+#include "mc.hh"
+#include "artifacts.hh"
+
+#if HAVE_CONFIG_H && !defined(VERSION)
+#  include "config.h"
+#endif
+
+using namespace std;
+
+
+vector<size_t>
+sigfile::
+detect_artifacts( const valarray<TFloat>& signal, size_t sr,
+		  const SArtifactDetectionPP& P)
+{
+	auto	sssu
+		= CBinnedMC::do_sssu_reduction(
+			signal,
+			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
+			? estimate_E(
+				sssu_diff,
+				P.sssu_hist_size,
+				P.dmin, P.dmax)
+			: estimate_E(
+				sssu_diff,
+				P.sssu_hist_size);
+	else
+		E = P.E;
+
+	vector<size_t>
+		marked;
+	for ( size_t p = 0; p < sssu_diff.size(); ++p )
+		if ( sssu_diff[p] < E + E * P.lower_thr ||
+		     sssu_diff[p] > E + E * P.upper_thr ) {
+			marked.push_back(p);
+		}
+
+	return marked;
+}
+
+
+
+
+TFloat
+sigfile::
+estimate_E( const valarray<TFloat>& sssu_diff,
+	    size_t sssu_hist_size,
+	    TFloat dmin, TFloat dmax)
+{
+	gsl_histogram *hist = gsl_histogram_alloc( sssu_hist_size);
+	gsl_histogram_set_ranges_uniform( hist, dmin, dmax);
+
+	for ( size_t i = 0; i < sssu_diff.size(); ++i )
+		gsl_histogram_increment( hist, sssu_diff[i]);
+
+	return dmin + (gsl_histogram_max_bin( hist) + .5)
+		* ((dmax-dmin) / sssu_hist_size);
+}
+
+
+
+
+
+// eof
diff --git a/src/libsigfile/artifacts.hh b/src/libsigfile/artifacts.hh
new file mode 100644
index 0000000..6c890e0
--- /dev/null
+++ b/src/libsigfile/artifacts.hh
@@ -0,0 +1,73 @@
+// ;-*-C++-*-
+/*
+ *       File name:  libsigfile/artifacts.hh
+ *         Project:  Aghermann
+ *          Author:  Andrei Zavada <johnhommer at gmail.com>
+ *
+ * Initial version:  2012-10-21
+ *
+ *         Purpose:  artifacts, mostly MC-based
+ *
+ *         License:  GPL
+ */
+
+#ifndef _SIGFILE_ARTIFACTS_H
+#define _SIGFILE_ARTIFACTS_H
+
+#include <vector>
+#include <valarray>
+#include "forward-decls.hh"
+
+#if HAVE_CONFIG_H && !defined(VERSION)
+#  include "config.h"
+#endif
+
+using namespace std;
+
+namespace sigfile {
+
+struct SArtifactDetectionPP {
+	double	scope,
+		upper_thr, lower_thr,
+		f0, fc, bandwidth,
+		mc_gain, iir_backpolate;
+	double	E, dmin, dmax;
+	size_t	sssu_hist_size,
+		smooth_side;
+	bool	estimate_E,
+		use_range;
+	SArtifactDetectionPP ()
+		: scope (4.),
+		  upper_thr (9.), lower_thr (-9.),
+		  f0 (1.), fc (1.8), bandwidth (1.5),
+		  mc_gain (10.), iir_backpolate (.5),
+		  E (4.), dmin (-10), dmax (20),
+		  sssu_hist_size (100), smooth_side (0),
+		  estimate_E (true), use_range (false)
+		{}
+};
+
+// artifacts (having sssu_diff outside thresholds * E), see paper pp 1190-1)
+vector<size_t> // don't estimate, use pi*B*x^2 (E) as provided
+detect_artifacts( const valarray<TFloat>&, size_t sr,
+		  const SArtifactDetectionPP&);
+TFloat
+estimate_E( const valarray<TFloat>&,
+	    size_t bins,
+	    TFloat dmin, TFloat dmax);
+
+inline TFloat
+estimate_E( const valarray<TFloat>& sssu_diff,
+	    size_t sssu_hist_size)
+{
+	return estimate_E( sssu_diff, sssu_hist_size,
+			   sssu_diff.min(), sssu_diff.max());
+}
+
+
+} // namespace sigfile
+
+
+#endif // _SIGFILE_ARTIFACTS_H
+
+// eof
diff --git a/src/libsigfile/mc.cc b/src/libsigfile/mc.cc
index f464f63..e1345a1 100644
--- a/src/libsigfile/mc.cc
+++ b/src/libsigfile/mc.cc
@@ -11,14 +11,6 @@
  *         License:  GPL
  */
 
-#include <unistd.h>
-#include <limits.h>
-#include <cassert>
-#include <functional>
-#include <stdexcept>
-
-#include <gsl/gsl_histogram.h>
-
 #include "../common/lang.hh"
 #include "mc.hh"
 #include "source.hh"
@@ -196,45 +188,6 @@ compute( const SMCParamSet& req_params,
 
 
 
-vector<size_t>
-sigfile::CBinnedMC::
-detect_artifacts( const valarray<TFloat>& sssu_diff,
-		  float upper_thr, float lower_thr,
-		  TFloat E)
-{
-	vector<size_t>
-		marked;
-	for ( size_t p = 0; p < sssu_diff.size(); ++p )
-		if ( sssu_diff[p] < E + E * lower_thr ||
-		     sssu_diff[p] > E + E * upper_thr ) {
-			marked.push_back(p);
-		}
-
-	return marked;
-}
-
-
-
-
-TFloat
-sigfile::CBinnedMC::
-estimate_E( const valarray<TFloat>& sssu_diff,
-	    size_t sssu_hist_size,
-	    TFloat dmin, TFloat dmax)
-{
-	gsl_histogram *hist = gsl_histogram_alloc( sssu_hist_size);
-	gsl_histogram_set_ranges_uniform( hist, dmin, dmax);
-
-	for ( size_t i = 0; i < sssu_diff.size(); ++i )
-		gsl_histogram_increment( hist, sssu_diff[i]);
-
-	return dmin + (gsl_histogram_max_bin( hist) + .5)
-		* ((dmax-dmin) / sssu_hist_size);
-}
-
-
-
-
 sigfile::CBinnedMC::TSSSU
 sigfile::CBinnedMC::
 do_sssu_reduction( const valarray<TFloat>& signal,
diff --git a/src/libsigfile/mc.hh b/src/libsigfile/mc.hh
index fc3abc0..d3bdfd1 100644
--- a/src/libsigfile/mc.hh
+++ b/src/libsigfile/mc.hh
@@ -67,6 +67,7 @@ struct SMCParamSet {
 
 
 
+
 class CBinnedMC
   : public CPageMetrics_base,
     public SMCParamSet {
@@ -99,24 +100,6 @@ class CBinnedMC
 	int export_tsv( size_t bin,
 			const string& fname) const;
 
-      // other useful functions
-	// artifacts (having sssu_diff outside thresholds * E), see paper pp 1190-1)
-	static vector<size_t> // don't estimate, use pi*B*x^2 (E) as provided
-	detect_artifacts( const valarray<TFloat>& sssu_diff,
-			  float upper_thr, float lower_thr,
-			  TFloat E);
-	static TFloat
-	estimate_E( const valarray<TFloat>&,
-		    size_t bins,
-		    TFloat dmin, TFloat dmax);
-	static TFloat
-	estimate_E( const valarray<TFloat>& sssu_diff,
-		    size_t sssu_hist_size)
-		{
-			return estimate_E( sssu_diff, sssu_hist_size,
-					   sssu_diff.min(), sssu_diff.max());
-		}
-
       // computation stages
 	typedef pair<valarray<TFloat>, valarray<TFloat>> TSSSU;
 
@@ -131,6 +114,8 @@ class CBinnedMC
 };
 
 
+
+
 } // namespace sigfile
 
 
diff --git a/src/sigproc/sigproc.hh b/src/sigproc/sigproc.hh
index 15d0239..bce0de2 100644
--- a/src/sigproc/sigproc.hh
+++ b/src/sigproc/sigproc.hh
@@ -1,6 +1,6 @@
 // ;-*-C++-*-
 /*
- *       File name:  libexstrom/sigproc.hh
+ *       File name:  sigproc/sigproc.hh
  *         Project:  Aghermann
  *          Author:  Andrei Zavada <johnhommer at gmail.com>
  * Initial version:  2011-01-26
diff --git a/src/ui/ed.cc b/src/ui/ed.cc
index 4fa3f4d..9bbe43e 100644
--- a/src/ui/ed.cc
+++ b/src/ui/ed.cc
@@ -186,6 +186,8 @@ SExpDesignUI (aghui::SSessionChooser *parent,
 				  bind( &SExpDesignUI::sb_main_progress_indicator, this,
 					placeholders::_1, placeholders::_2, placeholders::_3));
 	load_artifact_detection_profiles();
+	if ( global_artifact_detection_profiles.empty() )
+		global_artifact_detection_profiles["default"] = sigfile::SArtifactDetectionPP ();
 
 	nodestroy_by_cb = false;
 
@@ -384,7 +386,6 @@ do_purge_computed()
 
 	snprintf_buf( "find '%s' \\( -name '.*.psd' -or -name '.*.mc' \\) -delete",
 		      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__);
 		gtk_statusbar_pop( sbMainStatusBar, sbMainContextIdGeneral);
@@ -395,7 +396,6 @@ do_purge_computed()
 	gtk_statusbar_pop( sbMainStatusBar, sbMainContextIdGeneral);
 	gtk_statusbar_push( sbMainStatusBar, sbMainContextIdGeneral,
 			    "Purged computed files cache");
-	set_wMainWindow_interactive( true);
 }
 
 
diff --git a/src/ui/ed.hh b/src/ui/ed.hh
index 8918573..e021eb5 100644
--- a/src/ui/ed.hh
+++ b/src/ui/ed.hh
@@ -23,6 +23,7 @@
 
 #include "../common/lang.hh"
 #include "../common/config-validate.hh"
+#include "../libsigfile/artifacts.hh"
 #include "../model/forward-decls.hh"
 #include "../expdesign/primaries.hh"
 #include "ui.hh"
@@ -212,27 +213,7 @@ class SExpDesignUI
 		*close_this_SF_now;
 
 	// common artifact detection profiles
-	struct SDetectArtifactsParamPack {
-		double	scope,
-			upper_thr, lower_thr,
-			f0, fc, bandwidth,
-			mc_gain, iir_backpolate;
-		double	E, dmin, dmax;
-		size_t	sssu_hist_size,
-			smooth_side;
-		bool	estimate_E,
-			use_range;
-		SDetectArtifactsParamPack ()
-			: scope (4.),
-			  upper_thr (9.), lower_thr (-9.),
-			  f0 (1.), fc (1.8), bandwidth (1.5),
-			  mc_gain (10.), iir_backpolate (.5),
-			  E (4.), dmin (-10), dmax (20),
-			  sssu_hist_size (100), smooth_side (0),
-			  estimate_E (true), use_range (false)
-			{}
-	};
-	map<string, SDetectArtifactsParamPack>
+	map<string, sigfile::SArtifactDetectionPP>
 		global_artifact_detection_profiles;
 	void load_artifact_detection_profiles();
 	void save_artifact_detection_profiles() const;
diff --git a/src/ui/ed_cb.cc b/src/ui/ed_cb.cc
index 12f5ac1..d3bfd44 100644
--- a/src/ui/ed_cb.cc
+++ b/src/ui/ed_cb.cc
@@ -142,81 +142,75 @@ iExpGloballyDetectArtifacts_activate_cb( GtkMenuItem*, gpointer userdata)
 {
 	auto& ED = *(SExpDesignUI*)userdata;
 
-	if ( GTK_RESPONSE_OK !=
-	     gtk_dialog_run( ED.wGlobalArtifactDetection) )
+	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);
 
-	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());
+	SBusyBlock bb (ED.wMainWindow);
 
-				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);
-			}
-		};
+	using namespace agh;
+	CExpDesign::TRecordingOpFun F;
+	CExpDesign::TRecordingFilterFun filter;
 	CExpDesign::TRecordingReportFun G =
-		[&]( const CJGroup&, const CSubject& J, const string&, const CSubject::SEpisode& E, const CRecording& R,
+		[&]( 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", i, total,
-				ED.ED->group_of(J), J.name(), E.name(), R.F().channel_by_id(R.h()));
+				"(%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_widget_queue_draw( (GtkWidget*)ED.cMeasurements);
-			gdk_window_process_updates(
-				gtk_widget_get_parent_window( (GtkWidget*)ED.cMeasurements),
-				TRUE);
+			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
+				= sigfile::detect_artifacts( signal_original, sr, P);P
+			for ( size_t p = 0; p < marked.size(); ++p )
+				af.mark_artifact(
+					marked[p] * P.scope * sr,
+					(marked[p]+1) * P.scope * sr);
 		};
-	CExpDesign::TRecordingFilterFun filter =
+		filter =
 		[&]( CRecording& R)
 		{
 			return R.signal_type() == sigfile::SChannel::TType::eeg;
 		};
+	    break;
+	case 1:
+		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;
+		};
+	    break;
+	default:
+		throw runtime_error ("Fix AD dialog response?");
+	}
 
 	ED.ED -> for_all_recordings( F, G, filter);
 
@@ -226,6 +220,7 @@ iExpGloballyDetectArtifacts_activate_cb( GtkMenuItem*, gpointer userdata)
 				H.get_signal_filtered();
 		SF->queue_redraw_all();
 	}
+	ED.populate_1();
 }
 
 void
diff --git a/src/ui/sf-artifacts_cb.cc b/src/ui/sf-artifacts_cb.cc
index 51cfcf6..aaef804 100644
--- a/src/ui/sf-artifacts_cb.cc
+++ b/src/ui/sf-artifacts_cb.cc
@@ -200,15 +200,13 @@ gboolean
 wSFArtifactDetection_delete_event_cb(GtkWidget*, GdkEvent*, gpointer userdata)
 {
 	bSFADCancel_clicked_cb( NULL, userdata);
-	FAFA;
-	return FALSE;
+	return TRUE;
 }
 
 void
 wSFArtifactDetection_close_cb(GtkWidget*, gpointer userdata)
 {
 	bSFADCancel_clicked_cb( NULL, userdata);
-	FAFA;
 }
 
 // eof
diff --git a/src/ui/sf.hh b/src/ui/sf.hh
index 97ae746..3e4ccfa 100644
--- a/src/ui/sf.hh
+++ b/src/ui/sf.hh
@@ -105,7 +105,7 @@ class SScoringFacility
 	      // artifacts
 		float calculate_dirty_percent();
 		float	percent_dirty;
-		void detect_artifacts( const SExpDesignUI::SDetectArtifactsParamPack&);
+		void detect_artifacts( const sigfile::SArtifactDetectionPP&);
 
 	      // annotations
 		list<sigfile::SAnnotation*>
@@ -621,7 +621,7 @@ class SScoringFacility
 		SArtifactDetectionDialog (SScoringFacility&);
 	       ~SArtifactDetectionDialog ();
 
-		SExpDesignUI::SDetectArtifactsParamPack
+		sigfile::SArtifactDetectionPP
 			P;
 		sigfile::SArtifacts
 			artifacts_backup;

-- 
Sleep experiment manager



More information about the debian-med-commit mailing list