[med-svn] [aghermann] 29/60: unify the three artifact detection algorithms (part 1/2)

andrei zavada hmmr-guest at alioth.debian.org
Mon Nov 4 23:49:56 UTC 2013


This is an automated email from the git hooks/post-receive script.

hmmr-guest pushed a commit to branch WIP
in repository aghermann.

commit e43bb580fb6c5da8e0276b7844b4f5e8960034df
Author: Andrei Zavada <johnhommer at gmail.com>
Date:   Wed Oct 16 01:26:26 2013 +0300

    unify the three artifact detection algorithms (part 1/2)
---
 upstream/data/Makefile.am                          |    4 +-
 upstream/data/aghermann.gresource.xml              |    1 -
 upstream/data/sf-artifacts-simple.glade            |  406 -----
 upstream/data/sf-artifacts.glade                   | 1674 +++++++++++---------
 upstream/data/sf.glade                             |   33 +-
 upstream/src/Makefile.am                           |    8 +-
 upstream/src/aghermann/Makefile.am                 |    5 +-
 upstream/src/aghermann/artifact-detection/3in1.cc  |  175 ++
 upstream/src/aghermann/artifact-detection/3in1.hh  |  148 ++
 upstream/src/aghermann/expdesign/recording.cc      |   19 +-
 upstream/src/aghermann/expdesign/recording.hh      |    7 +
 upstream/src/aghermann/ui/mw/mainmenu_cb.cc        |   73 +-
 upstream/src/aghermann/ui/sf/channel.cc            |   67 +-
 upstream/src/aghermann/ui/sf/channel.hh            |    8 +-
 upstream/src/aghermann/ui/sf/construct.cc          |    2 -
 .../ui/sf/d/artifacts-simple-construct.cc          |   51 -
 upstream/src/aghermann/ui/sf/d/artifacts-simple.cc |   53 -
 upstream/src/aghermann/ui/sf/d/artifacts-simple.hh |   85 -
 upstream/src/aghermann/ui/sf/d/artifacts.cc        |   35 +-
 upstream/src/aghermann/ui/sf/d/artifacts.hh        |   53 +-
 upstream/src/aghermann/ui/sf/montage-menus_cb.cc   |   33 -
 upstream/src/aghermann/ui/sf/sf.cc                 |    1 -
 upstream/src/aghermann/ui/sf/sf.hh                 |    6 -
 upstream/src/aghermann/ui/sf/sf_cb.hh              |    1 -
 upstream/src/aghermann/ui/sf/widgets.hh            |    2 +-
 upstream/src/libmetrics/mc-artifacts.hh            |  102 +-
 upstream/src/libmetrics/page-metrics-base.hh       |    4 +-
 upstream/src/libsigfile/source-base.cc             |    6 +-
 28 files changed, 1453 insertions(+), 1609 deletions(-)

diff --git a/upstream/data/Makefile.am b/upstream/data/Makefile.am
index e82955e..df7a080 100644
--- a/upstream/data/Makefile.am
+++ b/upstream/data/Makefile.am
@@ -17,7 +17,7 @@ EXTRA_DIST := \
 	aghermann.gresource.xml \
 	sm.glade \
 	mw.glade mw-dialogs.glade \
-	sf.glade sf-artifacts.glade sf-artifacts-simple.glade sf-filters.glade sf-patterns.glade sf-phasediff.glade sf-rk1968.glade \
+	sf.glade sf-artifacts.glade sf-filters.glade sf-patterns.glade sf-phasediff.glade sf-rk1968.glade \
 	mf.glade \
 	edfhed.glade \
 	idle-bg.svg equations1.png equation-uc.png \
@@ -30,7 +30,7 @@ CLEANFILES := \
 GRESOURCES := \
 	sm.glade \
 	mw.glade mw-dialogs.glade \
-	sf.glade sf-artifacts.glade sf-artifacts-simple.glade sf-filters.glade sf-patterns.glade sf-phasediff.glade sf-rk1968.glade \
+	sf.glade sf-artifacts.glade sf-filters.glade sf-patterns.glade sf-phasediff.glade sf-rk1968.glade \
 	mf.glade edfhed.glade \
 	aghermann.png equations1.png equation-uc.png \
 	edfhed.glade
diff --git a/upstream/data/aghermann.gresource.xml b/upstream/data/aghermann.gresource.xml
index d32b750..f7a94ff 100644
--- a/upstream/data/aghermann.gresource.xml
+++ b/upstream/data/aghermann.gresource.xml
@@ -10,7 +10,6 @@
     <file compressed="true">mw-dialogs.glade</file>
     <file compressed="true">sf.glade</file>
     <file compressed="true">sf-artifacts.glade</file>
-    <file compressed="true">sf-artifacts-simple.glade</file>
     <file compressed="true">sf-filters.glade</file>
     <file compressed="true">sf-patterns.glade</file>
     <file compressed="true">sf-phasediff.glade</file>
diff --git a/upstream/data/sf-artifacts-simple.glade b/upstream/data/sf-artifacts-simple.glade
deleted file mode 100644
index 7b5d1bf..0000000
--- a/upstream/data/sf-artifacts-simple.glade
+++ /dev/null
@@ -1,406 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<interface>
-  <!-- interface-requires gtk+ 3.0 -->
-  <object class="GtkAdjustment" id="jSFASMinFlatRegionSize">
-    <property name="lower">0.01</property>
-    <property name="upper">10</property>
-    <property name="value">0.5</property>
-    <property name="step_increment">0.01</property>
-    <property name="page_increment">0.10000000000000001</property>
-  </object>
-  <object class="GtkAdjustment" id="jSFASMinSteadyToneFactor">
-    <property name="lower">1</property>
-    <property name="upper">20</property>
-    <property name="value">1.1000000000000001</property>
-    <property name="step_increment">0.10000000000000001</property>
-    <property name="page_increment">0.5</property>
-  </object>
-  <object class="GtkAdjustment" id="jSFASMinSteadyToneRun">
-    <property name="lower">1</property>
-    <property name="upper">9999</property>
-    <property name="value">1</property>
-    <property name="step_increment">1</property>
-    <property name="page_increment">5</property>
-  </object>
-  <object class="GtkAdjustment" id="jSFASPad">
-    <property name="upper">10</property>
-    <property name="value">0.20000000000000001</property>
-    <property name="step_increment">0.01</property>
-    <property name="page_increment">0.10000000000000001</property>
-  </object>
-  <object class="GtkDialog" id="wSFAS">
-    <property name="can_focus">False</property>
-    <property name="border_width">10</property>
-    <property name="title" translatable="yes">Simple artifact detection</property>
-    <property name="modal">True</property>
-    <property name="window_position">mouse</property>
-    <property name="destroy_with_parent">True</property>
-    <property name="icon">aghermann.png</property>
-    <property name="type_hint">dialog</property>
-    <signal name="close" 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-vbox14">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="orientation">vertical</property>
-        <property name="spacing">2</property>
-        <child internal-child="action_area">
-          <object class="GtkButtonBox" id="dialog-action_area14">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="margin_top">10</property>
-            <property name="layout_style">end</property>
-            <child>
-              <object class="GtkButton" id="bFilterCancel1">
-                <property name="label">gtk-cancel</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="bGlobalFiltersOK">
-                <property name="label">gtk-ok</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="has_default">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_stock">True</property>
-                <accelerator key="Return" signal="activate"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="pack_type">end</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkTable" id="table4">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="n_rows">11</property>
-            <property name="n_columns">3</property>
-            <property name="row_spacing">10</property>
-            <child>
-              <object class="GtkLabel" id="label52">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="margin_left">5</property>
-                <property name="xalign">0</property>
-                <property name="label" translatable="yes">sec</property>
-              </object>
-              <packing>
-                <property name="left_attach">2</property>
-                <property name="right_attach">3</property>
-                <property name="top_attach">4</property>
-                <property name="bottom_attach">5</property>
-                <property name="x_options">GTK_FILL</property>
-                <property name="y_options">GTK_FILL</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label53">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="margin_left">5</property>
-                <property name="xalign">0</property>
-                <property name="label" translatable="yes">sec</property>
-              </object>
-              <packing>
-                <property name="left_attach">2</property>
-                <property name="right_attach">3</property>
-                <property name="top_attach">3</property>
-                <property name="bottom_attach">4</property>
-                <property name="x_options">GTK_FILL</property>
-                <property name="y_options">GTK_FILL</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="lSFASLabel">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xalign">0</property>
-                <property name="label" translatable="yes"><b><big>Simple artifact detection</big></b></property>
-                <property name="use_markup">True</property>
-              </object>
-              <packing>
-                <property name="right_attach">3</property>
-                <property name="y_options">GTK_SHRINK</property>
-                <property name="y_padding">4</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkSpinButton" id="eSFASMinFlatRegionSize">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="invisible_char">•</property>
-                <property name="xalign">1</property>
-                <property name="invisible_char_set">True</property>
-                <property name="adjustment">jSFASMinFlatRegionSize</property>
-                <property name="digits">2</property>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="right_attach">2</property>
-                <property name="top_attach">3</property>
-                <property name="bottom_attach">4</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label47">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="margin_right">5</property>
-                <property name="xalign">1</property>
-                <property name="label" translatable="yes">Minimal flat region size:</property>
-                <property name="use_underline">True</property>
-              </object>
-              <packing>
-                <property name="top_attach">3</property>
-                <property name="bottom_attach">4</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label48">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="margin_right">5</property>
-                <property name="xalign">1</property>
-                <property name="label" translatable="yes">Pad:</property>
-                <property name="use_underline">True</property>
-              </object>
-              <packing>
-                <property name="top_attach">4</property>
-                <property name="bottom_attach">5</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkSpinButton" id="eSFASPad">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="invisible_char">•</property>
-                <property name="xalign">1</property>
-                <property name="invisible_char_set">True</property>
-                <property name="adjustment">jSFASPad</property>
-                <property name="digits">2</property>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="right_attach">2</property>
-                <property name="top_attach">4</property>
-                <property name="bottom_attach">5</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label14">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="valign">end</property>
-                <property name="margin_top">5</property>
-                <property name="xalign">0</property>
-                <property name="label" translatable="yes">Flat signal</property>
-                <attributes>
-                  <attribute name="style" value="italic"/>
-                </attributes>
-              </object>
-              <packing>
-                <property name="right_attach">3</property>
-                <property name="top_attach">1</property>
-                <property name="bottom_attach">2</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkSeparator" id="separator1">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-              </object>
-              <packing>
-                <property name="right_attach">3</property>
-                <property name="top_attach">2</property>
-                <property name="bottom_attach">3</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label1">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="valign">end</property>
-                <property name="margin_top">5</property>
-                <property name="xalign">0</property>
-                <property name="label" translatable="yes">Perturbations in EMG</property>
-                <attributes>
-                  <attribute name="style" value="italic"/>
-                </attributes>
-              </object>
-              <packing>
-                <property name="right_attach">3</property>
-                <property name="top_attach">5</property>
-                <property name="bottom_attach">6</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkSeparator" id="separator13">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-              </object>
-              <packing>
-                <property name="right_attach">3</property>
-                <property name="top_attach">6</property>
-                <property name="bottom_attach">7</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkCheckButton" id="eSFASLookAtEMG">
-                <property name="label" translatable="yes">Mark artifacts where EMG is </property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="halign">end</property>
-                <property name="xalign">0</property>
-                <property name="draw_indicator">True</property>
-              </object>
-              <packing>
-                <property name="top_attach">7</property>
-                <property name="bottom_attach">8</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkSpinButton" id="eSFASMinSteadyToneFactor">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="invisible_char">•</property>
-                <property name="xalign">1</property>
-                <property name="adjustment">jSFASMinSteadyToneFactor</property>
-                <property name="digits">2</property>
-                <property name="numeric">True</property>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="right_attach">2</property>
-                <property name="top_attach">7</property>
-                <property name="bottom_attach">8</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label2">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="margin_left">5</property>
-                <property name="xalign">0</property>
-                <property name="label" translatable="yes">times steady tone</property>
-              </object>
-              <packing>
-                <property name="left_attach">2</property>
-                <property name="right_attach">3</property>
-                <property name="top_attach">7</property>
-                <property name="bottom_attach">8</property>
-                <property name="x_options">GTK_FILL</property>
-                <property name="y_options">GTK_FILL</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label3">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="margin_right">5</property>
-                <property name="xalign">1</property>
-                <property name="label" translatable="yes">seen for at least</property>
-                <property name="use_underline">True</property>
-              </object>
-              <packing>
-                <property name="top_attach">8</property>
-                <property name="bottom_attach">9</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkSpinButton" id="eSFASMinSteadyToneRun">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="invisible_char">•</property>
-                <property name="xalign">1</property>
-                <property name="invisible_char_set">True</property>
-                <property name="adjustment">jSFASMinSteadyToneRun</property>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="right_attach">2</property>
-                <property name="top_attach">8</property>
-                <property name="bottom_attach">9</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label4">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="margin_left">5</property>
-                <property name="xalign">0</property>
-                <property name="label" translatable="yes">sec</property>
-              </object>
-              <packing>
-                <property name="left_attach">2</property>
-                <property name="right_attach">3</property>
-                <property name="top_attach">8</property>
-                <property name="bottom_attach">9</property>
-                <property name="x_options">GTK_FILL</property>
-                <property name="y_options">GTK_FILL</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkSeparator" id="separator2">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-              </object>
-              <packing>
-                <property name="right_attach">3</property>
-                <property name="top_attach">9</property>
-                <property name="bottom_attach">10</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkCheckButton" id="eSFASThisChannelOnly">
-                <property name="label" translatable="yes">Apply to this channel only</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="halign">start</property>
-                <property name="xalign">0</property>
-                <property name="draw_indicator">True</property>
-              </object>
-              <packing>
-                <property name="right_attach">3</property>
-                <property name="top_attach">10</property>
-                <property name="bottom_attach">11</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="padding">5</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
-      </object>
-    </child>
-    <action-widgets>
-      <action-widget response="-6">bFilterCancel1</action-widget>
-      <action-widget response="-5">bGlobalFiltersOK</action-widget>
-    </action-widgets>
-  </object>
-</interface>
diff --git a/upstream/data/sf-artifacts.glade b/upstream/data/sf-artifacts.glade
index 4eecbc1..1bddef5 100644
--- a/upstream/data/sf-artifacts.glade
+++ b/upstream/data/sf-artifacts.glade
@@ -1,12 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
-  <object class="GtkAdjustment" id="jSFADBackpolate">
-    <property name="upper">1</property>
-    <property name="value">0.5</property>
-    <property name="step_increment">0.01</property>
-    <property name="page_increment">0.10000000000000001</property>
-  </object>
   <object class="GtkAdjustment" id="jSFADBandwidth">
     <property name="lower">0.5</property>
     <property name="upper">4</property>
@@ -87,6 +81,12 @@
     <property name="step_increment">0.5</property>
     <property name="page_increment">2</property>
   </object>
+  <object class="GtkAdjustment" id="jSFADBackpolate">
+    <property name="upper">1</property>
+    <property name="value">0.5</property>
+    <property name="step_increment">0.01</property>
+    <property name="page_increment">0.10000000000000001</property>
+  </object>
   <object class="GtkDialog" id="wSFAD">
     <property name="can_focus">False</property>
     <property name="border_width">5</property>
@@ -153,301 +153,127 @@
           </packing>
         </child>
         <child>
-          <object class="GtkGrid" id="grid4">
+          <object class="GtkBox" id="box1">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="border_width">10</property>
             <property name="orientation">vertical</property>
-            <property name="row_spacing">5</property>
-            <child>
-              <object class="GtkLabel" id="lSFADInfo">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="margin_top">5</property>
-                <property name="margin_bottom">5</property>
-                <property name="xalign">0</property>
-                <property name="label" translatable="yes">fafa</property>
-                <attributes>
-                  <attribute name="weight" value="bold"/>
-                  <attribute name="scale" value="1.1000000000000001"/>
-                </attributes>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">0</property>
-                <property name="width">3</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkSeparator" id="separator12">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">1</property>
-                <property name="width">7</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label21">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="margin_right">5</property>
-                <property name="xalign">1</property>
-                <property name="label" translatable="yes">Granularity:</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">2</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkSpinButton" id="eSFADScope">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="has_frame">False</property>
-                <property name="invisible_char">•</property>
-                <property name="xalign">1</property>
-                <property name="shadow_type">none</property>
-                <property name="overwrite_mode">True</property>
-                <property name="adjustment">jSFADScope</property>
-                <property name="digits">1</property>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">2</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label22">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="margin_left">5</property>
-                <property name="xalign">0</property>
-                <property name="label" translatable="yes">sec</property>
-              </object>
-              <packing>
-                <property name="left_attach">2</property>
-                <property name="top_attach">2</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkSeparator" id="separator15">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">4</property>
-                <property name="width">3</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label14">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="margin_top">8</property>
-                <property name="xalign">0</property>
-                <property name="label" translatable="yes">Derivation of continuity/noise metrics</property>
-                <attributes>
-                  <attribute name="style" value="italic"/>
-                </attributes>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">3</property>
-                <property name="width">3</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label40">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="margin_top">8</property>
-                <property name="xalign">0</property>
-                <property name="label" translatable="yes">Artifact criteria</property>
-                <attributes>
-                  <attribute name="style" value="italic"/>
-                </attributes>
-              </object>
-              <packing>
-                <property name="left_attach">4</property>
-                <property name="top_attach">3</property>
-                <property name="width">3</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkSeparator" id="separator14">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-              </object>
-              <packing>
-                <property name="left_attach">4</property>
-                <property name="top_attach">4</property>
-                <property name="width">3</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label23">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="margin_right">5</property>
-                <property name="xalign">1</property>
-                <property name="label" translatable="yes">Upper threshold:</property>
-              </object>
-              <packing>
-                <property name="left_attach">4</property>
-                <property name="top_attach">5</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkSpinButton" id="eSFADUpperThr">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="has_frame">False</property>
-                <property name="invisible_char">•</property>
-                <property name="xalign">1</property>
-                <property name="shadow_type">none</property>
-                <property name="overwrite_mode">True</property>
-                <property name="invisible_char_set">True</property>
-                <property name="adjustment">jSFADUpperThr</property>
-                <property name="digits">1</property>
-              </object>
-              <packing>
-                <property name="left_attach">5</property>
-                <property name="top_attach">5</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label25">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="margin_left">5</property>
-                <property name="xalign">0</property>
-              </object>
-              <packing>
-                <property name="left_attach">6</property>
-                <property name="top_attach">5</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label24">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="margin_right">5</property>
-                <property name="xalign">1</property>
-                <property name="label" translatable="yes">Lower threshold:</property>
-              </object>
-              <packing>
-                <property name="left_attach">4</property>
-                <property name="top_attach">6</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkSpinButton" id="eSFADLowerThr">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="has_frame">False</property>
-                <property name="invisible_char">•</property>
-                <property name="xalign">1</property>
-                <property name="shadow_type">none</property>
-                <property name="overwrite_mode">True</property>
-                <property name="invisible_char_set">True</property>
-                <property name="adjustment">jSFADLowerThr</property>
-                <property name="digits">1</property>
-              </object>
-              <packing>
-                <property name="left_attach">5</property>
-                <property name="top_attach">6</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label26">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="margin_left">5</property>
-                <property name="xalign">0</property>
-              </object>
-              <packing>
-                <property name="left_attach">6</property>
-                <property name="top_attach">6</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkCheckButton" id="eSFADEstimateE">
-                <property name="label" translatable="yes">Estimate E</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="xalign">0</property>
-                <property name="draw_indicator">True</property>
-              </object>
-              <packing>
-                <property name="left_attach">5</property>
-                <property name="top_attach">7</property>
-                <property name="width">2</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
             <child>
-              <object class="GtkBox" id="box7">
+              <object class="GtkBox" id="box2">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="orientation">vertical</property>
                 <child>
-                  <object class="GtkGrid" id="cSFADWhenEstimateEOn">
+                  <object class="GtkLabel" id="lSFADInfo">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="margin_top">5</property>
+                    <property name="margin_bottom">5</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">fafa</property>
+                    <attributes>
+                      <attribute name="weight" value="bold"/>
+                      <attribute name="scale" value="1.1000000000000001"/>
+                    </attributes>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkBox" id="cSFADProfileControls">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
+                    <property name="halign">end</property>
+                    <property name="spacing">5</property>
                     <child>
-                      <object class="GtkLabel" id="label35">
+                      <object class="GtkButton" id="bSFADProfileRevert">
+                        <property name="label" translatable="yes">_Revert</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</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">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkComboBox" id="eSFADProfileList">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="margin_right">5</property>
-                        <property name="xalign">1</property>
-                        <property name="label" translatable="yes">Smooth:</property>
                       </object>
                       <packing>
-                        <property name="left_attach">0</property>
-                        <property name="top_attach">0</property>
-                        <property name="width">1</property>
-                        <property name="height">1</property>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkButton" id="bSFADProfileSave">
+                        <property name="label" translatable="yes">Save</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkButton" id="bSFADProfileDiscard">
+                        <property name="label" translatable="yes">Discard</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">True</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">False</property>
+                    <property name="fill">True</property>
+                    <property name="pack_type">end</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkExpander" id="expander1">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <child>
+                  <object class="GtkGrid" id="cSFADMicrocontinuityOptions">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="border_width">10</property>
+                    <property name="orientation">vertical</property>
+                    <property name="row_spacing">5</property>
                     <child>
-                      <object class="GtkSpinButton" id="eSFADSmoothSide">
+                      <object class="GtkSpinButton" id="eSFADScope">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="has_frame">False</property>
                         <property name="invisible_char">•</property>
                         <property name="xalign">1</property>
+                        <property name="shadow_type">none</property>
                         <property name="overwrite_mode">True</property>
-                        <property name="invisible_char_set">True</property>
-                        <property name="adjustment">jSFADSmoothSide</property>
+                        <property name="adjustment">jSFADScope</property>
+                        <property name="digits">1</property>
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
@@ -457,11 +283,12 @@
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkLabel" id="label36">
+                      <object class="GtkLabel" id="label22">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="margin_left">5</property>
                         <property name="xalign">0</property>
+                        <property name="label" translatable="yes">sec</property>
                       </object>
                       <packing>
                         <property name="left_attach">2</property>
@@ -471,593 +298,1004 @@
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkSpinButton" id="eSFADHistRangeMin">
+                      <object class="GtkSeparator" id="separator15">
                         <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="has_frame">False</property>
-                        <property name="invisible_char">•</property>
-                        <property name="xalign">1</property>
-                        <property name="overwrite_mode">True</property>
-                        <property name="invisible_char_set">True</property>
-                        <property name="adjustment">jSFADHistRangeMin</property>
+                        <property name="can_focus">False</property>
                       </object>
                       <packing>
-                        <property name="left_attach">1</property>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">2</property>
+                        <property name="width">3</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label14">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="margin_top">8</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">Derivation of continuity/noise metrics</property>
+                        <attributes>
+                          <attribute name="style" value="italic"/>
+                        </attributes>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
                         <property name="top_attach">1</property>
-                        <property name="width">1</property>
+                        <property name="width">3</property>
                         <property name="height">1</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkSpinButton" id="eSFADHistRangeMax">
+                      <object class="GtkLabel" id="label40">
                         <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="has_frame">False</property>
-                        <property name="invisible_char">•</property>
-                        <property name="xalign">1</property>
-                        <property name="overwrite_mode">True</property>
-                        <property name="invisible_char_set">True</property>
-                        <property name="adjustment">jSFADHistRangeMax</property>
+                        <property name="can_focus">False</property>
+                        <property name="margin_top">8</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">Artifact criteria</property>
+                        <attributes>
+                          <attribute name="style" value="italic"/>
+                        </attributes>
                       </object>
                       <packing>
-                        <property name="left_attach">1</property>
+                        <property name="left_attach">4</property>
+                        <property name="top_attach">1</property>
+                        <property name="width">3</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkSeparator" id="separator14">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">4</property>
                         <property name="top_attach">2</property>
-                        <property name="width">1</property>
+                        <property name="width">3</property>
                         <property name="height">1</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkLabel" id="label38">
+                      <object class="GtkLabel" id="label23">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="margin_right">5</property>
                         <property name="xalign">1</property>
-                        <property name="label" translatable="yes">Histogram bins:</property>
+                        <property name="label" translatable="yes">Upper threshold:</property>
                       </object>
                       <packing>
-                        <property name="left_attach">0</property>
+                        <property name="left_attach">4</property>
                         <property name="top_attach">3</property>
                         <property name="width">1</property>
                         <property name="height">1</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkSpinButton" id="eSFADHistBins">
+                      <object class="GtkSpinButton" id="eSFADUpperThr">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="has_frame">False</property>
                         <property name="invisible_char">•</property>
                         <property name="xalign">1</property>
+                        <property name="shadow_type">none</property>
                         <property name="overwrite_mode">True</property>
                         <property name="invisible_char_set">True</property>
-                        <property name="adjustment">jSFADHistBins</property>
+                        <property name="adjustment">jSFADUpperThr</property>
+                        <property name="digits">1</property>
                       </object>
                       <packing>
-                        <property name="left_attach">1</property>
+                        <property name="left_attach">5</property>
                         <property name="top_attach">3</property>
                         <property name="width">1</property>
                         <property name="height">1</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkLabel" id="label39">
+                      <object class="GtkLabel" id="label25">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="margin_left">5</property>
                         <property name="xalign">0</property>
-                        <property name="label" translatable="yes">to</property>
                       </object>
                       <packing>
-                        <property name="left_attach">2</property>
-                        <property name="top_attach">1</property>
+                        <property name="left_attach">6</property>
+                        <property name="top_attach">3</property>
                         <property name="width">1</property>
                         <property name="height">1</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkRadioButton" id="eSFADUseThisRange">
-                        <property name="label" translatable="yes">Use this range:</property>
+                      <object class="GtkLabel" id="label24">
                         <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">False</property>
-                        <property name="xalign">0</property>
-                        <property name="active">True</property>
-                        <property name="draw_indicator">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="margin_right">5</property>
+                        <property name="xalign">1</property>
+                        <property name="label" translatable="yes">Lower threshold:</property>
                       </object>
                       <packing>
-                        <property name="left_attach">0</property>
-                        <property name="top_attach">1</property>
+                        <property name="left_attach">4</property>
+                        <property name="top_attach">4</property>
                         <property name="width">1</property>
                         <property name="height">1</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkRadioButton" id="eSFADUseComputedRange">
-                        <property name="label" translatable="yes">Compute range</property>
+                      <object class="GtkSpinButton" id="eSFADLowerThr">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
-                        <property name="receives_default">False</property>
-                        <property name="xalign">0</property>
-                        <property name="draw_indicator">True</property>
-                        <property name="group">eSFADUseThisRange</property>
+                        <property name="has_frame">False</property>
+                        <property name="invisible_char">•</property>
+                        <property name="xalign">1</property>
+                        <property name="shadow_type">none</property>
+                        <property name="overwrite_mode">True</property>
+                        <property name="invisible_char_set">True</property>
+                        <property name="adjustment">jSFADLowerThr</property>
+                        <property name="digits">1</property>
                       </object>
                       <packing>
-                        <property name="left_attach">0</property>
-                        <property name="top_attach">2</property>
+                        <property name="left_attach">5</property>
+                        <property name="top_attach">4</property>
                         <property name="width">1</property>
                         <property name="height">1</property>
                       </packing>
                     </child>
                     <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
+                      <object class="GtkLabel" id="label26">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="margin_left">5</property>
+                        <property name="xalign">0</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">6</property>
+                        <property name="top_attach">4</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
                     </child>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkGrid" id="cSFADWhenEstimateEOff">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="no_show_all">True</property>
                     <child>
-                      <object class="GtkSpinButton" id="eSFADEValue">
+                      <object class="GtkCheckButton" id="eSFADEstimateE">
+                        <property name="label" translatable="yes">Estimate E</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
-                        <property name="has_frame">False</property>
-                        <property name="invisible_char">•</property>
-                        <property name="xalign">1</property>
-                        <property name="overwrite_mode">True</property>
-                        <property name="invisible_char_set">True</property>
-                        <property name="adjustment">jSFADEvalue</property>
-                        <property name="digits">2</property>
+                        <property name="receives_default">False</property>
+                        <property name="xalign">0</property>
+                        <property name="draw_indicator">True</property>
                       </object>
                       <packing>
-                        <property name="left_attach">1</property>
-                        <property name="top_attach">0</property>
-                        <property name="width">1</property>
+                        <property name="left_attach">5</property>
+                        <property name="top_attach">5</property>
+                        <property name="width">2</property>
                         <property name="height">1</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkLabel" id="label37">
+                      <object class="GtkBox" id="box7">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="margin_right">5</property>
-                        <property name="xalign">1</property>
-                        <property name="label" translatable="yes">Specify:</property>
+                        <property name="orientation">vertical</property>
+                        <child>
+                          <object class="GtkGrid" id="cSFADWhenEstimateEOn">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <child>
+                              <object class="GtkLabel" id="label35">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="margin_right">5</property>
+                                <property name="xalign">1</property>
+                                <property name="label" translatable="yes">Smooth:</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">0</property>
+                                <property name="top_attach">0</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkSpinButton" id="eSFADSmoothSide">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="has_frame">False</property>
+                                <property name="invisible_char">•</property>
+                                <property name="xalign">1</property>
+                                <property name="overwrite_mode">True</property>
+                                <property name="invisible_char_set">True</property>
+                                <property name="adjustment">jSFADSmoothSide</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="top_attach">0</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkLabel" id="label36">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="margin_left">5</property>
+                                <property name="xalign">0</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">2</property>
+                                <property name="top_attach">0</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkSpinButton" id="eSFADHistRangeMin">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="has_frame">False</property>
+                                <property name="invisible_char">•</property>
+                                <property name="xalign">1</property>
+                                <property name="overwrite_mode">True</property>
+                                <property name="invisible_char_set">True</property>
+                                <property name="adjustment">jSFADHistRangeMin</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="top_attach">1</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkSpinButton" id="eSFADHistRangeMax">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="has_frame">False</property>
+                                <property name="invisible_char">•</property>
+                                <property name="xalign">1</property>
+                                <property name="overwrite_mode">True</property>
+                                <property name="invisible_char_set">True</property>
+                                <property name="adjustment">jSFADHistRangeMax</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="top_attach">2</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkLabel" id="label38">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="margin_right">5</property>
+                                <property name="xalign">1</property>
+                                <property name="label" translatable="yes">Histogram bins:</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">0</property>
+                                <property name="top_attach">3</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkSpinButton" id="eSFADHistBins">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="has_frame">False</property>
+                                <property name="invisible_char">•</property>
+                                <property name="xalign">1</property>
+                                <property name="overwrite_mode">True</property>
+                                <property name="invisible_char_set">True</property>
+                                <property name="adjustment">jSFADHistBins</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="top_attach">3</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkLabel" id="label39">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="margin_left">5</property>
+                                <property name="xalign">0</property>
+                                <property name="label" translatable="yes">to</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">2</property>
+                                <property name="top_attach">1</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkRadioButton" id="eSFADUseThisRange">
+                                <property name="label" translatable="yes">Use this range:</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="xalign">0</property>
+                                <property name="active">True</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">0</property>
+                                <property name="top_attach">1</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkRadioButton" id="eSFADUseComputedRange">
+                                <property name="label" translatable="yes">Compute range</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="xalign">0</property>
+                                <property name="draw_indicator">True</property>
+                                <property name="group">eSFADUseThisRange</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">0</property>
+                                <property name="top_attach">2</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkGrid" id="cSFADWhenEstimateEOff">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="no_show_all">True</property>
+                            <child>
+                              <object class="GtkSpinButton" id="eSFADEValue">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="has_frame">False</property>
+                                <property name="invisible_char">•</property>
+                                <property name="xalign">1</property>
+                                <property name="overwrite_mode">True</property>
+                                <property name="invisible_char_set">True</property>
+                                <property name="adjustment">jSFADEvalue</property>
+                                <property name="digits">2</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="top_attach">0</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkLabel" id="label37">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="margin_right">5</property>
+                                <property name="xalign">1</property>
+                                <property name="label" translatable="yes">Specify:</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">0</property>
+                                <property name="top_attach">0</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkLabel" id="label41">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="margin_left">5</property>
+                                <property name="xalign">0</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">2</property>
+                                <property name="top_attach">0</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="left_attach">4</property>
+                        <property name="top_attach">6</property>
+                        <property name="width">3</property>
+                        <property name="height">4</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkTable" id="table3">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="valign">start</property>
+                        <property name="n_rows">5</property>
+                        <property name="n_columns">3</property>
+                        <property name="row_spacing">10</property>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <object class="GtkLabel" id="label33">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="margin_right">5</property>
+                            <property name="xalign">1</property>
+                            <property name="label" translatable="yes">MC Gain:</property>
+                          </object>
+                          <packing>
+                            <property name="top_attach">3</property>
+                            <property name="bottom_attach">4</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkSpinButton" id="eSFADMCGain">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="has_frame">False</property>
+                            <property name="invisible_char">•</property>
+                            <property name="xalign">1</property>
+                            <property name="shadow_type">none</property>
+                            <property name="overwrite_mode">True</property>
+                            <property name="invisible_char_set">True</property>
+                            <property name="adjustment">jSFADMCGain</property>
+                            <property name="digits">1</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">1</property>
+                            <property name="right_attach">2</property>
+                            <property name="top_attach">3</property>
+                            <property name="bottom_attach">4</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkLabel" id="label28">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="margin_right">5</property>
+                            <property name="xalign">1</property>
+                            <property name="label" translatable="yes">F<sub>0</sub>:</property>
+                            <property name="use_markup">True</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkSpinButton" id="eSFADF0">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="has_frame">False</property>
+                            <property name="invisible_char">•</property>
+                            <property name="xalign">1</property>
+                            <property name="shadow_type">none</property>
+                            <property name="overwrite_mode">True</property>
+                            <property name="invisible_char_set">True</property>
+                            <property name="adjustment">jSFADF0</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="label27">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="margin_left">5</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes">Hz</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">2</property>
+                            <property name="right_attach">3</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkLabel" id="label29">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="margin_right">5</property>
+                            <property name="xalign">1</property>
+                            <property name="label" translatable="yes">F<sub>cutoff</sub>:</property>
+                            <property name="use_markup">True</property>
+                          </object>
+                          <packing>
+                            <property name="top_attach">1</property>
+                            <property name="bottom_attach">2</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkSpinButton" id="eSFADFc">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="has_frame">False</property>
+                            <property name="invisible_char">•</property>
+                            <property name="xalign">1</property>
+                            <property name="shadow_type">none</property>
+                            <property name="overwrite_mode">True</property>
+                            <property name="invisible_char_set">True</property>
+                            <property name="adjustment">jSFADFc</property>
+                            <property name="digits">2</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">1</property>
+                            <property name="right_attach">2</property>
+                            <property name="top_attach">1</property>
+                            <property name="bottom_attach">2</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkLabel" id="label30">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="margin_right">5</property>
+                            <property name="xalign">1</property>
+                            <property name="label" translatable="yes">Bandwidth:</property>
+                          </object>
+                          <packing>
+                            <property name="top_attach">2</property>
+                            <property name="bottom_attach">3</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkLabel" id="label32">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="margin_left">5</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes">Hz</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">2</property>
+                            <property name="right_attach">3</property>
+                            <property name="top_attach">2</property>
+                            <property name="bottom_attach">3</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkLabel" id="label31">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="margin_left">5</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes">Hz</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">2</property>
+                            <property name="right_attach">3</property>
+                            <property name="top_attach">1</property>
+                            <property name="bottom_attach">2</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkSpinButton" id="eSFADBandwidth">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="has_frame">False</property>
+                            <property name="invisible_char">•</property>
+                            <property name="xalign">1</property>
+                            <property name="shadow_type">none</property>
+                            <property name="overwrite_mode">True</property>
+                            <property name="invisible_char_set">True</property>
+                            <property name="adjustment">jSFADBandwidth</property>
+                            <property name="digits">2</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">1</property>
+                            <property name="right_attach">2</property>
+                            <property name="top_attach">2</property>
+                            <property name="bottom_attach">3</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkLabel" id="label34">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="margin_right">5</property>
+                            <property name="xalign">1</property>
+                            <property name="label" translatable="yes">Back-polate factor:</property>
+                          </object>
+                          <packing>
+                            <property name="top_attach">4</property>
+                            <property name="bottom_attach">5</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkSpinButton" id="eSFADBackpolate">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="has_frame">False</property>
+                            <property name="invisible_char">•</property>
+                            <property name="xalign">1</property>
+                            <property name="shadow_type">none</property>
+                            <property name="overwrite_mode">True</property>
+                            <property name="invisible_char_set">True</property>
+                            <property name="adjustment">jSFADBackpolate</property>
+                            <property name="digits">2</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">1</property>
+                            <property name="right_attach">2</property>
+                            <property name="top_attach">4</property>
+                            <property name="bottom_attach">5</property>
+                          </packing>
+                        </child>
                       </object>
                       <packing>
                         <property name="left_attach">0</property>
-                        <property name="top_attach">0</property>
-                        <property name="width">1</property>
-                        <property name="height">1</property>
+                        <property name="top_attach">3</property>
+                        <property name="width">3</property>
+                        <property name="height">7</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkLabel" id="label41">
+                      <object class="GtkSeparator" id="separator16">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="margin_left">5</property>
+                        <property name="margin_left">10</property>
+                        <property name="margin_right">10</property>
+                        <property name="orientation">vertical</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">3</property>
+                        <property name="top_attach">1</property>
+                        <property name="width">1</property>
+                        <property name="height">9</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <object class="GtkCheckButton" id="eSFADMCBasedConsider">
+                        <property name="label" translatable="yes">Inspect every </property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="halign">end</property>
                         <property name="xalign">0</property>
+                        <property name="draw_indicator">True</property>
                       </object>
                       <packing>
-                        <property name="left_attach">2</property>
+                        <property name="left_attach">0</property>
                         <property name="top_attach">0</property>
                         <property name="width">1</property>
                         <property name="height">1</property>
                       </packing>
                     </child>
                   </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">1</property>
-                  </packing>
+                </child>
+                <child type="label">
+                  <object class="GtkLabel" id="label1">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes">_1. Microcontinuity-based</property>
+                    <property name="use_underline">True</property>
+                    <attributes>
+                      <attribute name="style" value="italic"/>
+                    </attributes>
+                  </object>
                 </child>
               </object>
               <packing>
-                <property name="left_attach">4</property>
-                <property name="top_attach">8</property>
-                <property name="width">3</property>
-                <property name="height">4</property>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
               </packing>
             </child>
             <child>
-              <object class="GtkTable" id="table3">
+              <object class="GtkExpander" id="expander2">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="valign">start</property>
-                <property name="n_rows">5</property>
-                <property name="n_columns">3</property>
-                <property name="row_spacing">10</property>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="label33">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="margin_right">5</property>
-                    <property name="xalign">1</property>
-                    <property name="label" translatable="yes">MC Gain:</property>
-                  </object>
-                  <packing>
-                    <property name="top_attach">3</property>
-                    <property name="bottom_attach">4</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkSpinButton" id="eSFADMCGain">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="has_frame">False</property>
-                    <property name="invisible_char">•</property>
-                    <property name="xalign">1</property>
-                    <property name="shadow_type">none</property>
-                    <property name="overwrite_mode">True</property>
-                    <property name="invisible_char_set">True</property>
-                    <property name="adjustment">jSFADMCGain</property>
-                    <property name="digits">1</property>
-                  </object>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="top_attach">3</property>
-                    <property name="bottom_attach">4</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="label28">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="margin_right">5</property>
-                    <property name="xalign">1</property>
-                    <property name="label" translatable="yes">F<sub>0</sub>:</property>
-                    <property name="use_markup">True</property>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkSpinButton" id="eSFADF0">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="has_frame">False</property>
-                    <property name="invisible_char">•</property>
-                    <property name="xalign">1</property>
-                    <property name="shadow_type">none</property>
-                    <property name="overwrite_mode">True</property>
-                    <property name="invisible_char_set">True</property>
-                    <property name="adjustment">jSFADF0</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="label27">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="margin_left">5</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes">Hz</property>
-                  </object>
-                  <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="label29">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="margin_right">5</property>
-                    <property name="xalign">1</property>
-                    <property name="label" translatable="yes">F<sub>cutoff</sub>:</property>
-                    <property name="use_markup">True</property>
-                  </object>
-                  <packing>
-                    <property name="top_attach">1</property>
-                    <property name="bottom_attach">2</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkSpinButton" id="eSFADFc">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="has_frame">False</property>
-                    <property name="invisible_char">•</property>
-                    <property name="xalign">1</property>
-                    <property name="shadow_type">none</property>
-                    <property name="overwrite_mode">True</property>
-                    <property name="invisible_char_set">True</property>
-                    <property name="adjustment">jSFADFc</property>
-                    <property name="digits">2</property>
-                  </object>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="top_attach">1</property>
-                    <property name="bottom_attach">2</property>
-                  </packing>
-                </child>
+                <property name="can_focus">True</property>
+                <property name="use_underline">True</property>
                 <child>
-                  <object class="GtkLabel" id="label30">
+                  <object class="GtkTable" id="table4">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="margin_right">5</property>
-                    <property name="xalign">1</property>
-                    <property name="label" translatable="yes">Bandwidth:</property>
+                    <property name="n_rows">2</property>
+                    <property name="n_columns">3</property>
+                    <property name="row_spacing">10</property>
+                    <child>
+                      <object class="GtkLabel" id="label52">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="margin_left">5</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">sec</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">2</property>
+                        <property name="right_attach">3</property>
+                        <property name="top_attach">1</property>
+                        <property name="bottom_attach">2</property>
+                        <property name="x_options">GTK_FILL</property>
+                        <property name="y_options">GTK_FILL</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label53">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="margin_left">5</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">sec</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">2</property>
+                        <property name="right_attach">3</property>
+                        <property name="x_options">GTK_FILL</property>
+                        <property name="y_options">GTK_FILL</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkSpinButton" id="eSFADFlatMinRegionSize">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="invisible_char">•</property>
+                        <property name="xalign">1</property>
+                        <property name="invisible_char_set">True</property>
+                        <property name="adjustment"/>
+                        <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="label48">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="margin_right">5</property>
+                        <property name="xalign">1</property>
+                        <property name="label" translatable="yes">Pad:</property>
+                        <property name="use_underline">True</property>
+                      </object>
+                      <packing>
+                        <property name="top_attach">1</property>
+                        <property name="bottom_attach">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkSpinButton" id="eSFADFlatPad">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="invisible_char">•</property>
+                        <property name="xalign">1</property>
+                        <property name="invisible_char_set">True</property>
+                        <property name="adjustment"/>
+                        <property name="digits">2</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
+                        <property name="top_attach">1</property>
+                        <property name="bottom_attach">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkCheckButton" id="eSFADFlatConsider">
+                        <property name="label" translatable="yes">Consider flat regions at least </property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="halign">end</property>
+                        <property name="xalign">0</property>
+                        <property name="draw_indicator">True</property>
+                      </object>
+                    </child>
                   </object>
-                  <packing>
-                    <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
-                  </packing>
                 </child>
-                <child>
-                  <object class="GtkLabel" id="label32">
+                <child type="label">
+                  <object class="GtkLabel" id="label2">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="margin_left">5</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes">Hz</property>
+                    <property name="label" translatable="yes">_2. Flat regions</property>
+                    <property name="use_underline">True</property>
+                    <attributes>
+                      <attribute name="style" value="italic"/>
+                    </attributes>
                   </object>
-                  <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
-                    <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
-                  </packing>
                 </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="padding">5</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkExpander" id="expander3">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
                 <child>
-                  <object class="GtkLabel" id="label31">
+                  <object class="GtkTable" id="table2">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="margin_left">5</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes">Hz</property>
-                  </object>
-                  <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
-                    <property name="top_attach">1</property>
-                    <property name="bottom_attach">2</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkSpinButton" id="eSFADBandwidth">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="has_frame">False</property>
-                    <property name="invisible_char">•</property>
-                    <property name="xalign">1</property>
-                    <property name="shadow_type">none</property>
-                    <property name="overwrite_mode">True</property>
-                    <property name="invisible_char_set">True</property>
-                    <property name="adjustment">jSFADBandwidth</property>
-                    <property name="digits">2</property>
+                    <property name="n_rows">2</property>
+                    <property name="n_columns">3</property>
+                    <property name="row_spacing">10</property>
+                    <child>
+                      <object class="GtkCheckButton" id="eSFADEMGConsider">
+                        <property name="label" translatable="yes">Mark artifacts where EMG is </property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="halign">end</property>
+                        <property name="xalign">0</property>
+                        <property name="draw_indicator">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkSpinButton" id="eSFADEMGMinSteadyToneFactor">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="invisible_char">•</property>
+                        <property name="xalign">1</property>
+                        <property name="invisible_char_set">True</property>
+                        <property name="adjustment"/>
+                        <property name="digits">2</property>
+                        <property name="numeric">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label10">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="margin_left">5</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">times steady tone</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">2</property>
+                        <property name="right_attach">3</property>
+                        <property name="x_options">GTK_FILL</property>
+                        <property name="y_options">GTK_FILL</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label11">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="margin_right">5</property>
+                        <property name="xalign">1</property>
+                        <property name="label" translatable="yes">seen for at least</property>
+                        <property name="use_underline">True</property>
+                      </object>
+                      <packing>
+                        <property name="top_attach">1</property>
+                        <property name="bottom_attach">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkSpinButton" id="eSFADEMGMinSteadyToneRun">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="invisible_char">•</property>
+                        <property name="xalign">1</property>
+                        <property name="invisible_char_set">True</property>
+                        <property name="adjustment"/>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
+                        <property name="top_attach">1</property>
+                        <property name="bottom_attach">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label12">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="margin_left">5</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">sec</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">2</property>
+                        <property name="right_attach">3</property>
+                        <property name="top_attach">1</property>
+                        <property name="bottom_attach">2</property>
+                        <property name="x_options">GTK_FILL</property>
+                        <property name="y_options">GTK_FILL</property>
+                      </packing>
+                    </child>
                   </object>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
-                  </packing>
                 </child>
-                <child>
-                  <object class="GtkLabel" id="label34">
+                <child type="label">
+                  <object class="GtkLabel" id="label4">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="margin_right">5</property>
-                    <property name="xalign">1</property>
-                    <property name="label" translatable="yes">Back-polate factor:</property>
-                  </object>
-                  <packing>
-                    <property name="top_attach">4</property>
-                    <property name="bottom_attach">5</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkSpinButton" id="eSFADBackpolate">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="has_frame">False</property>
-                    <property name="invisible_char">•</property>
-                    <property name="xalign">1</property>
-                    <property name="shadow_type">none</property>
-                    <property name="overwrite_mode">True</property>
-                    <property name="invisible_char_set">True</property>
-                    <property name="adjustment">jSFADBackpolate</property>
-                    <property name="digits">2</property>
+                    <property name="label" translatable="yes">_3. EMG perturbations</property>
+                    <property name="use_underline">True</property>
+                    <attributes>
+                      <attribute name="style" value="italic"/>
+                    </attributes>
                   </object>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="top_attach">4</property>
-                    <property name="bottom_attach">5</property>
-                  </packing>
                 </child>
               </object>
               <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">5</property>
-                <property name="width">3</property>
-                <property name="height">7</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkSeparator" id="separator20">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="margin_top">5</property>
-                <property name="margin_bottom">5</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">14</property>
-                <property name="width">7</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkCheckButton" id="eSFADSingleChannelPreview">
-                <property name="label" translatable="yes">Hide other channels in preview</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="xalign">0</property>
-                <property name="active">True</property>
-                <property name="draw_indicator">True</property>
-              </object>
-              <packing>
-                <property name="left_attach">4</property>
-                <property name="top_attach">13</property>
-                <property name="width">3</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkSeparator" id="separator2">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">12</property>
-                <property name="width">7</property>
-                <property name="height">1</property>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="padding">5</property>
+                <property name="position">3</property>
               </packing>
             </child>
             <child>
-              <object class="GtkBox" id="box8">
+              <object class="GtkTable" id="table1">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="halign">end</property>
-                <property name="spacing">5</property>
+                <property name="n_columns">2</property>
                 <child>
-                  <object class="GtkButton" id="bSFADProfileRevert">
-                    <property name="label" translatable="yes">_Revert</property>
+                  <object class="GtkCheckButton" id="eSFADSingleChannelPreview">
+                    <property name="label" translatable="yes">Hide other channels in preview</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="use_underline">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="xalign">0</property>
+                    <property name="active">True</property>
+                    <property name="draw_indicator">True</property>
                   </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">0</property>
-                  </packing>
                 </child>
                 <child>
-                  <object class="GtkComboBox" id="eSFADProfileList">
+                  <object class="GtkLabel" id="lSFADDirtyPercent">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
+                    <property name="yalign">1</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="bSFADProfileSave">
-                    <property name="label" translatable="yes">Save</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">2</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkButton" id="bSFADProfileDiscard">
-                    <property name="label" translatable="yes">Discard</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">3</property>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
                   </packing>
                 </child>
               </object>
               <packing>
-                <property name="left_attach">4</property>
-                <property name="top_attach">0</property>
-                <property name="width">3</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="lSFADDirtyPercent">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xalign">0</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">13</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkSeparator" id="separator16">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="margin_left">10</property>
-                <property name="margin_right">10</property>
-                <property name="orientation">vertical</property>
-              </object>
-              <packing>
-                <property name="left_attach">3</property>
-                <property name="top_attach">3</property>
-                <property name="width">1</property>
-                <property name="height">9</property>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">4</property>
               </packing>
             </child>
-            <child>
-              <placeholder/>
-            </child>
-            <child>
-              <placeholder/>
-            </child>
-            <child>
-              <placeholder/>
-            </child>
-            <child>
-              <placeholder/>
-            </child>
-            <child>
-              <placeholder/>
-            </child>
-            <child>
-              <placeholder/>
-            </child>
-            <child>
-              <placeholder/>
-            </child>
-            <child>
-              <placeholder/>
-            </child>
-            <child>
-              <placeholder/>
-            </child>
           </object>
           <packing>
             <property name="expand">False</property>
diff --git a/upstream/data/sf.glade b/upstream/data/sf.glade
index ad640db..1232dd8 100644
--- a/upstream/data/sf.glade
+++ b/upstream/data/sf.glade
@@ -342,15 +342,6 @@
               </object>
             </child>
             <child>
-              <object class="GtkMenuItem" id="iSFPageSimpleArtifacts">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="tooltip_markup" translatable="yes">Mark artifacts where signal is flat or EMG levels are high</property>
-                <property name="label" translatable="yes">_Simple artifact detection...</property>
-                <property name="use_underline">True</property>
-              </object>
-            </child>
-            <child>
               <object class="GtkMenuItem" id="iSFPageArtifactsClear">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
@@ -1483,6 +1474,18 @@
                       </packing>
                     </child>
                     <child>
+                      <object class="GtkSeparator" id="separator6">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="orientation">vertical</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">9</property>
+                      </packing>
+                    </child>
+                    <child>
                       <object class="GtkTable" id="cSFSleepStageStats">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
@@ -1615,18 +1618,6 @@
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkSeparator" id="separator6">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="orientation">vertical</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">9</property>
-                      </packing>
-                    </child>
-                    <child>
                       <object class="GtkSeparator" id="separator4">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
diff --git a/upstream/src/Makefile.am b/upstream/src/Makefile.am
index a1c0719..b49f04a 100644
--- a/upstream/src/Makefile.am
+++ b/upstream/src/Makefile.am
@@ -43,13 +43,14 @@ BUILT_SOURCES = \
 	libmetrics/all.hh.gch \
 	libmetrics/page-metrics-base.hh.gch \
 	libmetrics/bands.hh.gch \
-	aghermann/model/achermann-tunable.hh.gch \
-	aghermann/model/achermann.hh.gch \
-	aghermann/model/beersma.hh.gch \
+	aghermann/artifact-detection/3in1.hh.gch \
 	aghermann/expdesign/subject.hh.gch \
 	aghermann/expdesign/recording.hh.gch \
 	aghermann/expdesign/profile.hh.gch \
 	aghermann/expdesign/expdesign.hh.gch \
+	aghermann/model/achermann-tunable.hh.gch \
+	aghermann/model/achermann.hh.gch \
+	aghermann/model/beersma.hh.gch \
 	aghermann/rk1968/rk1968.hh.gch \
 	aghermann/globals.hh.gch \
 	aghermann/patterns/patterns.hh.gch \
@@ -58,7 +59,6 @@ BUILT_SOURCES = \
 	aghermann/ui/mf/mf_cb.hh.gch \
 	aghermann/ui/ui.hh.gch \
 	aghermann/ui/misc.hh.gch \
-	aghermann/ui/sf/d/artifacts-simple.hh.gch \
 	aghermann/ui/sf/d/filters.hh.gch \
 	aghermann/ui/sf/d/artifacts.hh.gch \
 	aghermann/ui/sf/d/patterns.hh.gch \
diff --git a/upstream/src/aghermann/Makefile.am b/upstream/src/aghermann/Makefile.am
index e68d3a7..2aa3af9 100644
--- a/upstream/src/aghermann/Makefile.am
+++ b/upstream/src/aghermann/Makefile.am
@@ -9,6 +9,8 @@ AM_CXXFLAGS := \
 bin_PROGRAMS := aghermann
 
 aghermann_SOURCES := \
+	artifact-detection/3in1.cc \
+	artifact-detection/3in1.hh \
 	expdesign/forward-decls.hh \
 	expdesign/dirlevel.cc \
 	expdesign/dirlevel.hh \
@@ -83,9 +85,6 @@ aghermann_SOURCES := \
 	ui/sf/d/artifacts.cc \
 	ui/sf/d/artifacts-profiles_cb.cc \
 	ui/sf/d/artifacts_cb.cc \
-	ui/sf/d/artifacts-simple.hh \
-	ui/sf/d/artifacts-simple.cc \
-	ui/sf/d/artifacts-simple-construct.cc \
 	ui/sf/d/filters.hh \
 	ui/sf/d/filters.cc \
 	ui/sf/d/filters-construct.cc \
diff --git a/upstream/src/aghermann/artifact-detection/3in1.cc b/upstream/src/aghermann/artifact-detection/3in1.cc
new file mode 100644
index 0000000..d2ee889
--- /dev/null
+++ b/upstream/src/aghermann/artifact-detection/3in1.cc
@@ -0,0 +1,175 @@
+/*
+ *       File name:  aghermann/artifact-detection/3in1.cc
+ *         Project:  Aghermann
+ *          Author:  Andrei Zavada <johnhommer at gmail.com>
+ * Initial version:  2013-10-14
+ *
+ *         Purpose:  Comprehensive artifact detection
+ *
+ *         License:  GPL
+ */
+
+#include "3in1.hh"
+#include "common/lang.hh"
+#include "aghermann/globals.hh"
+#include "aghermann/expdesign/subject.hh"
+#include "aghermann/expdesign/recording.hh"
+
+using namespace std;
+using namespace agh::ad;
+
+
+CComprehensiveArtifactDetector::
+CComprehensiveArtifactDetector (const string& name_, agh::TExpDirLevel level_, agh::CExpDesign& ED_, const agh::SExpDirLevelId& level_id_)
+      : CStorablePPack (common_subdir, name_, level_, ED_, level_id_)
+{
+        using agh::confval::SValidator;
+        config
+                ("do_flat_regions",           &Pp.do_flat_regions)
+                ("do_emg_perturbations",      &Pp.do_emg_perturbations)
+                ("do_mc_based",               &Pp.do_mc_based)
+                ("flat.min_size",             &Pp.flat_min_size,             SValidator<double>::SVFRangeIn (.01, 100.))
+                ("flat.pad",                  &Pp.flat_pad,                  SValidator<double>::SVFRangeIn (0., 100.))
+                ("EMG.min_steadytone_factor", &Pp.emg_min_steadytone_factor, SValidator<double>::SVFRangeEx (1., 50.))
+                ("EMG.min_steadytone_run",    &Pp.emg_min_steadytone_run,    SValidator<double>::SVFRangeIn (0., 60.))
+                ("MC.scope",                  &Pp.MC.scope,                  SValidator<double>::SVFRangeIn (0.5, 60.))
+                ("MC.upper_thr",              &Pp.MC.upper_thr,              SValidator<double>::SVFRangeIn (0., 100.))
+                ("MC.lower_thr",              &Pp.MC.lower_thr,              SValidator<double>::SVFRangeIn (-100., 0.))
+                ("MC.f0",                     &Pp.MC.f0,                     SValidator<double>::SVFRangeIn (.1, 80.))
+                ("MC.fc",                     &Pp.MC.fc,                     SValidator<double>::SVFRangeIn (.1, 80.))
+                ("MC.bandwidth",              &Pp.MC.bandwidth,              SValidator<double>::SVFRangeIn (.1, 40.))
+                ("MC.mc_gain",                &Pp.MC.mc_gain,                SValidator<double>::SVFRangeIn (0., 100.))
+                ("MC.iir_backpolate",         &Pp.MC.iir_backpolate,         SValidator<double>::SVFRangeIn (0., 1.))
+                ("MC.E",                      &Pp.MC.E,                      SValidator<double>::SVFRangeIn (.1, 100.))
+                ("MC.dmin",                   &Pp.MC.dmin,                   SValidator<double>::SVFRangeIn (-100., 100.))
+                ("MC.dmax",                   &Pp.MC.dmax,                   SValidator<double>::SVFRangeIn (-100., 100.))
+                ("MC.sssu_hist_size",         &Pp.MC.sssu_hist_size,         SValidator<size_t>::SVFRangeIn (10, 1000))
+                ("MC.smooth_side",            &Pp.MC.smooth_side,            SValidator<size_t>::SVFRangeIn (0, 10))
+                ("MC.estimate_E",             &Pp.MC.estimate_E)
+                ("MC.use_range",              &Pp.MC.use_range);
+
+        make_default_SComprehensiveArtifactDetectionPPack( Pp);
+        load();
+}
+
+
+string
+CComprehensiveArtifactDetector::
+serialize() const
+{
+        return move(
+                CStorablePPack::serialize() +
+                agh::str::sasprintf(
+                        "scope:%g; upper_thr:%g; lower_thr:%g; f0:%g; fc:%g; bandwidth:%g; mc_gain:%g; iir_backpolate:%g; E:%g; dmin:%g; dmax:%g; sssu_hist_size:%zu; smooth_side:%zu; estimate_E:%d;  use_range:%d;",
+                        // FIXME: mention all members please?
+                        Pp.MC.scope, Pp.MC.upper_thr, Pp.MC.lower_thr, Pp.MC.f0, Pp.MC.fc, Pp.MC.bandwidth, Pp.MC.mc_gain, Pp.MC.iir_backpolate,
+                        Pp.MC.E, Pp.MC.dmin, Pp.MC.dmax, Pp.MC.sssu_hist_size, Pp.MC.smooth_side,
+                        Pp.MC.estimate_E, Pp.MC.use_range));
+}
+
+
+
+TDetectArtifactsResult
+detect_artifacts( agh::CRecording& R,
+                  const SComprehensiveArtifactDetectionPPack& P)
+{
+        auto S = R.F().get_signal_original( R.h());
+        size_t sr = R.F().samplerate( R.h());
+
+        auto AF2 = R.F().artifacts( R.h());
+        auto& AF = R.F().artifacts( R.h());
+        bool marked_some = false;
+
+        // 1. Flat regions
+        {
+                size_t  last_j = 0;
+                for ( size_t i = 0; i < S.size(); ++i ) {
+                        if ( agh::dbl_cmp( S[i], S[last_j]) == 0 ) {
+                                size_t j = i;
+                                while ( j < S.size() && agh::dbl_cmp( S[j], S[last_j]) == 0 )
+                                        ++j;
+                                if ( j-i > P.flat_min_size * sr ) {
+                                        AF.mark_artifact(
+                                                (double)i/sr - P.flat_pad,
+                                                (double)j/sr + P.flat_pad);
+                                        marked_some = true;
+                                }
+                                i = j;
+                        }
+                        last_j = i;
+                }
+        }
+
+        // 2. EMG perturbations tada, needs EMG channel: how to get it here?
+        
+
+        // 3. MC-based
+        {
+                auto marked =
+                        metrics::mc::detect_artifacts( S, sr, P.MC);
+                for ( size_t p = 0; p < marked.size(); ++p ) {
+                        AF.mark_artifact(
+                                (marked[p]+0) * P.MC.scope,
+                                (marked[p]+1) * P.MC.scope);
+                        marked_some = true;
+                }
+        }
+
+        return  marked_some
+                ? AF() == AF2() ? TDetectArtifactsResult::marked_same : TDetectArtifactsResult::marked_new
+                : TDetectArtifactsResult::marked_nothing;
+}
+
+
+
+
+// this looks appropriate if we claim to be comprehensive
+void
+detect_artifacts( agh::SEpisode& E,
+                  const SComprehensiveArtifactDetectionPPack& P)
+{
+      // 1. and 3. are simple, single-channel algorithms
+        for ( auto& HR : E.recordings )
+                agh::ad::detect_artifacts( HR.second, P);
+
+      // 2. EMG perturbations
+        // which EMG channels are there?
+        list<agh::CRecording*> emgRR;
+        for ( auto& HR : E.recordings ) {
+                const sigfile::SChannel& H = HR.first;
+                agh::CRecording& R = HR.second;
+                if ( H.type() == sigfile::SChannel::TType::emg )
+                        emgRR.push_front( &R);
+                if ( emgRR.empty() ) {
+                        APPLOG_INFO ("No EMG recordings in episode %s (%s), skipping EMG perturbation-bound artifact detection", E.name(), E.sources.front()().patient_id());
+                }
+        }
+
+        for ( auto& emgR : emgRR ) {
+                double this_steady_tone =
+                        emgR->emg_steady_tone(
+                                P.emg_steady_secs, P.emg_max_dev_factor);
+                auto emg_raw_profile =
+                        sigproc::raw_signal_profile<TFloat>(
+                                {emgR->F().get_signal_original( emgR->h()), emgR->F().samplerate( emgR->h())},
+                                1., P.emg_min_steadytone_run);
+                for ( size_t t = 0; t < emg_raw_profile.size(); ++t )
+                        if ( emg_raw_profile[t] > this_steady_tone * P.emg_min_steadytone_factor )
+                                for ( auto& HR : E.recordings ) {
+                                        // if ( &HR.second != emgR ) {  // why skip emg channels indeed?
+                                        agh::CRecording& R = HR.second;
+                                        auto& AF = R.F().artifacts( R.h());
+                                        AF.mark_artifact(
+                                                (t+0) * P.emg_min_steadytone_run,
+                                                (t+1) * P.emg_min_steadytone_run);
+                                }
+        }
+}
+
+
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: nil
+// tab-width: 8
+// c-basic-offset: 8
+// End:
diff --git a/upstream/src/aghermann/artifact-detection/3in1.hh b/upstream/src/aghermann/artifact-detection/3in1.hh
new file mode 100644
index 0000000..f49b1ca
--- /dev/null
+++ b/upstream/src/aghermann/artifact-detection/3in1.hh
@@ -0,0 +1,148 @@
+/*
+ *       File name:  aghermann/artifact-detection/3in1.hh
+ *         Project:  Aghermann
+ *          Author:  Andrei Zavada <johnhommer at gmail.com>
+ * Initial version:  2013-10-14
+ *
+ *         Purpose:  Comprehensive artifact detection
+ *
+ *         License:  GPL
+ */
+
+#ifndef AGH_AGHERMANN_ARTIFACT_DETECTION_3IN1_H_
+#define AGH_AGHERMANN_ARTIFACT_DETECTION_3IN1_H_
+
+#include <list>
+
+#include <gtk/gtk.h>
+
+#include "common/lang.hh"
+#include "libmetrics/mc-artifacts.hh"
+#include "libsigfile/source-base.hh"
+#include "aghermann/expdesign/dirlevel.hh"
+#include "aghermann/expdesign/forward-decls.hh"
+
+#if HAVE_CONFIG_H && !defined(VERSION)
+#  include "config.h"
+#endif
+
+using namespace std;
+
+namespace agh {
+namespace ad {
+
+struct SComprehensiveArtifactDetectionPPack {
+        // one
+        bool    do_flat_regions;
+        double  flat_min_size,
+                flat_pad;
+
+        // two
+        bool    do_emg_perturbations;
+        size_t  emg_steady_secs;
+        double  emg_max_dev_factor;
+        double  emg_min_steadytone_factor,
+                emg_min_steadytone_run;
+
+        // three
+        bool    do_mc_based;
+        metrics::mc::SArtifactDetectionPPack
+                MC;
+
+        bool
+        operator==( const SComprehensiveArtifactDetectionPPack& rv) const
+                {
+                        return  do_flat_regions      == rv.do_flat_regions &&
+                                do_emg_perturbations == rv.do_emg_perturbations &&
+                                do_mc_based          == rv.do_mc_based &&
+                                dbl_cmp( flat_min_size, rv.flat_min_size)  == 0 &&
+                                dbl_cmp( flat_pad, rv.flat_pad)            == 0 &&
+                                dbl_cmp( emg_steady_secs, rv.emg_steady_secs)       == 0 &&
+                                dbl_cmp( emg_max_dev_factor, rv.emg_max_dev_factor) == 0 &&
+                                dbl_cmp( emg_min_steadytone_factor, rv.emg_min_steadytone_factor) == 0 &&
+                                dbl_cmp( emg_min_steadytone_run, rv.emg_min_steadytone_run)       == 0 &&
+                                MC == rv.MC;
+                }
+};
+
+
+inline
+void
+make_default_SComprehensiveArtifactDetectionPPack( SComprehensiveArtifactDetectionPPack& A)
+{
+        A.do_flat_regions = A.do_emg_perturbations = A.do_mc_based = true;
+        A.flat_min_size             = .5;
+        A.flat_pad                  = .5;
+        A.emg_steady_secs           = 10;
+        A.emg_max_dev_factor        = 1.1;
+        A.emg_min_steadytone_factor = 1.2;
+        A.emg_min_steadytone_run    = 2.;
+        metrics::mc::make_default_SArtifactDetectionPPack( A.MC);
+}
+
+
+class CComprehensiveArtifactDetector
+  : public agh::CStorablePPack {
+
+    public:
+        static constexpr const char* common_subdir = ".artifact-profiles/";
+
+        CComprehensiveArtifactDetector (const string& name_, agh::TExpDirLevel, agh::CExpDesign&, const agh::SExpDirLevelId&);
+        CComprehensiveArtifactDetector (agh::CExpDesign& ED_, const agh::SExpDirLevelId& level_id_)
+              : CStorablePPack (common_subdir, "(unnamed)", agh::TExpDirLevel::transient, ED_, level_id_)
+                {}
+        explicit CComprehensiveArtifactDetector (const CComprehensiveArtifactDetector& rv)
+              : CStorablePPack (rv),
+                Pp (rv.Pp)
+                {}
+        explicit CComprehensiveArtifactDetector (CComprehensiveArtifactDetector&& rv)
+              : CStorablePPack (common_subdir, move(rv.name), rv.level, rv.ED, move(rv.level_id)),
+                Pp (move(rv.Pp))
+                {
+                        rv.level = agh::TExpDirLevel::transient;
+                }
+
+       ~CComprehensiveArtifactDetector ()
+                {
+                        save();
+                }
+
+        CComprehensiveArtifactDetector&
+        operator=( const CComprehensiveArtifactDetector& rv)
+                { return Pp = rv.Pp, *this; }
+
+        bool
+        operator==( const CComprehensiveArtifactDetector& rv) const
+                { return Pp == rv.Pp; }  // don't bother about CStorable
+
+        string serialize() const;
+
+        SComprehensiveArtifactDetectionPPack
+                Pp;
+};
+
+
+
+enum class TDetectArtifactsResult {
+        marked_nothing,
+        marked_same,
+        marked_new,
+};
+
+TDetectArtifactsResult
+detect_artifacts( agh::CRecording& R,
+                  const SComprehensiveArtifactDetectionPPack& P);
+
+void
+detect_artifacts( agh::SEpisode& E,
+                  const SComprehensiveArtifactDetectionPPack& P);
+
+}}
+
+#endif
+
+// Local Variables:
+// indent-tabs-mode: nil
+// tab-width: 8
+// c-basic-offset: 8
+// End:
diff --git a/upstream/src/aghermann/expdesign/recording.cc b/upstream/src/aghermann/expdesign/recording.cc
index a3b2efb..5789d73 100644
--- a/upstream/src/aghermann/expdesign/recording.cc
+++ b/upstream/src/aghermann/expdesign/recording.cc
@@ -12,8 +12,10 @@
 #include <list>
 #include <valarray>
 
+#include "libsigproc/sigproc.hh"
 #include "aghermann/globals.hh"
 #include "aghermann/model/beersma.hh"
+#include "aghermann/rk1968/rk1968.hh"
 
 #include "recording.hh"
 #include "subject.hh"
@@ -31,7 +33,8 @@ CRecording (sigfile::CTypedSource& F, int sig_no,
         mc_profile  (F, sig_no, mc_params),
         uc_params (nullptr),
         _status (0), // not computed
-        _source (F), _sig_no (sig_no)
+        _source (F), _sig_no (sig_no),
+        _cached_emg_steady_tone (NAN)
 {}
 
 
@@ -44,6 +47,20 @@ agh::CRecording::
 
 
 
+double
+agh::CRecording::
+emg_steady_tone( size_t steady_secs, double max_dev_factor)
+{
+        if ( !isfinite( _cached_emg_steady_tone) ||
+             _cached_steady_secs != steady_secs ||
+             _cached_max_dev_factor != max_dev_factor )
+                tie (_cached_emg_steady_tone, ignore) =
+                        agh::rk1968::emg_steady_tone(
+                                sigproc::SSignalRef<TFloat> {_source().get_signal_original(_sig_no), _source().samplerate(_sig_no)},
+                                _cached_steady_secs = steady_secs,
+                                _cached_max_dev_factor = max_dev_factor);
+        return _cached_emg_steady_tone;
+}
 
 
 
diff --git a/upstream/src/aghermann/expdesign/recording.hh b/upstream/src/aghermann/expdesign/recording.hh
index ccea3bf..e7e9af9 100644
--- a/upstream/src/aghermann/expdesign/recording.hh
+++ b/upstream/src/aghermann/expdesign/recording.hh
@@ -236,18 +236,25 @@ class CRecording {
         metrics::swu::CProfile swu_profile;
         metrics::mc::CProfile  mc_profile;
 
+      // var/misc/etc
         bool
         have_uc_determined() const
                 { return uc_params; }
         agh::beersma::SUltradianCycle
                 *uc_params;
 
+        double  emg_steady_tone( size_t steady_secs, double max_dev_factor);
+
     protected:
         int     _status;
 
         sigfile::CTypedSource&
                 _source;
         int     _sig_no;
+
+        size_t  _cached_steady_secs;
+        double  _cached_max_dev_factor;
+        double  _cached_emg_steady_tone;
 };
 
 
diff --git a/upstream/src/aghermann/ui/mw/mainmenu_cb.cc b/upstream/src/aghermann/ui/mw/mainmenu_cb.cc
index 814f51c..90ebbc7 100644
--- a/upstream/src/aghermann/ui/mw/mainmenu_cb.cc
+++ b/upstream/src/aghermann/ui/mw/mainmenu_cb.cc
@@ -9,6 +9,7 @@
  *         License:  GPL
  */
 
+#include "aghermann/artifact-detection/3in1.hh"
 #include "aghermann/ui/misc.hh"
 #include "aghermann/ui/sm/sm.hh"
 #include "aghermann/ui/sf/sf.hh"
@@ -212,7 +213,7 @@ iExpBasicSADetectUltradianCycles_activate_cb(
 
 
 static void
-populate_combo( const list<metrics::mc::CArtifactDetector>& profiles, GtkListStore* mProfiles)
+populate_combo( const list<agh::ad::CComprehensiveArtifactDetector>& profiles, GtkListStore* mProfiles)
 {
         gtk_list_store_clear( mProfiles);
 
@@ -230,8 +231,8 @@ populate_combo( const list<metrics::mc::CArtifactDetector>& profiles, GtkListSto
 }
 
 
-static list<metrics::mc::CArtifactDetector>::const_iterator
-profile_by_idx( const list<metrics::mc::CArtifactDetector>& profiles, size_t idx)
+static list<agh::ad::CComprehensiveArtifactDetector>::const_iterator
+profile_by_idx( const list<agh::ad::CComprehensiveArtifactDetector>& profiles, size_t idx)
 {
         size_t i = 0;
         for ( auto I = profiles.cbegin(); I != profiles.cend(); ++I )
@@ -250,14 +251,14 @@ iExpGloballyDetectArtifacts_activate_cb(
         auto& ED = *(SExpDesignUI*)userdata;
 
         using namespace agh;
-        using metrics::mc::CArtifactDetector;
-        list<CArtifactDetector> profiles;
+        using agh::ad::CComprehensiveArtifactDetector;
+        list<CComprehensiveArtifactDetector> profiles;
 
         for ( auto A : {TExpDirLevel::system, TExpDirLevel::user, TExpDirLevel::experiment} )
                 profiles.splice(
                         profiles.end(),
-                        load_profiles_from_location<CArtifactDetector>(
-                                CArtifactDetector::common_subdir,
+                        load_profiles_from_location<CComprehensiveArtifactDetector>(
+                                CComprehensiveArtifactDetector::common_subdir,
                                 A, *ED.ED, agh::SExpDirLevelId {"", "", ""}));
 
         if ( profiles.size() < 1 ) {
@@ -281,8 +282,8 @@ iExpGloballyDetectArtifacts_activate_cb(
 
 
         auto response = gtk_dialog_run( ED.wGlobalArtifactDetection);
-        if ( response == GTK_RESPONSE_CANCEL ||
-             response == GTK_RESPONSE_DELETE_EVENT )
+        if ( GTK_RESPONSE_CANCEL == response ||
+             GTK_RESPONSE_DELETE_EVENT == response )
                 return; // just to save on indents in those lambdas below
 
         auto& P =
@@ -295,54 +296,50 @@ iExpGloballyDetectArtifacts_activate_cb(
         SBusyBlock bb (ED.wMainWindow);
 
         using namespace agh;
-        CExpDesign::TRecordingOpFun op;
-        CExpDesign::TRecordingFilterFun filter;
-        CExpDesign::TRecordingReportFun reporter =
-                [&]( const CJGroup&, const CSubject& J, const string& D, const SEpisode& E, const CRecording& R,
+        CExpDesign::TEpisodeOpFun op;
+        CExpDesign::TEpisodeFilterFun filter;
+        CExpDesign::TEpisodeReportFun reporter =
+                [&]( const CJGroup&, const CSubject& J, const string& D, const SEpisode& E,
                      size_t i, size_t total)
                 {
                         ED.sb_main_progress_indicator(
                                 snprintf_buf(
-                                        "Detect artifacts in %s/%s/%s/%s:%s",
-                                        ED.ED->group_of(J), J.id.c_str(), D.c_str(), E.name(), R.F().channel_by_id(R.h()).name()),
+                                        "Detect artifacts in %s/%s/%s/%s",
+                                        ED.ED->group_of(J), J.id.c_str(), D.c_str(), E.name()),
                                 total, i, TGtkRefreshMode::gtk);
                 };
         switch ( response ) {
         case GTK_RESPONSE_OK:
                 op =
-                [&]( CRecording& R)
+                [&]( SEpisode& E)
                 {
-                        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);
+                                for ( auto& F : E.sources )
+                                        for ( size_t h = 0; h < F().n_channels(); ++h )
+                                                F().artifacts((int)h).clear_all();
+                        ad::detect_artifacts( E, 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)
+                [&]( SEpisode& E)
                 {
-                        return R.signal_type() == sigfile::SChannel::TType::eeg;
+                        return true;  // R.signal_type() == sigfile::SChannel::TType::eeg;
                 };
             break;
-        case 1: // "Clear All"
+
+        case 1:  // "Clear All"
                 op =
-                [&]( CRecording& R)
+                [&]( SEpisode& E)
                 {
-                        auto& F = R.F();
-                        for ( auto& H : F.channel_list() ) {
-                                auto&        af = F.artifacts(F.channel_id(H));
-                                af.clear_all();
-                        }
+                        for ( auto& F : E.sources )
+                                for ( size_t h = 0; h < F().n_channels(); ++h )
+                                        F().artifacts((int)h).clear_all();
                 };
                 filter =
-                [&]( CRecording&)
+                [&]( SEpisode&)
                 {
                         return true; // clear in all channels (mark in EEG channels only)
                 };
@@ -355,7 +352,7 @@ iExpGloballyDetectArtifacts_activate_cb(
         for ( auto& SFp : ED.open_scoring_facilities )
                 bbl.push_front( new SBusyBlock (SFp->wSF));
 
-        ED.ED -> for_all_recordings( op, reporter, filter);
+        ED.ED -> for_all_episodes( op, reporter, filter);
         ED.sb_clear();
 
         for ( auto& SF : ED.open_scoring_facilities ) {
diff --git a/upstream/src/aghermann/ui/sf/channel.cc b/upstream/src/aghermann/ui/sf/channel.cc
index ed9497f..4aef7d1 100644
--- a/upstream/src/aghermann/ui/sf/channel.cc
+++ b/upstream/src/aghermann/ui/sf/channel.cc
@@ -403,11 +403,8 @@ void
 SScoringFacility::SChannel::
 detect_artifacts( const metrics::mc::SArtifactDetectionPPack& P)
 {
-        auto marked =
-                metrics::mc::detect_artifacts( signal_original, samplerate(), P);
-        for ( size_t p = 0; p < marked.size(); ++p )
-                artifacts.mark_artifact(
-                        marked[p] * P.scope, (marked[p]+1) * P.scope);
+        
+        
 
         calculate_dirty_percent();
         get_signal_filtered();
@@ -426,66 +423,6 @@ detect_artifacts( const metrics::mc::SArtifactDetectionPPack& P)
 }
 
 
-pair<double, double>
-SScoringFacility::SChannel::
-mark_flat_regions_as_artifacts( const double minsize, const double pad)
-{
-        double  total_before = artifacts.total();
-        size_t  marked_here = 0;
-        auto d =
-                sigproc::derivative( signal_original);
-        size_t  last_j = 0;
-        for ( size_t i = 0; i < d.size(); ++i )
-                if ( d[i] == 0. ) {
-                        size_t j = i;
-                        while ( j < d.size() && d[j] == 0. )
-                                ++j;
-                        if ( j-i > minsize * samplerate() ) {
-                                size_t extend_from = (i - last_j < .1) ? last_j : i;
-                                artifacts.mark_artifact(
-                                        (double)extend_from/samplerate() - pad,
-                                        (double)j/samplerate() + pad);
-                                marked_here += (j - extend_from);
-                                last_j = j;
-                        }
-                        i = j;
-                }
-
-        calculate_dirty_percent();
-        get_signal_filtered();
-        if ( type() == sigfile::SChannel::TType::eeg ) {
-                get_psd_course();
-                get_psd_in_bands();
-                get_spectrum( _p.cur_page());
-                get_swu_course();
-                get_mc_course();
-
-                // if ( this == channel currently displayed on measurements overview )
-                if ( strcmp( name(), _p._p.AghH()) == 0 )
-                        _p.redraw_ssubject_timeline();
-        }
-
-        return { (double)marked_here/samplerate(),
-                 (double)(artifacts.total() - total_before) };
-}
-
-pair<double, double>
-SScoringFacility::SChannel::
-mark_emg_perturbations_as_artifacts( const double min_steadytone_factor, const double min_steadytone_run)
-{
-        // which EMG channels are there?
-        forward_list<SChannel*> HH;
-        for ( auto &H : _p.channels )
-                if ( H.type() == sigfile::SChannel::TType::emg )
-                        HH.push_front( &H);
-        if ( HH.empty() )
-                return {0., 0.};
-        
-
-        // return { (double)marked_here/samplerate(),
-        //          (double)(artifacts.total() - total_before) };
-}
-
 
 
 
diff --git a/upstream/src/aghermann/ui/sf/channel.hh b/upstream/src/aghermann/ui/sf/channel.hh
index 5c63b8f..644b6df 100644
--- a/upstream/src/aghermann/ui/sf/channel.hh
+++ b/upstream/src/aghermann/ui/sf/channel.hh
@@ -97,13 +97,7 @@ struct SScoringFacility::SChannel {
         calculate_dirty_percent();
 
         void
-        detect_artifacts( const metrics::mc::SArtifactDetectionPPack&);
-
-        pair<double, double>
-        mark_flat_regions_as_artifacts( double at_least_this_long, double pad);
-
-        pair<double, double>
-        mark_emg_perturbations_as_artifacts( double min_steadytone_factor, double min_steadytone_run);
+        detect_artifacts( const agh::ad::SComprehensiveArtifactDetectionPPack&);
 
       // annotations
         list<sigfile::SAnnotation*>
diff --git a/upstream/src/aghermann/ui/sf/construct.cc b/upstream/src/aghermann/ui/sf/construct.cc
index a871572..df68160 100644
--- a/upstream/src/aghermann/ui/sf/construct.cc
+++ b/upstream/src/aghermann/ui/sf/construct.cc
@@ -238,7 +238,6 @@ SScoringFacilityWidgets ()
         AGH_GBGETOBJ (iSFPageUseThisScale);
         AGH_GBGETOBJ (iSFPageArtifactsDetect);
         AGH_GBGETOBJ (iSFPageArtifactsClear);
-        AGH_GBGETOBJ (iSFPageSimpleArtifacts);
         AGH_GBGETOBJ (iSFPageHide);
         AGH_GBGETOBJ (iSFPageHidden);
         AGH_GBGETOBJ (iSFPageSpaceEvenly);
@@ -295,7 +294,6 @@ SScoringFacilityWidgets ()
         G_CONNECT_1 (iSFPageExportSignal, activate);
         G_CONNECT_1 (iSFPageUseThisScale, activate);
         G_CONNECT_1 (iSFPageArtifactsDetect, activate);
-        G_CONNECT_1 (iSFPageSimpleArtifacts, activate);
         G_CONNECT_1 (iSFPageArtifactsClear, activate);
         G_CONNECT_1 (iSFPageHide, activate);
 
diff --git a/upstream/src/aghermann/ui/sf/d/artifacts-simple-construct.cc b/upstream/src/aghermann/ui/sf/d/artifacts-simple-construct.cc
deleted file mode 100644
index 77bdc28..0000000
--- a/upstream/src/aghermann/ui/sf/d/artifacts-simple-construct.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- *       File name:  aghermann/ui/sf/d/artifacts-simple-construct.cc
- *         Project:  Aghermann
- *          Author:  Andrei Zavada <johnhommer at gmail.com>
- * Initial version:  2012-10-25
- *
- *         Purpose:  scoring facility Artifacts Simple (flat signal detection) construct
- *
- *         License:  GPL
- */
-
-#include <stdexcept>
-
-#include "aghermann/ui/ui.hh"
-
-#include "artifacts-simple.hh"
-
-using namespace std;
-using namespace agh::ui;
-
-SArtifactsSimpleDialogWidgets::
-SArtifactsSimpleDialogWidgets ()
-{
-        builder = gtk_builder_new();
-        if ( !gtk_builder_add_from_resource( builder, "/org/gtk/aghermann/sf-artifacts-simple.glade", NULL) )
-                throw runtime_error( "Failed to load SF::artifacts-simple glade resource");
-        gtk_builder_connect_signals( builder, NULL);
-
-        AGH_GBGETOBJ (wSFAS);
-        AGH_GBGETOBJ (eSFASMinFlatRegionSize);
-        AGH_GBGETOBJ (eSFASPad);
-        AGH_GBGETOBJ (eSFASLookAtEMG);
-        AGH_GBGETOBJ (eSFASMinSteadyToneFactor);
-        AGH_GBGETOBJ (eSFASMinSteadyToneRun);
-        AGH_GBGETOBJ (eSFASThisChannelOnly);
-}
-
-
-SArtifactsSimpleDialogWidgets::
-~SArtifactsSimpleDialogWidgets ()
-{
-        gtk_widget_destroy( (GtkWidget*)wSFAS);
-        g_object_unref( (GObject*)builder);
-}
-
-
-// Local Variables:
-// indent-tabs-mode: nil
-// tab-width: 8
-// c-basic-offset: 8
-// End:
diff --git a/upstream/src/aghermann/ui/sf/d/artifacts-simple.cc b/upstream/src/aghermann/ui/sf/d/artifacts-simple.cc
deleted file mode 100644
index 42577b1..0000000
--- a/upstream/src/aghermann/ui/sf/d/artifacts-simple.cc
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- *       File name:  aghermann/ui/sf/d/artifacts-simple.cc
- *         Project:  Aghermann
- *          Author:  Andrei Zavada <johnhommer at gmail.com>
- * Initial version:  2013-01-25
- *
- *         Purpose:  scoring facility: simple artifact detection dialog
- *
- *         License:  GPL
- */
-
-#include "artifacts-simple.hh"
-
-using namespace std;
-using namespace agh::ui;
-
-SScoringFacility::SArtifactsSimpleDialog&
-SScoringFacility::
-artifacts_simple_d()
-{
-        if ( not _artifacts_simple_d )
-                _artifacts_simple_d = new SArtifactsSimpleDialog(*this);
-        return *_artifacts_simple_d;
-}
-
-
-SScoringFacility::SArtifactsSimpleDialog::
-SArtifactsSimpleDialog (SScoringFacility& p_)
-      : flat_min_size (0.5),
-        flat_pad (.2),
-        do_emg_perturbations_check (true),
-        emg_min_steadytone_factor (1.5),
-        emg_min_steadytone_run (2.),
-        _p (p_)
-{
-        W_V.reg( eSFASMinFlatRegionSize,   &flat_min_size);
-        W_V.reg( eSFASPad,                 &flat_pad);
-        W_V.reg( eSFASLookAtEMG,           &do_emg_perturbations_check);
-        W_V.reg( eSFASMinSteadyToneFactor, &emg_min_steadytone_factor);
-        W_V.reg( eSFASMinSteadyToneRun,    &emg_min_steadytone_run);
-        W_V.reg( eSFASThisChannelOnly,     &this_channel_only);
-
-        W_V.up();
-}
-
-
-
-// Local Variables:
-// Mode: c++
-// indent-tabs-mode: nil
-// tab-width: 8
-// c-basic-offset: 8
-// End:
diff --git a/upstream/src/aghermann/ui/sf/d/artifacts-simple.hh b/upstream/src/aghermann/ui/sf/d/artifacts-simple.hh
deleted file mode 100644
index 1ec0a03..0000000
--- a/upstream/src/aghermann/ui/sf/d/artifacts-simple.hh
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- *       File name:  aghermann/ui/sf/d/artifacts-simple.hh
- *         Project:  Aghermann
- *          Author:  Andrei Zavada <johnhommer at gmail.com>
- * Initial version:  2013-01-24
- *
- *         Purpose:  scoring facility Artifacts Simple (flat signal detection) dialog
- *
- *         License:  GPL
- */
-
-#ifndef AGH_AGHERMANN_UI_SF_D_ARTIFACTS_SIMPLE_H_
-#define AGH_AGHERMANN_UI_SF_D_ARTIFACTS_SIMPLE_H_
-
-#include <gtk/gtk.h>
-
-#include "aghermann/ui/ui++.hh"
-#include "aghermann/ui/sf/sf.hh"
-
-#if HAVE_CONFIG_H && !defined(VERSION)
-#  include "config.h"
-#endif
-
-using namespace std;
-
-namespace agh {
-namespace ui {
-
-struct SArtifactsSimpleDialogWidgets {
-
-        SArtifactsSimpleDialogWidgets ();
-       ~SArtifactsSimpleDialogWidgets ();
-
-        GtkBuilder
-                *builder;
-
-        GtkDialog
-                *wSFAS;
-        GtkSpinButton
-                *eSFASMinFlatRegionSize,
-                *eSFASPad;
-
-        GtkCheckButton
-                *eSFASLookAtEMG;
-        GtkSpinButton
-                *eSFASMinSteadyToneFactor,
-                *eSFASMinSteadyToneRun;
-
-        GtkCheckButton
-                *eSFASThisChannelOnly;
-};
-
-struct SScoringFacility::SArtifactsSimpleDialog
-  : public SArtifactsSimpleDialogWidgets {
-
-        DELETE_DEFAULT_METHODS (SArtifactsSimpleDialog);
-
-        SArtifactsSimpleDialog (SScoringFacility&);
-
-        double  flat_min_size,
-                flat_pad;
-
-        bool    do_emg_perturbations_check;
-        double  emg_min_steadytone_factor,
-                emg_min_steadytone_run;
-
-        bool    this_channel_only;
-
-        SUIVarCollection
-                W_V;
-
-        SScoringFacility&
-                _p;
-};
-
-}
-} // namespace agh::ui
-
-#endif // _AGH_UI_SF_FILTERS_H
-
-// Local Variables:
-// indent-tabs-mode: nil
-// tab-width: 8
-// c-basic-offset: 8
-// End:
diff --git a/upstream/src/aghermann/ui/sf/d/artifacts.cc b/upstream/src/aghermann/ui/sf/d/artifacts.cc
index eab7bb6..bb464ba 100644
--- a/upstream/src/aghermann/ui/sf/d/artifacts.cc
+++ b/upstream/src/aghermann/ui/sf/d/artifacts.cc
@@ -27,7 +27,7 @@ artifacts_d()
 
 SScoringFacility::SArtifactsDialog::
 SArtifactsDialog (SScoringFacility& p_)
-      : SDirlevelStorableAdapter<metrics::mc::CArtifactDetector> (
+      : SDirlevelStorableAdapter<agh::ad::CComprehensiveArtifactDetector>> (
               *p_._p.ED, agh::SExpDirLevelId {p_._p.ED->group_of(p_.csubject()), p_.csubject().id, p_.session()},
               mSFADProfiles, eSFADProfileList, eSFADProfileList_changed_cb_handler_id,
               bSFADProfileSave, bSFADProfileRevert, bSFADProfileDiscard,
@@ -124,21 +124,24 @@ SArtifactsDialog (SScoringFacility& p_)
                         this);
       // 2. vars
         auto& P = Pp2.Pp;
-        W_V.reg( eSFADScope,              &P.scope);
-        W_V.reg( eSFADUpperThr,           &P.upper_thr);
-        W_V.reg( eSFADLowerThr,           &P.lower_thr);
-        W_V.reg( eSFADF0,                 &P.f0);
-        W_V.reg( eSFADFc,                 &P.fc);
-        W_V.reg( eSFADBandwidth,          &P.bandwidth);
-        W_V.reg( eSFADMCGain,             &P.mc_gain);
-        W_V.reg( eSFADBackpolate,         &P.iir_backpolate);
-        W_V.reg( eSFADEstimateE,          &P.estimate_E);
-        W_V.reg( eSFADEValue,             &P.E);
-        W_V.reg( eSFADHistRangeMin,       &P.dmin);
-        W_V.reg( eSFADHistRangeMax,       &P.dmax);
-        W_V.reg( eSFADHistBins,     (int*)&P.sssu_hist_size);
-        W_V.reg( eSFADSmoothSide,   (int*)&P.smooth_side);
-        W_V.reg( (GtkCheckButton*)eSFADUseThisRange,       &P.use_range);
+        W_V.reg( eSFADScope,                         &P.MC.scope);
+        W_V.reg( eSFADUpperThr,                      &P.MC.upper_thr);
+        W_V.reg( eSFADLowerThr,                      &P.MC.lower_thr);
+        W_V.reg( eSFADF0,                            &P.MC.f0);
+        W_V.reg( eSFADFc,                            &P.MC.fc);
+        W_V.reg( eSFADBandwidth,                     &P.MC.bandwidth);
+        W_V.reg( eSFADMCGain,                        &P.MC.mc_gain);
+        W_V.reg( eSFADBackpolate,                    &P.MC.iir_backpolate);
+        W_V.reg( eSFADEstimateE,                     &P.MC.estimate_E);
+        W_V.reg( eSFADEValue,                        &P.MC.E);
+        W_V.reg( eSFADHistRangeMin,                  &P.MC.dmin);
+        W_V.reg( eSFADHistRangeMax,                  &P.MC.dmax);
+        W_V.reg( eSFADHistBins,     (int*)           &P.MC.sssu_hist_size);
+        W_V.reg( eSFADSmoothSide,   (int*)           &P.MC.smooth_side);
+        W_V.reg( (GtkCheckButton*)eSFADUseThisRange, &P.MC.use_range);
+        W_V.reg( eSFADFlatMinRegionSize,             &P.flat_min_size);
+        W_V.reg( eSFADFlatPad,                       &P.flat_pad);
+        W_V.reg( eSFADEMGMinSteadyToneFactor,        &P.
 
         atomic_up();
 }
diff --git a/upstream/src/aghermann/ui/sf/d/artifacts.hh b/upstream/src/aghermann/ui/sf/d/artifacts.hh
index bec5ec6..3a183e5 100644
--- a/upstream/src/aghermann/ui/sf/d/artifacts.hh
+++ b/upstream/src/aghermann/ui/sf/d/artifacts.hh
@@ -16,8 +16,7 @@
 
 #include <gtk/gtk.h>
 
-#include "libmetrics/mc-artifacts.hh"
-#include "libsigfile/source-base.hh"
+#include "aghermann/artifact-detection/3in1.hh"
 #include "aghermann/ui/dirlevel-storable-adapter.hh"
 #include "aghermann/ui/ui++.hh"
 #include "aghermann/ui/sf/sf.hh"
@@ -32,7 +31,7 @@ namespace agh {
 namespace ui {
 
 struct SScoringFacility::SArtifactsDialog
-  : public SDirlevelStorableAdapter<metrics::mc::CArtifactDetector> {
+  : public SDirlevelStorableAdapter<agh::ad::CComprehensiveArtifactDetector> {
 
         DELETE_DEFAULT_METHODS (SArtifactsDialog);
 
@@ -51,10 +50,12 @@ struct SScoringFacility::SArtifactsDialog
         SScoringFacility&
                 _p;
 
-        GtkBuilder *builder;
-
+        GtkBuilder
+                *builder;
+      // widgets
         GtkDialog
                 *wSFAD;
+        // A. Profiles
         GtkListStore
                 *mSFADProfiles;
         GtkComboBox
@@ -64,6 +65,21 @@ struct SScoringFacility::SArtifactsDialog
                 *bSFADProfileSave,
                 *bSFADProfileRevert,
                 *bSFADProfileDiscard;
+        GtkDialog
+                *wSFADProfileSave;
+        GtkToggleButton
+                *eSFADProfileSaveOriginSubject,
+                *eSFADProfileSaveOriginExperiment,
+                *eSFADProfileSaveOriginUser;
+        GtkButton
+                *bSFADProfileSaveOK;
+        GtkEntry
+                *eSFADProfileSaveName;
+
+        // B. Contents
+        // 1. MC-based
+        GtkCheckButton
+                *eSFADMCBasedConsider;
         GtkSpinButton
                 *eSFADUpperThr,
                 *eSFADLowerThr,
@@ -87,6 +103,22 @@ struct SScoringFacility::SArtifactsDialog
         GtkTable
                 *cSFADWhenEstimateEOn,
                 *cSFADWhenEstimateEOff;
+
+        // 2. Flat regions
+        GtkCheckButton
+                *eSFADFlatConsider;
+        GtkSpinButton
+                *eSFADFlatMinRegionSize,
+                *eSFADFlatPad;
+
+        // 3. EMG perturbations
+        GtkCheckButton
+                *eSFADEMGConsider;
+        GtkSpinButton
+                *eSFADEMGMinSteadyToneFactor,
+                *eSFADEMGMinSteadyToneRun;
+
+        // C. Dialog buttons
         GtkLabel
                 *lSFADInfo,
                 *lSFADDirtyPercent;
@@ -95,17 +127,6 @@ struct SScoringFacility::SArtifactsDialog
         GtkButton
                 *bSFADApply,
                 *bSFADDismiss;
-
-        GtkDialog
-                *wSFADProfileSave;
-        GtkToggleButton
-                *eSFADProfileSaveOriginSubject,
-                *eSFADProfileSaveOriginExperiment,
-                *eSFADProfileSaveOriginUser;
-        GtkButton
-                *bSFADProfileSaveOK;
-        GtkEntry
-                *eSFADProfileSaveName;
 };
 
 
diff --git a/upstream/src/aghermann/ui/sf/montage-menus_cb.cc b/upstream/src/aghermann/ui/sf/montage-menus_cb.cc
index f76f2b5..5ff2937 100644
--- a/upstream/src/aghermann/ui/sf/montage-menus_cb.cc
+++ b/upstream/src/aghermann/ui/sf/montage-menus_cb.cc
@@ -15,7 +15,6 @@
 #include "sf.hh"
 #include "sf_cb.hh"
 #include "d/artifacts.hh"
-#include "d/artifacts-simple.hh"
 #include "d/filters.hh"
 
 
@@ -320,38 +319,6 @@ iSFPageArtifactsDetect_activate_cb(
         gtk_widget_show( (GtkWidget*)AD.wSFAD);
 }
 
-void
-iSFPageSimpleArtifacts_activate_cb(
-        GtkMenuItem*,
-        const gpointer userdata)
-{
-        auto& SF = *(SScoringFacility*)userdata;
-        auto& AS = SF.artifacts_simple_d();
-        if ( GTK_RESPONSE_OK ==
-             gtk_dialog_run( (GtkDialog*)AS.wSFAS) ) {
-                AS.W_V.down();
-
-                if ( AS.this_channel_only ) {
-                        auto marked_flat = SF.using_channel->mark_flat_regions_as_artifacts( AS.flat_min_size, AS.flat_pad);
-                        if ( AS.do_emg_perturbations_check )
-                                SF.using_channel->mark_emg_perturbations_as_artifacts( AS.emg_min_steadytone_factor, AS.emg_min_steadytone_run);
-                        // SF.sb_message(
-                        //         snprintf_buf(
-                        //                 "Detected %.2g sec of flat regions and %.2g sec of EMG perturbations",
-                        //                 marked_flat.first, marked_flat.second));
-                } else
-                        for ( auto& H : SF.channels ) {
-                                H.mark_flat_regions_as_artifacts( AS.flat_min_size, AS.flat_pad);
-                                if ( AS.do_emg_perturbations_check )
-                                        H.mark_emg_perturbations_as_artifacts( AS.emg_min_steadytone_factor, AS.emg_min_steadytone_run);
-                        }
-
-                gtk_widget_queue_draw( (GtkWidget*)SF.daSFMontage);
-                gtk_widget_queue_draw( (GtkWidget*)SF.daSFHypnogram);
-        }
-}
-
-
 
 void
 iSFPageArtifactsClear_activate_cb(
diff --git a/upstream/src/aghermann/ui/sf/sf.cc b/upstream/src/aghermann/ui/sf/sf.cc
index 22d9013..9d46aea 100644
--- a/upstream/src/aghermann/ui/sf/sf.cc
+++ b/upstream/src/aghermann/ui/sf/sf.cc
@@ -73,7 +73,6 @@ SScoringFacility (agh::CSubject& J,
         mode                       (TMode::scoring),
         crosshair_at               (10),
         show_cur_pos_time_relative (false),
-        _artifacts_simple_d (nullptr),
         draw_crosshair             (false),
         alt_hypnogram              (true),
         pagesize_item              (figure_display_pagesize_item( parent.pagesize())),
diff --git a/upstream/src/aghermann/ui/sf/sf.hh b/upstream/src/aghermann/ui/sf/sf.hh
index ece8e02..ec5957f 100644
--- a/upstream/src/aghermann/ui/sf/sf.hh
+++ b/upstream/src/aghermann/ui/sf/sf.hh
@@ -302,10 +302,6 @@ class SScoringFacility
         SArtifactsDialog&
         artifacts_d();
 
-        struct SArtifactsSimpleDialog;
-        SArtifactsSimpleDialog&
-        artifacts_simple_d();
-
         struct SRK1968Dialog;
         SRK1968Dialog&
         rk1968_d();
@@ -319,8 +315,6 @@ class SScoringFacility
                 *_phasediff_d;
         SArtifactsDialog
                 *_artifacts_d;
-        SArtifactsSimpleDialog
-                *_artifacts_simple_d;
         SRK1968Dialog
                 *_rk1968_d;
 
diff --git a/upstream/src/aghermann/ui/sf/sf_cb.hh b/upstream/src/aghermann/ui/sf/sf_cb.hh
index 259846a..77b1d2a 100644
--- a/upstream/src/aghermann/ui/sf/sf_cb.hh
+++ b/upstream/src/aghermann/ui/sf/sf_cb.hh
@@ -92,7 +92,6 @@ void iSFPageUseResample_toggled_cb( GtkCheckMenuItem*, gpointer);
 void iSFPageDrawZeroline_toggled_cb( GtkCheckMenuItem*, gpointer);
 void iSFPageDrawEMGSteadyTone_toggled_cb( GtkCheckMenuItem*, gpointer);
 void iSFPageArtifactsDetect_activate_cb( GtkMenuItem*, gpointer);
-void iSFPageSimpleArtifacts_activate_cb( GtkMenuItem*, gpointer);
 void iSFPageArtifactsClear_activate_cb( GtkMenuItem*, gpointer);
 void iSFPageFilter_activate_cb( GtkMenuItem*, gpointer);
 void iSFPageSaveChannelAsSVG_activate_cb( GtkMenuItem*, gpointer);
diff --git a/upstream/src/aghermann/ui/sf/widgets.hh b/upstream/src/aghermann/ui/sf/widgets.hh
index d369bd0..c364467 100644
--- a/upstream/src/aghermann/ui/sf/widgets.hh
+++ b/upstream/src/aghermann/ui/sf/widgets.hh
@@ -165,7 +165,7 @@ struct SScoringFacilityWidgets {
                 *iSFPageFilter,
                 *iSFPageSaveChannelAsSVG, *iSFPageSaveMontageAsSVG,
                 *iSFPageExportSignal, *iSFPageUseThisScale,
-                *iSFPageArtifactsDetect, *iSFPageSimpleArtifacts, *iSFPageArtifactsClear,
+                *iSFPageArtifactsDetect, *iSFPageArtifactsClear,
                 *iSFPageHide,
                 *iSFPageHidden,  // has a submenu
                 *iSFPageSpaceEvenly,
diff --git a/upstream/src/libmetrics/mc-artifacts.hh b/upstream/src/libmetrics/mc-artifacts.hh
index 7b1e3c8..958cf00 100644
--- a/upstream/src/libmetrics/mc-artifacts.hh
+++ b/upstream/src/libmetrics/mc-artifacts.hh
@@ -17,7 +17,6 @@
 #include <valarray>
 #include "common/lang.hh"
 #include "libsigproc/sigproc.hh"
-#include "aghermann/expdesign/dirlevel.hh"
 
 #if HAVE_CONFIG_H && !defined(VERSION)
 #  include "config.h"
@@ -43,91 +42,46 @@ struct SArtifactDetectionPPack {
         operator==( const SArtifactDetectionPPack& rv) const
                 {
                         using agh::dbl_cmp;
-                        return  dbl_cmp(scope, rv.scope) == 0 &&
-                                dbl_cmp(upper_thr, rv.upper_thr) == 0 &&
-                                dbl_cmp(lower_thr, rv.lower_thr) == 0 &&
-                                dbl_cmp(f0, rv.f0) == 0 &&
-                                dbl_cmp(fc, rv.fc) == 0 &&
-                                dbl_cmp(bandwidth, rv.bandwidth) == 0 &&
-                                dbl_cmp(mc_gain, rv.mc_gain) == 0 &&
+                        return  dbl_cmp(scope, rv.scope)                   == 0 &&
+                                dbl_cmp(upper_thr, rv.upper_thr)           == 0 &&
+                                dbl_cmp(lower_thr, rv.lower_thr)           == 0 &&
+                                dbl_cmp(f0, rv.f0)                         == 0 &&
+                                dbl_cmp(fc, rv.fc)                         == 0 &&
+                                dbl_cmp(bandwidth, rv.bandwidth)           == 0 &&
+                                dbl_cmp(mc_gain, rv.mc_gain)               == 0 &&
                                 dbl_cmp(iir_backpolate, rv.iir_backpolate) == 0 &&
-                                dbl_cmp(E, rv.E) == 0 &&
-                                dbl_cmp(dmin, rv.dmin) == 0 &&
-                                dbl_cmp(dmax, rv.dmax) == 0 &&
-                                sssu_hist_size == rv.sssu_hist_size &&
-                                smooth_side == rv.smooth_side &&
-                                estimate_E == rv.estimate_E &&
-                                use_range == rv.use_range;
+                                dbl_cmp(E, rv.E)                           == 0 &&
+                                dbl_cmp(dmin, rv.dmin)                     == 0 &&
+                                dbl_cmp(dmax, rv.dmax)                     == 0 &&
+                                sssu_hist_size                             == rv.sssu_hist_size &&
+                                smooth_side                                == rv.smooth_side &&
+                                estimate_E                                 == rv.estimate_E &&
+                                use_range                                  == rv.use_range;
                 }
 };
 
 inline void
 make_default_SArtifactDetectionPPack( SArtifactDetectionPPack& p)
 {
-        p.scope = 4.;
-        p.upper_thr = 9.;
-        p.lower_thr = -9.;
-        p.f0 = 1.;
-        p.fc = 1.8;
-        p.bandwidth = 1.5;
-        p.mc_gain = 10.;
-        p.iir_backpolate = .5;
-        p.E = 4.;
-        p.dmin = -10;
-        p.dmax = 20;
+        p.scope          =  4.;
+        p.upper_thr      =  9.;
+        p.lower_thr      = -9.;
+        p.f0             =  1.;
+        p.fc             =  1.8;
+        p.bandwidth      =  1.5;
+        p.mc_gain        = 10.;
+        p.iir_backpolate =   .5;
+        p.E              =  4.;
+        p.dmin           = -10;
+        p.dmax           =  20;
         p.sssu_hist_size = 100;
-        p.smooth_side = 0;
-        p.estimate_E = true;
-        p.use_range = false;
+        p.smooth_side    =   0;
+        p.estimate_E     =  true;
+        p.use_range      = false;
 }
 
 
 
-class CArtifactDetector
-  : public agh::CStorablePPack {
-
-    public:
-        static constexpr const char* common_subdir = ".artifact-profiles/";
-
-        CArtifactDetector (const string& name_, agh::TExpDirLevel, agh::CExpDesign&, const agh::SExpDirLevelId&);
-        CArtifactDetector (agh::CExpDesign& ED_, const agh::SExpDirLevelId& level_id_)
-              : CStorablePPack (common_subdir, "(unnamed)", agh::TExpDirLevel::transient, ED_, level_id_)
-                {}
-        explicit CArtifactDetector (const CArtifactDetector& rv)
-              : CStorablePPack (rv),
-                Pp (rv.Pp)
-                {
-                        // assign_keys();
-                }
-        explicit CArtifactDetector (CArtifactDetector&& rv)
-              : CStorablePPack (common_subdir, move(rv.name), rv.level, rv.ED, move(rv.level_id)),
-                Pp (move(rv.Pp))
-                {
-                        rv.level = agh::TExpDirLevel::transient;  // we do the saving, prevent rv from doing so
-                        // assign_keys();
-                }
-
-       ~CArtifactDetector ()
-                {
-                        save();
-                }
-
-        CArtifactDetector&
-        operator=( const CArtifactDetector& rv)
-                { return Pp = rv.Pp, *this; }
-
-        bool
-        operator==( const CArtifactDetector& rv) const
-                { return Pp == rv.Pp; }  // don't bother about CStorable
-
-        string serialize() const;
-
-        SArtifactDetectionPPack
-                Pp;
-};
-
-
-
 template <typename T>
 vector<size_t> // don't estimate, use pi*B*x^2 (E) as provided
 detect_artifacts( const valarray<T>& signal, size_t sr,
diff --git a/upstream/src/libmetrics/page-metrics-base.hh b/upstream/src/libmetrics/page-metrics-base.hh
index 7b4c6b3..c7eb984 100644
--- a/upstream/src/libmetrics/page-metrics-base.hh
+++ b/upstream/src/libmetrics/page-metrics-base.hh
@@ -50,7 +50,7 @@ name( TType t)
 
 
 struct SPPack {
-        double        pagesize,
+        double  pagesize,
                 step;
 
         SPPack ()
@@ -160,7 +160,7 @@ class CProfile {
         virtual string fname_base() const = 0;
         virtual string mirror_fname() const = 0;
 
-        enum TFlags : int {
+        enum TFlags {
                 computed = (1<<0),
                 computable = (1<<1)
         };
diff --git a/upstream/src/libsigfile/source-base.cc b/upstream/src/libsigfile/source-base.cc
index 5a6958b..25c5f7b 100644
--- a/upstream/src/libsigfile/source-base.cc
+++ b/upstream/src/libsigfile/source-base.cc
@@ -12,6 +12,7 @@
 #include <cstdarg>
 #include <fstream>
 #include "common/string.hh"
+#include "common/alg.hh"
 #include "libsigproc/sigproc.hh"
 #include "source-base.hh"
 
@@ -413,8 +414,9 @@ get_region_filtered_smpl( const int h,
       // artifacts
         const auto& AA = artifacts(h);
         for ( const auto& A : AA() ) {
-                size_t  Aa = A.a * this_samplerate,
-                        Az = A.z * this_samplerate;
+                assert (A.a < A.z);  // this is logic_error
+                size_t  Aa = this_samplerate * agh::alg::value_within(A.a, (decltype(A.a))smpla * this_samplerate, (decltype(A.a))smplz * this_samplerate),
+                        Az = this_samplerate * agh::alg::value_within(A.z, (decltype(A.z))smpla * this_samplerate, (decltype(A.z))smplz * this_samplerate);
                 if ( unlikely (Aa >= smplz) )
                         break;
                 size_t  run = (Az - Aa),

-- 
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