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

Andrei Zavada johnhommer at gmail.com
Sun Feb 3 12:52:57 UTC 2013


The following commit has been merged in the master branch:
commit fd015c7f80b8eb32d062b37cf3e8e7cf1677ff80
Author: Andrei Zavada <johnhommer at gmail.com>
Date:   Mon Jan 28 03:06:18 2013 +0200

    weekend WIP

diff --git a/ChangeLog b/ChangeLog
index 393e756..07f838d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,14 +1,17 @@
 v.0.8.0 (2013-01-xx)
-	* edfcat: better handling of overshooting signal portions.
-	* phasic events detection groundwork.
+	* edfcat: proper handling of overshooting signal portions.
+	* Phasic events detection groundwork.
 	* SF: mark flat signal portions as artifacts.
-	* SF: reingeneered Patterns dialog:
+	* SF: reingeneered Patterns/Find dialog:
 	  o use band-pass for target frequency matching;
 	  o system, user, experiment and subject-wide patterns:
 	  o obtain match index once, for instantaneous finding
 	    against variable criteria;
 	  o mark matches as annotations;
 	* Fix envelope function.
+	* Fix dzcdf function.
+	* Differentiate and make use subject full/short name.
+	* SF: Ensure all annotations are shown.
 
 v.0.7.6 (2012-12-20)
 	* Don't forget to save some .expdesign.conf settings.
diff --git a/data/aghermann.gresource.xml b/data/aghermann.gresource.xml
index 15b0876..01bbfb7 100644
--- a/data/aghermann.gresource.xml
+++ b/data/aghermann.gresource.xml
@@ -10,6 +10,8 @@
     <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>
     <file compressed="true">mf.glade</file>
diff --git a/data/mw-dialogs.glade b/data/mw-dialogs.glade
index e522854..3cc10ee 100644
--- a/data/mw-dialogs.glade
+++ b/data/mw-dialogs.glade
@@ -431,17 +431,6 @@ With bug reports, either send yours to <a href="mailto:aghermann-users at lists.
 	* Correctly set OMP max threads.
 	* edfcat conv: set physical_min/max.
 </span>
-<big><b>v. 0.7.5.1</b></big> (2012-12-04)
-<span font="monospace">
-	* Fix Ubuntu build.
-</span>
-<big><b>v. 0.7.5</b></big> (2012-12-03)
-<span font="monospace">
-	* Experimental SWU profile.
-	* General overhaul of profiles.
-	* Fix SF Find dialog wrt search in a changed
-	  field channel.
-</span>
 
 (for older entries, see <a href="http://johnhommer.com/academic/code/aghermann">full changelog</a>)</property>
                             <property name="use_markup">True</property>
@@ -2557,11 +2546,11 @@ With bug reports, either send yours to <a href="mailto:aghermann-users at lists.
                     <property name="xalign">1</property>
                     <property name="label" translatable="yes">Full _name:</property>
                     <property name="use_underline">True</property>
-                    <property name="mnemonic_widget">eSubjectDetailsName</property>
+                    <property name="mnemonic_widget">eSubjectDetailsFullName</property>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
-                    <property name="top_attach">0</property>
+                    <property name="top_attach">1</property>
                     <property name="width">1</property>
                     <property name="height">1</property>
                   </packing>
@@ -2575,7 +2564,7 @@ With bug reports, either send yours to <a href="mailto:aghermann-users at lists.
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
-                    <property name="top_attach">1</property>
+                    <property name="top_attach">2</property>
                     <property name="width">1</property>
                     <property name="height">1</property>
                   </packing>
@@ -2591,7 +2580,7 @@ With bug reports, either send yours to <a href="mailto:aghermann-users at lists.
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
-                    <property name="top_attach">2</property>
+                    <property name="top_attach">3</property>
                     <property name="width">1</property>
                     <property name="height">1</property>
                   </packing>
@@ -2609,7 +2598,7 @@ With bug reports, either send yours to <a href="mailto:aghermann-users at lists.
                   </object>
                   <packing>
                     <property name="left_attach">1</property>
-                    <property name="top_attach">2</property>
+                    <property name="top_attach">3</property>
                     <property name="width">1</property>
                     <property name="height">1</property>
                   </packing>
@@ -2660,13 +2649,13 @@ With bug reports, either send yours to <a href="mailto:aghermann-users at lists.
                   </object>
                   <packing>
                     <property name="left_attach">1</property>
-                    <property name="top_attach">1</property>
+                    <property name="top_attach">2</property>
                     <property name="width">1</property>
                     <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkEntry" id="eSubjectDetailsName">
+                  <object class="GtkEntry" id="eSubjectDetailsFullName">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="has_focus">True</property>
@@ -2677,7 +2666,7 @@ With bug reports, either send yours to <a href="mailto:aghermann-users at lists.
                   </object>
                   <packing>
                     <property name="left_attach">1</property>
-                    <property name="top_attach">0</property>
+                    <property name="top_attach">1</property>
                     <property name="width">1</property>
                     <property name="height">1</property>
                   </packing>
@@ -2687,13 +2676,13 @@ With bug reports, either send yours to <a href="mailto:aghermann-users at lists.
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <property name="xalign">1</property>
-                    <property name="label" translatable="yes">_Comment:</property>
+                    <property name="label" translatable="yes">Com_ment:</property>
                     <property name="use_underline">True</property>
                     <property name="mnemonic_widget">eSubjectDetailsComment</property>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
-                    <property name="top_attach">3</property>
+                    <property name="top_attach">4</property>
                     <property name="width">1</property>
                     <property name="height">1</property>
                   </packing>
@@ -2710,7 +2699,7 @@ With bug reports, either send yours to <a href="mailto:aghermann-users at lists.
                   </object>
                   <packing>
                     <property name="left_attach">1</property>
-                    <property name="top_attach">3</property>
+                    <property name="top_attach">4</property>
                     <property name="width">1</property>
                     <property name="height">1</property>
                   </packing>
@@ -2723,7 +2712,7 @@ With bug reports, either send yours to <a href="mailto:aghermann-users at lists.
                   </object>
                   <packing>
                     <property name="left_attach">2</property>
-                    <property name="top_attach">2</property>
+                    <property name="top_attach">3</property>
                     <property name="width">1</property>
                     <property name="height">1</property>
                   </packing>
@@ -2737,6 +2726,42 @@ With bug reports, either send yours to <a href="mailto:aghermann-users at lists.
                 <child>
                   <placeholder/>
                 </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <object class="GtkEntry" id="eSubjectDetailsShortName">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="can_default">True</property>
+                    <property name="invisible_char">•</property>
+                    <property name="activates_default">True</property>
+                    <property name="invisible_char_set">True</property>
+                    <property name="caps_lock_warning">False</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="label3">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">1</property>
+                    <property name="label" translatable="yes">_Short name:</property>
+                    <property name="use_underline">True</property>
+                    <property name="mnemonic_widget">eSubjectDetailsFullName</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>
               </object>
               <packing>
                 <property name="expand">False</property>
diff --git a/data/mw.glade b/data/mw.glade
index b179040..a33a960 100644
--- a/data/mw.glade
+++ b/data/mw.glade
@@ -4379,7 +4379,7 @@ dragging individual signals with <i>Alt</i>.</small></property
                                                     <property name="can_focus">False</property>
                                                     <property name="valign">start</property>
                                                     <property name="border_width">10</property>
-                                                    <property name="n_rows">6</property>
+                                                    <property name="n_rows">9</property>
                                                     <property name="n_columns">2</property>
                                                     <child>
                                                       <object class="GtkLabel" id="label100">
@@ -4576,6 +4576,83 @@ dragging individual signals with <i>Alt</i>.</small></property
                                                         <property name="x_padding">5</property>
                                                       </packing>
                                                     </child>
+                                                    <child>
+                                                      <object class="GtkColorButton" id="bColourSFPhasicSpindle">
+                                                        <property name="visible">True</property>
+                                                        <property name="can_focus">True</property>
+                                                        <property name="receives_default">True</property>
+                                                        <property name="relief">none</property>
+                                                        <property name="use_alpha">True</property>
+                                                        <property name="title" translatable="yes">Labels (scoring facility)</property>
+                                                        <property name="color">#adad7f7fa8a8</property>
+                                                      </object>
+                                                      <packing>
+                                                        <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="GtkColorButton" id="bColourSFPhasicKComplex">
+                                                        <property name="visible">True</property>
+                                                        <property name="can_focus">True</property>
+                                                        <property name="receives_default">True</property>
+                                                        <property name="relief">none</property>
+                                                        <property name="use_alpha">True</property>
+                                                        <property name="title" translatable="yes">Labels (scoring facility)</property>
+                                                        <property name="color">#e9e9b9b96e6e</property>
+                                                      </object>
+                                                      <packing>
+                                                        <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="GtkLabel" id="label68">
+                                                        <property name="visible">True</property>
+                                                        <property name="can_focus">False</property>
+                                                        <property name="xalign">0</property>
+                                                        <property name="label" translatable="yes">Spindle</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>
+                                                        <property name="y_options">GTK_FILL</property>
+                                                        <property name="x_padding">5</property>
+                                                      </packing>
+                                                    </child>
+                                                    <child>
+                                                      <object class="GtkLabel" id="label97">
+                                                        <property name="visible">True</property>
+                                                        <property name="can_focus">False</property>
+                                                        <property name="xalign">0</property>
+                                                        <property name="label" translatable="yes">K-complex</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>
+                                                        <property name="y_options">GTK_FILL</property>
+                                                        <property name="x_padding">5</property>
+                                                      </packing>
+                                                    </child>
+                                                    <child>
+                                                      <object class="GtkSeparator" id="separator16">
+                                                        <property name="visible">True</property>
+                                                        <property name="can_focus">False</property>
+                                                      </object>
+                                                      <packing>
+                                                        <property name="right_attach">2</property>
+                                                        <property name="top_attach">6</property>
+                                                        <property name="bottom_attach">7</property>
+                                                      </packing>
+                                                    </child>
                                                   </object>
                                                   <packing>
                                                     <property name="position">3</property>
@@ -7118,6 +7195,12 @@ dragging individual signals with <i>Alt</i>.</small></property
                                     <child>
                                       <placeholder/>
                                     </child>
+                                    <child>
+                                      <placeholder/>
+                                    </child>
+                                    <child>
+                                      <placeholder/>
+                                    </child>
                                   </object>
                                 </child>
                                 <child>
diff --git a/data/sf-artifacts-simple.glade b/data/sf-artifacts-simple.glade
new file mode 100644
index 0000000..97a16cd
--- /dev/null
+++ b/data/sf-artifacts-simple.glade
@@ -0,0 +1,233 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.0 -->
+  <object class="GtkAdjustment" id="jSFADSMinFlatRegionSize">
+    <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="jSFADSPad">
+    <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="wSFADS">
+    <property name="can_focus">False</property>
+    <property name="border_width">10</property>
+    <property name="title" translatable="yes">Global filters</property>
+    <property name="modal">True</property>
+    <property name="window_position">mouse</property>
+    <property name="destroy_with_parent">True</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="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">5</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">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="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">2</property>
+                <property name="bottom_attach">3</property>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options">GTK_FILL</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="lFilterCaption1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes"><b><big>Flat signal 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="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">1</property>
+                <property name="bottom_attach">2</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkSeparator" id="separator13">
+                <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="right_attach">3</property>
+                <property name="top_attach">4</property>
+                <property name="bottom_attach">5</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkSpinButton" id="eSFADSMinFlatRegionSize">
+                <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">jSFADSMinFlatRegionSize</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="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">2</property>
+                <property name="bottom_attach">3</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">3</property>
+                <property name="bottom_attach">4</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkSpinButton" id="eSFADSPad">
+                <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">jSFADSPad</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>
+          </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/data/sf-artifacts.glade b/data/sf-artifacts.glade
index 53d9bed..b1470e9 100644
--- a/data/sf-artifacts.glade
+++ b/data/sf-artifacts.glade
@@ -1,13 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
-  <object class="GtkAdjustment" id="jSFADUpperThr">
-    <property name="lower">1</property>
-    <property name="upper">30</property>
-    <property name="value">9</property>
-    <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>
@@ -87,18 +80,12 @@
     <property name="step_increment">1</property>
     <property name="page_increment">2</property>
   </object>
-  <object class="GtkAdjustment" id="jSFSimpleArtifactDetectionMinFlatRegionSize">
-    <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="jSFSimpleArtifactDetectionPad">
-    <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 class="GtkAdjustment" id="jSFADUpperThr">
+    <property name="lower">1</property>
+    <property name="upper">30</property>
+    <property name="value">9</property>
+    <property name="step_increment">0.5</property>
+    <property name="page_increment">2</property>
   </object>
   <object class="GtkDialog" id="wSFAD">
     <property name="can_focus">False</property>
@@ -1174,222 +1161,6 @@
       <action-widget response="-5">button9</action-widget>
     </action-widgets>
   </object>
-  <object class="GtkDialog" id="wSFSimpleArtifactDetectionParams">
-    <property name="can_focus">False</property>
-    <property name="border_width">10</property>
-    <property name="title" translatable="yes">Global filters</property>
-    <property name="modal">True</property>
-    <property name="window_position">mouse</property>
-    <property name="destroy_with_parent">True</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="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">5</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">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="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">2</property>
-                <property name="bottom_attach">3</property>
-                <property name="x_options">GTK_FILL</property>
-                <property name="y_options">GTK_FILL</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="lFilterCaption1">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xalign">0</property>
-                <property name="label" translatable="yes"><b><big>Flat signal 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="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">1</property>
-                <property name="bottom_attach">2</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkSeparator" id="separator13">
-                <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="right_attach">3</property>
-                <property name="top_attach">4</property>
-                <property name="bottom_attach">5</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkSpinButton" id="eSFSimpleArtifactDetectionMinFlatRegionSize">
-                <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">jSFSimpleArtifactDetectionMinFlatRegionSize</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="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">2</property>
-                <property name="bottom_attach">3</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">3</property>
-                <property name="bottom_attach">4</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkSpinButton" id="eSFSimpleArtifactDetectionPad">
-                <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">jSFSimpleArtifactDetectionPad</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>
-          </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>
   <object class="GtkSizeGroup" id="zSFADEstimateEControls">
     <widgets>
       <widget name="label37"/>
diff --git a/data/sf-filters.glade b/data/sf-filters.glade
new file mode 100644
index 0000000..26d78a6
--- /dev/null
+++ b/data/sf-filters.glade
@@ -0,0 +1,405 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.0 -->
+  <object class="GtkAdjustment" id="jSFFilterHighPassCutoff">
+    <property name="upper">100</property>
+    <property name="step_increment">0.25</property>
+    <property name="page_increment">1</property>
+  </object>
+  <object class="GtkAdjustment" id="jSFFilterHighPassOrder">
+    <property name="upper">5</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
+  <object class="GtkAdjustment" id="jSFFilterLowPassCutoff">
+    <property name="upper">100</property>
+    <property name="step_increment">0.25</property>
+    <property name="page_increment">1</property>
+  </object>
+  <object class="GtkAdjustment" id="jSFFilterLowPassOrder">
+    <property name="upper">5</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
+  <object class="GtkListStore" id="mSFFilterNotchFilter">
+    <columns>
+      <!-- column-name type -->
+      <column type="gchararray"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0" translatable="yes">none</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">at 50 Hz</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">at 60 Hz</col>
+      </row>
+    </data>
+  </object>
+  <object class="GtkDialog" id="wSFFilters">
+    <property name="can_focus">False</property>
+    <property name="border_width">10</property>
+    <property name="title" translatable="yes">High- and Low-pass filters</property>
+    <property name="modal">True</property>
+    <property name="window_position">mouse</property>
+    <property name="destroy_with_parent">True</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-vbox12">
+        <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_area12">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="bSFFilterCancel">
+                <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="bSFFilterOK">
+                <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="table1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="border_width">10</property>
+            <property name="n_rows">6</property>
+            <property name="n_columns">5</property>
+            <property name="row_spacing">10</property>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <object class="GtkSpinButton" id="eSFFilterLowPassCutoff">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="has_frame">False</property>
+                <property name="invisible_char">•</property>
+                <property name="activates_default">True</property>
+                <property name="xalign">1</property>
+                <property name="overwrite_mode">True</property>
+                <property name="invisible_char_set">True</property>
+                <property name="primary_icon_activatable">False</property>
+                <property name="secondary_icon_activatable">False</property>
+                <property name="adjustment">jSFFilterLowPassCutoff</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">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="label15">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">1</property>
+                <property name="xpad">10</property>
+                <property name="label" translatable="yes">Low pass:</property>
+              </object>
+              <packing>
+                <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="label16">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">1</property>
+                <property name="xpad">10</property>
+                <property name="label" translatable="yes">High pass:</property>
+              </object>
+              <packing>
+                <property name="top_attach">2</property>
+                <property name="bottom_attach">3</property>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options">GTK_FILL</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label17">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">0</property>
+                <property name="xpad">5</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">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="label18">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">0</property>
+                <property name="xpad">5</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>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options">GTK_FILL</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label19">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">1</property>
+                <property name="xpad">10</property>
+                <property name="label" translatable="yes">Order:</property>
+              </object>
+              <packing>
+                <property name="left_attach">3</property>
+                <property name="right_attach">4</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="GtkSpinButton" id="eSFFilterLowPassOrder">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="has_frame">False</property>
+                <property name="invisible_char">•</property>
+                <property name="activates_default">True</property>
+                <property name="xalign">1</property>
+                <property name="overwrite_mode">True</property>
+                <property name="invisible_char_set">True</property>
+                <property name="primary_icon_activatable">False</property>
+                <property name="secondary_icon_activatable">False</property>
+                <property name="adjustment">jSFFilterLowPassOrder</property>
+                <property name="snap_to_ticks">True</property>
+                <property name="numeric">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">4</property>
+                <property name="right_attach">5</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="label20">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">1</property>
+                <property name="xpad">10</property>
+                <property name="label" translatable="yes">Order:</property>
+              </object>
+              <packing>
+                <property name="left_attach">3</property>
+                <property name="right_attach">4</property>
+                <property name="top_attach">2</property>
+                <property name="bottom_attach">3</property>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options">GTK_FILL</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkSpinButton" id="eSFFilterHighPassOrder">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="tooltip_markup" translatable="yes">A value of 0 disables filter</property>
+                <property name="has_frame">False</property>
+                <property name="invisible_char">•</property>
+                <property name="activates_default">True</property>
+                <property name="xalign">1</property>
+                <property name="overwrite_mode">True</property>
+                <property name="invisible_char_set">True</property>
+                <property name="primary_icon_activatable">False</property>
+                <property name="secondary_icon_activatable">False</property>
+                <property name="adjustment">jSFFilterHighPassOrder</property>
+                <property name="snap_to_ticks">True</property>
+                <property name="numeric">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">4</property>
+                <property name="right_attach">5</property>
+                <property name="top_attach">2</property>
+                <property name="bottom_attach">3</property>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options">GTK_FILL</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="lSFFilterCaption">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">0</property>
+                <property name="use_markup">True</property>
+              </object>
+              <packing>
+                <property name="right_attach">5</property>
+                <property name="y_options">GTK_SHRINK</property>
+                <property name="y_padding">4</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label10">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">1</property>
+                <property name="xpad">10</property>
+                <property name="label" translatable="yes">Notch filter:</property>
+              </object>
+              <packing>
+                <property name="top_attach">4</property>
+                <property name="bottom_attach">5</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkComboBox" id="eSFFilterNotchFilter">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="valign">center</property>
+                <property name="model">mSFFilterNotchFilter</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">3</property>
+                <property name="top_attach">4</property>
+                <property name="bottom_attach">5</property>
+                <property name="y_options">GTK_FILL</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkSeparator" id="separator10">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+              </object>
+              <packing>
+                <property name="right_attach">5</property>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkSeparator" id="separator19">
+                <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="right_attach">5</property>
+                <property name="top_attach">5</property>
+                <property name="bottom_attach">6</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkSpinButton" id="eSFFilterHighPassCutoff">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="tooltip_markup" translatable="yes">If both cutoffs are >0, use band-pass</property>
+                <property name="has_frame">False</property>
+                <property name="invisible_char">•</property>
+                <property name="activates_default">True</property>
+                <property name="xalign">1</property>
+                <property name="overwrite_mode">True</property>
+                <property name="invisible_char_set">True</property>
+                <property name="primary_icon_activatable">False</property>
+                <property name="secondary_icon_activatable">False</property>
+                <property name="adjustment">jSFFilterHighPassCutoff</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">2</property>
+                <property name="bottom_attach">3</property>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options">GTK_FILL</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">bSFFilterCancel</action-widget>
+      <action-widget response="-5">bSFFilterOK</action-widget>
+    </action-widgets>
+  </object>
+  <object class="GtkSizeGroup" id="sizegroup1">
+    <widgets>
+      <widget name="cSFICAModeContainer"/>
+      <widget name="cSFScoringModeContainer"/>
+    </widgets>
+  </object>
+</interface>
diff --git a/data/sf-patterns.glade b/data/sf-patterns.glade
index 31201bb..6e7d7af 100644
--- a/data/sf-patterns.glade
+++ b/data/sf-patterns.glade
@@ -1,6 +1,85 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
+  <object class="GtkMenu" id="iiSFFDField">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <child>
+      <object class="GtkCheckMenuItem" id="iSFFDFieldDrawMatchIndex">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Match index</property>
+        <property name="use_underline">True</property>
+        <property name="active">True</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkMenuItem" id="iiSFFDFieldProfileTypes">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Profile type</property>
+        <property name="use_underline">True</property>
+        <child type="submenu">
+          <object class="GtkMenu" id="menu1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkRadioMenuItem" id="iSFFDFieldProfileTypeRaw">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">_Raw</property>
+                <property name="use_underline">True</property>
+                <property name="active">True</property>
+                <property name="draw_as_radio">True</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkSeparatorMenuItem" id="separator">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkRadioMenuItem" id="iSFFDFieldProfileTypePSD">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">_PSD</property>
+                <property name="use_underline">True</property>
+                <property name="draw_as_radio">True</property>
+                <property name="group">iSFFDFieldProfileTypeRaw</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkRadioMenuItem" id="iSFFDFieldProfileTypeMC">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">µ_C</property>
+                <property name="use_underline">True</property>
+                <property name="draw_as_radio">True</property>
+                <property name="group">iSFFDFieldProfileTypeRaw</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkRadioMenuItem" id="iSFFDFieldProfileTypeSWU">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">SW_U</property>
+                <property name="use_underline">True</property>
+                <property name="draw_as_radio">True</property>
+                <property name="group">iSFFDFieldProfileTypeRaw</property>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </object>
+  <object class="GtkAdjustment" id="jSFFDBandPassFrom">
+    <property name="upper">48</property>
+    <property name="value">0.25</property>
+    <property name="step_increment">0.25</property>
+    <property name="page_increment">1</property>
+  </object>
   <object class="GtkAdjustment" id="jSFFDBandPassOrder">
     <property name="lower">1</property>
     <property name="upper">5</property>
@@ -9,7 +88,7 @@
     <property name="page_increment">10</property>
   </object>
   <object class="GtkAdjustment" id="jSFFDBandPassUpto">
-    <property name="upper">100</property>
+    <property name="upper">50</property>
     <property name="value">1.5</property>
     <property name="step_increment">0.25</property>
     <property name="page_increment">1</property>
@@ -67,30 +146,19 @@
     <property name="step_increment">0.01</property>
     <property name="page_increment">5</property>
   </object>
-  <object class="GtkMenu" id="iiSFFDField">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
-    <child>
-      <object class="GtkMenuItem" id="menuitem4">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="label" translatable="yes">menuitem4</property>
-        <property name="use_underline">True</property>
-      </object>
-    </child>
-  </object>
-  <object class="GtkAdjustment" id="jSFFDBandPassFrom">
-    <property name="upper">8</property>
-    <property name="value">0.25</property>
-    <property name="step_increment">0.25</property>
-    <property name="page_increment">1</property>
+  <object class="GtkAdjustment" id="jSFFDIncrement">
+    <property name="lower">0.01</property>
+    <property name="upper">0.5</property>
+    <property name="value">0.050000000000000003</property>
+    <property name="step_increment">0.01</property>
+    <property name="page_increment">0.10000000000000001</property>
   </object>
   <object class="GtkDialog" id="wSFFD">
     <property name="can_focus">False</property>
     <property name="border_width">10</property>
     <property name="title" translatable="yes">Find/manage patterns</property>
     <property name="default_width">800</property>
-    <property name="default_height">500</property>
+    <property name="default_height">570</property>
     <property name="destroy_with_parent">True</property>
     <property name="type_hint">normal</property>
     <property name="skip_taskbar_hint">True</property>
@@ -133,16 +201,13 @@
               <object class="GtkBox" id="box12">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="halign">start</property>
-                <property name="valign">end</property>
                 <property name="orientation">vertical</property>
                 <property name="homogeneous">True</property>
                 <child>
                   <object class="GtkTable" id="cSFFDSearchButton">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="halign">start</property>
-                    <property name="n_columns">3</property>
+                    <property name="n_columns">6</property>
                     <child>
                       <object class="GtkButton" id="bSFFDSearch">
                         <property name="label" translatable="yes">Search</property>
@@ -162,7 +227,7 @@
                         <property name="can_focus">False</property>
                         <property name="xalign">0</property>
                         <property name="xpad">5</property>
-                        <property name="label" translatable="yes"> in channel </property>
+                        <property name="label" translatable="yes"> in </property>
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
@@ -175,7 +240,6 @@
                       <object class="GtkComboBox" id="eSFFDChannel">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="halign">end</property>
                       </object>
                       <packing>
                         <property name="left_attach">2</property>
@@ -184,6 +248,50 @@
                         <property name="y_options"/>
                       </packing>
                     </child>
+                    <child>
+                      <object class="GtkLabel" id="label1">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">, dt </property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">3</property>
+                        <property name="right_attach">4</property>
+                        <property name="x_options"/>
+                        <property name="y_options"/>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkSpinButton" id="eSFFDIncrement">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="invisible_char">•</property>
+                        <property name="xalign">1</property>
+                        <property name="overwrite_mode">True</property>
+                        <property name="adjustment">jSFFDIncrement</property>
+                        <property name="digits">2</property>
+                        <property name="numeric">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">4</property>
+                        <property name="right_attach">5</property>
+                        <property name="x_options"/>
+                        <property name="y_options"/>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label2">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes"> sec</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">5</property>
+                        <property name="right_attach">6</property>
+                        <property name="x_options"/>
+                        <property name="y_options"/>
+                      </packing>
+                    </child>
                   </object>
                   <packing>
                     <property name="expand">False</property>
@@ -195,14 +303,18 @@
                   <object class="GtkTable" id="cSFFDAgainButton">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="halign">start</property>
+                    <property name="halign">end</property>
                     <child>
                       <object class="GtkButton" id="bSFFDAgain">
-                        <property name="label" translatable="yes">Modify pattern</property>
+                        <property name="label" translatable="yes">Modify</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">True</property>
                       </object>
+                      <packing>
+                        <property name="x_options"/>
+                        <property name="y_options"/>
+                      </packing>
                     </child>
                   </object>
                   <packing>
@@ -220,7 +332,7 @@
                       <object class="GtkLabel" id="label50">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="xalign">0</property>
+                        <property name="xalign">1</property>
                         <property name="label" translatable="yes">Searching …</property>
                         <attributes>
                           <attribute name="style" value="italic"/>
@@ -295,6 +407,7 @@
                       <packing>
                         <property name="expand">False</property>
                         <property name="fill">True</property>
+                        <property name="pack_type">end</property>
                         <property name="position">0</property>
                       </packing>
                     </child>
@@ -1083,6 +1196,7 @@ on individual parameters</property>
                     <property name="can_focus">False</property>
                     <child>
                       <object class="GtkScrolledWindow" id="swSFFDThing">
+                        <property name="height_request">220</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="shadow_type">in</property>
@@ -1096,26 +1210,52 @@ on individual parameters</property>
                                 <property name="visible">True</property>
                                 <property name="app_paintable">True</property>
                                 <property name="can_focus">False</property>
-                                <property name="events">GDK_STRUCTURE_MASK | GDK_SCROLL_MASK</property>
+                                <property name="events">GDK_BUTTON_PRESS_MASK | GDK_STRUCTURE_MASK | GDK_SCROLL_MASK</property>
                               </object>
                             </child>
                           </object>
                         </child>
                       </object>
                       <packing>
-                        <property name="expand">True</property>
+                        <property name="expand">False</property>
                         <property name="fill">True</property>
                         <property name="padding">2</property>
                         <property name="position">1</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkLabel" id="lSFFDParametersBrief">
+                      <object class="GtkBox" id="box1">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="xalign">0</property>
-                        <property name="xpad">5</property>
-                        <property name="ypad">3</property>
+                        <property name="margin_top">5</property>
+                        <property name="margin_bottom">5</property>
+                        <property name="spacing">3</property>
+                        <child>
+                          <object class="GtkLabel" id="lSFFDParametersBrief">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="hexpand">True</property>
+                            <property name="xalign">0</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkLabel" id="lSFFDFoundInfo">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="hexpand">True</property>
+                            <property name="xalign">1</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
                       </object>
                       <packing>
                         <property name="expand">False</property>
@@ -1125,6 +1265,7 @@ on individual parameters</property>
                     </child>
                     <child>
                       <object class="GtkScrolledWindow" id="swSFFDField">
+                        <property name="height_request">180</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="shadow_type">in</property>
@@ -1143,22 +1284,9 @@ on individual parameters</property>
                         </child>
                       </object>
                       <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
-                        <property name="position">2</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="lSFFDFoundInfo">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="xalign">1</property>
-                        <property name="xpad">5</property>
-                      </object>
-                      <packing>
                         <property name="expand">False</property>
                         <property name="fill">True</property>
-                        <property name="position">4</property>
+                        <property name="position">2</property>
                       </packing>
                     </child>
                   </object>
@@ -1183,9 +1311,6 @@ on individual parameters</property>
           </packing>
         </child>
         <child>
-          <placeholder/>
-        </child>
-        <child>
           <object class="GtkSeparator" id="separator18">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
@@ -1195,7 +1320,7 @@ on individual parameters</property>
           <packing>
             <property name="expand">False</property>
             <property name="fill">True</property>
-            <property name="position">3</property>
+            <property name="position">2</property>
           </packing>
         </child>
       </object>
@@ -1368,7 +1493,7 @@ on individual parameters</property>
               </packing>
             </child>
             <child>
-              <object class="GtkButton" id="button3">
+              <object class="GtkButton" id="bSFFDPatternSaveOK">
                 <property name="label">gtk-ok</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
@@ -1397,16 +1522,18 @@ on individual parameters</property>
     </child>
     <action-widgets>
       <action-widget response="-6">button1</action-widget>
-      <action-widget response="-5">button3</action-widget>
+      <action-widget response="-5">bSFFDPatternSaveOK</action-widget>
     </action-widgets>
   </object>
   <object class="GtkSizeGroup" id="zButton">
+    <property name="mode">both</property>
     <widgets>
       <widget name="bSFFDSearch"/>
       <widget name="bSFFDAgain"/>
       <widget name="bSFFDProfileRevert"/>
       <widget name="bSFFDProfileSave"/>
       <widget name="bSFFDProfileDiscard"/>
+      <widget name="eSFFDIncrement"/>
     </widgets>
   </object>
   <object class="GtkSizeGroup" id="zSFFDControls"/>
diff --git a/data/sf.glade b/data/sf.glade
index 1fca721..41c8a12 100644
--- a/data/sf.glade
+++ b/data/sf.glade
@@ -573,26 +573,6 @@
       </object>
     </child>
   </object>
-  <object class="GtkAdjustment" id="jSFFilterHighPassCutoff">
-    <property name="upper">100</property>
-    <property name="step_increment">0.25</property>
-    <property name="page_increment">1</property>
-  </object>
-  <object class="GtkAdjustment" id="jSFFilterHighPassOrder">
-    <property name="upper">5</property>
-    <property name="step_increment">1</property>
-    <property name="page_increment">10</property>
-  </object>
-  <object class="GtkAdjustment" id="jSFFilterLowPassCutoff">
-    <property name="upper">100</property>
-    <property name="step_increment">0.25</property>
-    <property name="page_increment">1</property>
-  </object>
-  <object class="GtkAdjustment" id="jSFFilterLowPassOrder">
-    <property name="upper">5</property>
-    <property name="step_increment">1</property>
-    <property name="page_increment">10</property>
-  </object>
   <object class="GtkAdjustment" id="jSFICAEigVecFirst">
     <property name="lower">1</property>
     <property name="upper">100</property>
@@ -664,23 +644,6 @@
     <property name="step_increment">1</property>
     <property name="page_increment">10</property>
   </object>
-  <object class="GtkListStore" id="mSFFilterNotchFilter">
-    <columns>
-      <!-- column-name type -->
-      <column type="gchararray"/>
-    </columns>
-    <data>
-      <row>
-        <col id="0" translatable="yes">none</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">at 50 Hz</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">at 60 Hz</col>
-      </row>
-    </data>
-  </object>
   <object class="GtkListStore" id="mSFICAApproach">
     <columns>
       <!-- column-name type -->
@@ -2311,7 +2274,10 @@ skew:	𝑔(𝑢) = 𝑢2</property>
   <object class="GtkDialog" id="wSFAnnotationLabel">
     <property name="can_focus">False</property>
     <property name="border_width">5</property>
+    <property name="title" translatable="yes">New annotation</property>
+    <property name="modal">True</property>
     <property name="window_position">mouse</property>
+    <property name="destroy_with_parent">True</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"/>
@@ -2416,7 +2382,10 @@ skew:	𝑔(𝑢) = 𝑢2</property>
   <object class="GtkDialog" id="wSFAnnotationSelector">
     <property name="can_focus">False</property>
     <property name="border_width">5</property>
+    <property name="title" translatable="yes">Select annotation</property>
+    <property name="modal">True</property>
     <property name="window_position">mouse</property>
+    <property name="destroy_with_parent">True</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"/>
@@ -2479,7 +2448,7 @@ skew:	𝑔(𝑢) = 𝑢2</property>
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="xalign">0.0099999997764825821</property>
-                <property name="label" translatable="yes">_Select annotation:</property>
+                <property name="label" translatable="yes">_Annotations under pointer:</property>
                 <property name="use_underline">True</property>
                 <property name="mnemonic_widget">eSFAnnotationLabel</property>
               </object>
@@ -2514,370 +2483,12 @@ skew:	𝑔(𝑢) = 𝑢2</property>
       <action-widget response="-5">button6</action-widget>
     </action-widgets>
   </object>
-  <object class="GtkDialog" id="wSFFilters">
-    <property name="can_focus">False</property>
-    <property name="border_width">10</property>
-    <property name="title" translatable="yes">High- and Low-pass filters</property>
-    <property name="modal">True</property>
-    <property name="window_position">mouse</property>
-    <property name="destroy_with_parent">True</property>
-    <property name="type_hint">dialog</property>
-    <property name="transient_for">wSF</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-vbox12">
-        <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_area12">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="layout_style">end</property>
-            <child>
-              <object class="GtkButton" id="bSFFilterCancel">
-                <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="bSFFilterOK">
-                <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="table1">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="border_width">10</property>
-            <property name="n_rows">6</property>
-            <property name="n_columns">5</property>
-            <property name="row_spacing">10</property>
-            <child>
-              <placeholder/>
-            </child>
-            <child>
-              <placeholder/>
-            </child>
-            <child>
-              <object class="GtkSpinButton" id="eSFFilterLowPassCutoff">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="has_frame">False</property>
-                <property name="invisible_char">•</property>
-                <property name="activates_default">True</property>
-                <property name="xalign">1</property>
-                <property name="overwrite_mode">True</property>
-                <property name="invisible_char_set">True</property>
-                <property name="primary_icon_activatable">False</property>
-                <property name="secondary_icon_activatable">False</property>
-                <property name="adjustment">jSFFilterLowPassCutoff</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">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="GtkSpinButton" id="eSFFilterHighPassCutoff">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="tooltip_markup" translatable="yes">If both cutoffs are >0, use band-pass</property>
-                <property name="has_frame">False</property>
-                <property name="invisible_char">•</property>
-                <property name="activates_default">True</property>
-                <property name="xalign">1</property>
-                <property name="overwrite_mode">True</property>
-                <property name="invisible_char_set">True</property>
-                <property name="primary_icon_activatable">False</property>
-                <property name="secondary_icon_activatable">False</property>
-                <property name="adjustment">jSFFilterHighPassCutoff</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">2</property>
-                <property name="bottom_attach">3</property>
-                <property name="x_options">GTK_FILL</property>
-                <property name="y_options">GTK_FILL</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label15">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xalign">1</property>
-                <property name="xpad">10</property>
-                <property name="label" translatable="yes">Low pass:</property>
-              </object>
-              <packing>
-                <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="label16">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xalign">1</property>
-                <property name="xpad">10</property>
-                <property name="label" translatable="yes">High pass:</property>
-              </object>
-              <packing>
-                <property name="top_attach">2</property>
-                <property name="bottom_attach">3</property>
-                <property name="x_options">GTK_FILL</property>
-                <property name="y_options">GTK_FILL</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label17">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xalign">0</property>
-                <property name="xpad">5</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">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="label18">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xalign">0</property>
-                <property name="xpad">5</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>
-                <property name="x_options">GTK_FILL</property>
-                <property name="y_options">GTK_FILL</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label19">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xalign">1</property>
-                <property name="xpad">10</property>
-                <property name="label" translatable="yes">Order:</property>
-              </object>
-              <packing>
-                <property name="left_attach">3</property>
-                <property name="right_attach">4</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="GtkSpinButton" id="eSFFilterLowPassOrder">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="has_frame">False</property>
-                <property name="invisible_char">•</property>
-                <property name="activates_default">True</property>
-                <property name="xalign">1</property>
-                <property name="overwrite_mode">True</property>
-                <property name="invisible_char_set">True</property>
-                <property name="primary_icon_activatable">False</property>
-                <property name="secondary_icon_activatable">False</property>
-                <property name="adjustment">jSFFilterLowPassOrder</property>
-                <property name="snap_to_ticks">True</property>
-                <property name="numeric">True</property>
-              </object>
-              <packing>
-                <property name="left_attach">4</property>
-                <property name="right_attach">5</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="label20">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xalign">1</property>
-                <property name="xpad">10</property>
-                <property name="label" translatable="yes">Order:</property>
-              </object>
-              <packing>
-                <property name="left_attach">3</property>
-                <property name="right_attach">4</property>
-                <property name="top_attach">2</property>
-                <property name="bottom_attach">3</property>
-                <property name="x_options">GTK_FILL</property>
-                <property name="y_options">GTK_FILL</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkSpinButton" id="eSFFilterHighPassOrder">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="tooltip_markup" translatable="yes">A value of 0 disables filter</property>
-                <property name="has_frame">False</property>
-                <property name="invisible_char">•</property>
-                <property name="activates_default">True</property>
-                <property name="xalign">1</property>
-                <property name="overwrite_mode">True</property>
-                <property name="invisible_char_set">True</property>
-                <property name="primary_icon_activatable">False</property>
-                <property name="secondary_icon_activatable">False</property>
-                <property name="adjustment">jSFFilterHighPassOrder</property>
-                <property name="snap_to_ticks">True</property>
-                <property name="numeric">True</property>
-              </object>
-              <packing>
-                <property name="left_attach">4</property>
-                <property name="right_attach">5</property>
-                <property name="top_attach">2</property>
-                <property name="bottom_attach">3</property>
-                <property name="x_options">GTK_FILL</property>
-                <property name="y_options">GTK_FILL</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="lSFFilterCaption">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xalign">0</property>
-                <property name="use_markup">True</property>
-              </object>
-              <packing>
-                <property name="right_attach">5</property>
-                <property name="y_options">GTK_SHRINK</property>
-                <property name="y_padding">4</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label10">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xalign">1</property>
-                <property name="xpad">10</property>
-                <property name="label" translatable="yes">Notch filter:</property>
-              </object>
-              <packing>
-                <property name="top_attach">4</property>
-                <property name="bottom_attach">5</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkComboBox" id="eSFFilterNotchFilter">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="valign">center</property>
-                <property name="model">mSFFilterNotchFilter</property>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="right_attach">3</property>
-                <property name="top_attach">4</property>
-                <property name="bottom_attach">5</property>
-                <property name="y_options">GTK_FILL</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkSeparator" id="separator10">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-              </object>
-              <packing>
-                <property name="right_attach">5</property>
-                <property name="top_attach">1</property>
-                <property name="bottom_attach">2</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkSeparator" id="separator19">
-                <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="right_attach">5</property>
-                <property name="top_attach">5</property>
-                <property name="bottom_attach">6</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">bSFFilterCancel</action-widget>
-      <action-widget response="-5">bSFFilterOK</action-widget>
-    </action-widgets>
-  </object>
   <object class="GtkDialog" id="wSFICAMatrix">
     <property name="can_focus">False</property>
     <property name="border_width">5</property>
     <property name="title" translatable="yes">Matrix</property>
     <property name="resizable">False</property>
+    <property name="modal">True</property>
     <property name="window_position">mouse</property>
     <property name="destroy_with_parent">True</property>
     <property name="type_hint">dialog</property>
diff --git a/src/common/alg.hh b/src/common/alg.hh
index b6f4301..9d7064f 100644
--- a/src/common/alg.hh
+++ b/src/common/alg.hh
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  common/alg.hh
  *         Project:  Aghermann
@@ -181,4 +180,7 @@ double sensible_scale_reduction_factor( double display_scale,
 
 #endif // _AGH_COMMON_ALG_H
 
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
diff --git a/src/common/fs.hh b/src/common/fs.hh
index cb9a99e..bfc3f90 100644
--- a/src/common/fs.hh
+++ b/src/common/fs.hh
@@ -1,11 +1,10 @@
-// ;-*-C++-*-
 /*
  *       File name:  common/fs.hh
  *         Project:  Aghermann
  *          Author:  Andrei Zavada <johnhommer at gmail.com>
  * Initial version:  2012-02-11
  *
- *         Purpose:  generic path handling utility
+ *         Purpose:  generic utilities for handling paths and files
  *
  *         License:  GPL
  */
@@ -55,9 +54,10 @@ template<class T>
 string
 dirname( const T& _filename)
 {
+	string pre = (_filename[0] == '/') ? "/" : "";
 	auto ee = agh::str::tokens( _filename, "/");
 	ee.pop_back();
-	return agh::str::join( ee, "/");
+	return pre + agh::str::join( ee, "/");
 }
 
 
@@ -83,7 +83,7 @@ mkdir_with_parents( const T& _dir)
 {
 	string dir (_dir);
 	DEF_UNIQUE_CHARP(_);
-	assert (asprintf( &_, "mkdir -p '%s'", dir.c_str()));
+	ASPRINTF( &_, "mkdir -p '%s'", dir.c_str());
 	return system( _);
 }
 
@@ -104,4 +104,7 @@ extern size_t __n_edf_files;
 
 #endif // _AGH_COMMON_FS_H
 
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
diff --git a/src/expdesign/primaries.cc b/src/expdesign/primaries.cc
index 6fbe451..f8131f5 100644
--- a/src/expdesign/primaries.cc
+++ b/src/expdesign/primaries.cc
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  expdesign/primaries.cc
  *         Project:  Aghermann
@@ -293,7 +292,7 @@ enumerate_subjects() const
 	list<string> recp;
 	for ( auto &G : groups )
 		for ( auto &J : G.second )
-			recp.push_back( J.name());
+			recp.push_back( J.short_name);
 	return recp;
 }
 
@@ -410,13 +409,12 @@ gender_sign( TGender g)
 agh::CSubject::
 CSubject (const string& dir,
 	  sid_type id)
-  : full_name (""),
+  : short_name (dir.substr( dir.rfind('/')+1)),
     gender (TGender::neuter),
     age (21),
     _status (0),
     _id (id),
-    _dir (dir),
-    _name (dir.substr( dir.rfind('/')+1))
+    _dir (dir)
 {
 	ifstream ifs (_dir + "/.subject_info");
 	char gender_char;
@@ -427,7 +425,7 @@ CSubject (const string& dir,
 	      ifs.good()) )
 		gender = (TGender)gender_char;
 	else
-		full_name = _name;
+		full_name = short_name;
 }
 
 
@@ -594,6 +592,7 @@ purge_cached_profiles()
 	return system( b);
 }
 
-
-
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
diff --git a/src/expdesign/primaries.hh b/src/expdesign/primaries.hh
index 94801b3..a3b30b0 100644
--- a/src/expdesign/primaries.hh
+++ b/src/expdesign/primaries.hh
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  expdesign/primaries.hh
  *         Project:  Aghermann
@@ -54,13 +53,12 @@ class CSubject {
 	static const char* gender_sign( TGender g);
 
     public:
-	string	full_name;
+	string	short_name,
+		full_name;
 	TGender	gender;
 	int	age;
 	string	comment;
 
-	sid_type           id() const	{ return _id; }
-	const char      *name() const	{ return _name.c_str(); };
 	const string&     dir() const   { return _dir; }
 
 	CSubject (const string& dir, sid_type id);
@@ -223,11 +221,11 @@ class CSubject {
 
 	bool operator==( const CSubject &o) const
 		{
-			return strcmp( name(), o.name()) == 0;
+			return short_name == o.short_name;
 		}
 	bool operator==( const string& n) const
 		{
-			return name() == n;
+			return short_name == n;
 		}
 	bool operator==( sid_type id) const
 		{
@@ -239,8 +237,7 @@ class CSubject {
 	sid_type
 		_id; // eventually to allow distinctly identifiable namesakes in different groups
 
-	string	_dir,
-		_name;
+	string	_dir;
 };
 
 
@@ -331,7 +328,7 @@ class CExpDesign {
 		{
 			map<string, CJGroup>::const_iterator G;
 			const CSubject& J = subject_by_x(j, &G);
-			return _session_dir + '/' + G->first + '/' + J.name();
+			return _session_dir + '/' + G->first + '/' + J.short_name;
 		}
 
       // scan tree: build all structures
@@ -540,4 +537,7 @@ assisted_score( agh::CSubject::SEpisode&);
 
 #endif
 
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
diff --git a/src/expdesign/recording.cc b/src/expdesign/recording.cc
index c97cabb..149e850 100644
--- a/src/expdesign/recording.cc
+++ b/src/expdesign/recording.cc
@@ -105,7 +105,7 @@ CProfile (CSubject& J, const string& d, const sigfile::SChannel& h,
 	_sim_start ((size_t)-1), _sim_end ((size_t)-1)
 {
 	if ( not J.have_session(d) or J.measurements.at(d).size() == 0 )
-		throw invalid_argument (string(J.name()) + " has no recordings in session " + d);
+		throw invalid_argument (J.short_name + " has no recordings in session " + d);
 
 	auto& EE = J.measurements.at(d).episodes;
 	for ( auto &E : EE )
diff --git a/src/expdesign/recording.hh b/src/expdesign/recording.hh
index bd217a6..a34fcee 100644
--- a/src/expdesign/recording.hh
+++ b/src/expdesign/recording.hh
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  expdesign/recording.hh
  *         Project:  Aghermann
@@ -287,4 +286,7 @@ course( const SProfileParamSet::MC& p)
 
 #endif
 
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
diff --git a/src/expdesign/tree-scanner.cc b/src/expdesign/tree-scanner.cc
index 3361c3a..d59c7b4 100644
--- a/src/expdesign/tree-scanner.cc
+++ b/src/expdesign/tree-scanner.cc
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  expdesign/tree-scanner.cc
  *         Project:  Aghermann
@@ -323,7 +322,7 @@ scan_tree( TMsmtCollectProgressIndicatorFun user_progress_fun)
 				if ( D.second.episodes.size() < n_episodes &&
 				     complete_episode_set.front() != D.second.episodes.begin()->name() ) { // the baseline is missing
 					log_message( "No Baseline episode in %s's %s: skip this session\n",
-						     J.name(), D.first.c_str());
+						     J.short_name.c_str(), D.first.c_str());
 					J.measurements.erase(D.first);
 					goto startover;
 				}
@@ -373,5 +372,7 @@ compute_profiles()
 	for_all_recordings( F, G, filter);
 }
 
-
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
diff --git a/src/ica/ica.hh b/src/ica/ica.hh
index 52ef4fc..f752459 100644
--- a/src/ica/ica.hh
+++ b/src/ica/ica.hh
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  ica/ica.hh
  *         Project:  Aghermann
@@ -10,8 +9,8 @@
  *         License:  GPL
  */
 
-#ifndef _ICA_HH
-#define _ICA_HH
+#ifndef _AGH_ICA_HH
+#define _AGH_ICA_HH
 
 #include <valarray>
 #include <vector>
@@ -134,6 +133,9 @@ class CFastICA {
 
 }
 
-#endif // _ICA_HH
+#endif // _AGH_ICA_HH
 
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
diff --git a/src/libsigfile/channel.cc b/src/libsigfile/channel.cc
index 1f8d5d7..c31d83a 100644
--- a/src/libsigfile/channel.cc
+++ b/src/libsigfile/channel.cc
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  libsigfile/channel.cc
  *         Project:  Aghermann
@@ -83,5 +82,8 @@ SChannel::operator<( const SChannel& rv) const
 		return strcmp( c_str(), rv.c_str()) < 0;
 }
 
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
 
-// eof
diff --git a/src/libsigfile/channel.hh b/src/libsigfile/channel.hh
index eedaa1c..4e89d23 100644
--- a/src/libsigfile/channel.hh
+++ b/src/libsigfile/channel.hh
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  libsigfile/channel.hh
  *         Project:  Aghermann
@@ -89,4 +88,8 @@ struct SChannel
 
 #endif
 
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
+
diff --git a/src/libsigfile/edf.cc b/src/libsigfile/edf.cc
index c4df842..d96a4ae 100644
--- a/src/libsigfile/edf.cc
+++ b/src/libsigfile/edf.cc
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  libsigfile/edf.cc
  *         Project:  Aghermann
@@ -186,6 +185,7 @@ CEDFFile (const char *fname_, int flags_)
 			} else
 				break;
 		}
+		H.annotations.sort();
 	}
 
       // filters
@@ -849,8 +849,8 @@ sigfile::CEDFFile::explain_edf_status( int status)
 }
 
 
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
 
-
-
-
-// eof
diff --git a/src/libsigfile/edf.hh b/src/libsigfile/edf.hh
index 8e7e704..f983a9c 100644
--- a/src/libsigfile/edf.hh
+++ b/src/libsigfile/edf.hh
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  libsigfile/edf.hh
  *         Project:  Aghermann
@@ -584,4 +583,8 @@ class CEDFFile
 
 #endif
 
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
+
diff --git a/src/libsigfile/edf.ii b/src/libsigfile/edf.ii
index c298cc7..ead7ed5 100644
--- a/src/libsigfile/edf.ii
+++ b/src/libsigfile/edf.ii
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  libsigfile/edf.ii
  *         Project:  Aghermann
@@ -84,7 +83,7 @@ get_region_filtered_( Th h,
       // artifacts
 	size_t this_samplerate = H.samples_per_record / data_record_size;
 	for ( auto &A : H.artifacts() ) {
-		if ( unlikely (A.a > smplz) )
+		if ( unlikely (A.a >= smplz) )
 			break;
 		size_t	run = A.z - A.a,
 			window = min( run, this_samplerate),
@@ -256,5 +255,8 @@ export_filtered_( Th h,
 		return -1;
 }
 
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
 
-// eof
diff --git a/src/libsigfile/forward-decls.hh b/src/libsigfile/forward-decls.hh
index 083c607..0db5dae 100644
--- a/src/libsigfile/forward-decls.hh
+++ b/src/libsigfile/forward-decls.hh
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  libsigfile/forward-decls.hh
  *         Project:  Aghermann
@@ -29,4 +28,8 @@ class CHypnogram;
 
 #endif // _SIGFILE_FORWARD_DECLS_H
 
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
+
diff --git a/src/libsigfile/page.cc b/src/libsigfile/page.cc
index 304641e..1c2b286 100644
--- a/src/libsigfile/page.cc
+++ b/src/libsigfile/page.cc
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  libsigfile/page.cc
  *         Project:  Aghermann
@@ -185,5 +184,8 @@ sigfile::CHypnogram::load_canonical( const char *fname,
 	return f.eof() ? 0 : 1;
 }
 
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
 
-// EOF
diff --git a/src/libsigfile/page.hh b/src/libsigfile/page.hh
index d9934b0..d9176ec 100644
--- a/src/libsigfile/page.hh
+++ b/src/libsigfile/page.hh
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  libsigfile/page.hh
  *         Project:  Aghermann
@@ -239,4 +238,8 @@ class CHypnogram {
 
 #endif
 
-// EOF
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
+
diff --git a/src/libsigfile/source-base.cc b/src/libsigfile/source-base.cc
index d409840..974dd23 100644
--- a/src/libsigfile/source-base.cc
+++ b/src/libsigfile/source-base.cc
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  libsigfile/source-base.cc
  *         Project:  Aghermann
@@ -130,4 +129,8 @@ CSource_base( CSource_base&& rv)
 }
 
 
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
+
diff --git a/src/libsigfile/source-base.hh b/src/libsigfile/source-base.hh
index cce8d3d..5fa0619 100644
--- a/src/libsigfile/source-base.hh
+++ b/src/libsigfile/source-base.hh
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  libsigfile/source-base.hh
  *         Project:  Aghermann
@@ -127,6 +126,10 @@ struct SAnnotation {
 		{
 			return span == rv.span && label == rv.label; // && origin == rv.origin;
 		}
+	bool operator<( const SAnnotation& rv) const
+		{
+			return span < rv.span;
+		}
 };
 
 inline void
@@ -135,6 +138,7 @@ mark_annotation( list<SAnnotation>& annotations,
 		 const char* label)
 {
 	annotations.emplace_back( aa, az, label);
+	annotations.sort();
 }
 
 
@@ -381,4 +385,8 @@ class CSource_base {
 
 #endif // _SIGFILE_SOURCE_BASE_H
 
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
+
diff --git a/src/libsigfile/source.cc b/src/libsigfile/source.cc
index 2877c2e..899b51d 100644
--- a/src/libsigfile/source.cc
+++ b/src/libsigfile/source.cc
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  libsigfile/source.cc
  *         Project:  Aghermann
@@ -98,6 +97,8 @@ sigfile::CSource::source_file_type( const char* fname)
 }
 
 
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
 
-
-// eof
diff --git a/src/libsigfile/source.hh b/src/libsigfile/source.hh
index 5b375df..3dab3eb 100644
--- a/src/libsigfile/source.hh
+++ b/src/libsigfile/source.hh
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  libsigfile/source.hh
  *         Project:  Aghermann
@@ -303,4 +302,8 @@ struct SNamedChannel {
 
 #endif // _AGH_SOURCE_H
 
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
+
diff --git a/src/metrics/mc-artifacts.hh b/src/metrics/mc-artifacts.hh
index 8228ae8..89ab522 100644
--- a/src/metrics/mc-artifacts.hh
+++ b/src/metrics/mc-artifacts.hh
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  metrics/mc-artifacts.hh
  *         Project:  Aghermann
@@ -11,8 +10,8 @@
  *         License:  GPL
  */
 
-#ifndef _METRICS_MC_ARTIFACTS_H
-#define _METRICS_MC_ARTIFACTS_H
+#ifndef _AGH_METRICS_MC_ARTIFACTS_H
+#define _AGH_METRICS_MC_ARTIFACTS_H
 
 #include <vector>
 #include <valarray>
@@ -77,6 +76,9 @@ estimate_E( const valarray<T>& sssu_diff,
 } // namespace metrics
 
 
-#endif // _METRICS_MC_ARTIFACTS_H
+#endif // _AGH_METRICS_MC_ARTIFACTS_H
 
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
diff --git a/src/metrics/page-metrics-base.hh b/src/metrics/page-metrics-base.hh
index 492eba6..8fba436 100644
--- a/src/metrics/page-metrics-base.hh
+++ b/src/metrics/page-metrics-base.hh
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  metrics/page-metrics-base.hh
  *         Project:  Aghermann
@@ -30,7 +29,7 @@ using namespace std;
 
 namespace metrics {
 
-enum class TType { invalid, psd, mc, swu };
+enum class TType { raw, psd, mc, swu };
 
 inline const char*
 __attribute__ ((pure))
@@ -185,6 +184,10 @@ class CProfile {
 
 } // namespace metrics
 
-#endif // _SIGFILE_PAGE_METRICS_BASE_H
+#endif // _METRICS_PAGE_METRICS_BASE_H
+
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
 
-// eof
diff --git a/src/model/achermann-tunable.hh b/src/model/achermann-tunable.hh
index 87d28b3..7a1324b 100644
--- a/src/model/achermann-tunable.hh
+++ b/src/model/achermann-tunable.hh
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  model/achermann-tunable.hh
  *         Project:  Aghermann
@@ -187,4 +186,7 @@ struct STunableSetWithState
 
 #endif
 
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
diff --git a/src/model/achermann.hh b/src/model/achermann.hh
index 55f4255..0d56212 100644
--- a/src/model/achermann.hh
+++ b/src/model/achermann.hh
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  model/achermann.hh
  *         Project:  Aghermann
@@ -137,4 +136,7 @@ _which_gc( size_t p) const // selects episode egc by page, or returns &gc if !AZ
 
 #endif
 
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
diff --git a/src/patterns/patterns.cc b/src/patterns/patterns.cc
index 34a0fe5..849c7f3 100644
--- a/src/patterns/patterns.cc
+++ b/src/patterns/patterns.cc
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  patterns/patterns.cc
  *         Project:  Aghermann
@@ -55,18 +54,30 @@ load_pattern( const char* fname) throw(invalid_argument)
 			     " %g %g %g %g"
 			     " %zu %zu %zu %zu\n"
 			     "--DATA--\n"
-			     :
-			     "%lg  %u %lg %lg  %lg %lg %u"
+			     : "%lg  %u %lg %lg  %lg %lg %u"
 			     " %lg %lg %lg %lg"
 			     " %zu %zu %zu %zu\n"
-			     "--DATA--\n"
-			     ,
+			     "--DATA--\n",
 			     &P.Pp.env_scope,
 			     &P.Pp.bwf_order, &P.Pp.bwf_ffrom, &P.Pp.bwf_fupto,
 			     &P.Pp.dzcdf_step, &P.Pp.dzcdf_sigma, &P.Pp.dzcdf_smooth,
 			     &get<0>(P.criteria), &get<1>(P.criteria), &get<2>(P.criteria), &get<3>(P.criteria),
 			     &P.samplerate, &P.context_before, &P.context_after,
-			     &full_sample) == 14 ) {
+			     &full_sample) == 15 ) {
+
+			if ( P.samplerate == 0 || P.samplerate > 4096 ||
+			     full_sample == 0 || full_sample > P.samplerate * 10 ||
+			     P.context_before > P.samplerate * 2 ||
+			     P.context_after > P.samplerate * 2 ||
+			     not P.Pp.sane() ) {
+				ASPRINTF( &buf, "load_pattern(\"%s\"): bogus data in header; "
+					  "removing file", fname);
+				fprintf( stderr, "%s\n", buf);
+				P.thing.resize( 0);
+				fclose( fd);
+				unlink( fname);
+				throw invalid_argument (buf);
+			}
 
 			P.thing.resize( full_sample);
 			for ( size_t i = 0; i < full_sample; ++i ) {
@@ -101,7 +112,9 @@ load_pattern( const char* fname) throw(invalid_argument)
 		throw invalid_argument (buf);
 	}
 
+	printf( "loaded pattern in %s\n", fname);
 	P.saved = true;
+	P.name = agh::str::tokens( fname, "/").back();
 	P.path = fname;
 	return P;
 }
@@ -115,6 +128,7 @@ save_pattern( SPattern<TFloat>& P, const char* fname)
 		fprintf( stderr, "save_pattern(\"%s\"): mkdir %s failed\n", fname, agh::fs::dirname(fname).c_str());
 		return -1;
 	}
+	printf( "saving pattern in %s\n", fname);
 
 	FILE *fd = fopen( fname, "w");
 	try {
@@ -174,7 +188,7 @@ load_patterns_from_location<TFloat>( const string& loc, pattern::TOrigin origin)
 		for ( int i = 0; i < total; ++i ) {
 			try {
 				ret.push_back(
-					load_pattern<TFloat>( eps[i]->d_name));
+					load_pattern<TFloat>( (loc + '/' + eps[i]->d_name).c_str()));
 				ret.back().origin = origin;
 			} catch (invalid_argument& ex) {
 				;
@@ -190,4 +204,7 @@ load_patterns_from_location<TFloat>( const string& loc, pattern::TOrigin origin)
 
 } // namespace pattern
 
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
diff --git a/src/patterns/patterns.hh b/src/patterns/patterns.hh
index 9cbb647..ef08894 100644
--- a/src/patterns/patterns.hh
+++ b/src/patterns/patterns.hh
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  sigproc/patterns.hh
  *         Project:  Aghermann
@@ -34,7 +33,7 @@ class CMatch
   : public tuple<T, T, T, T> {
     public:
 	CMatch ()
-	      : tuple<T, T, T, T> (NAN, NAN, NAN, NAN)
+	      : tuple<T, T, T, T> (.1, .1, .1, .1) // empirically ok default
 		{}
 
 	bool good_enough( const CMatch<T>& rv) const
@@ -44,7 +43,6 @@ class CMatch
 			       get<2>(*this) < get<2>(rv) &&
 			       get<3>(*this) < get<3>(rv);
 		}
-
 };
 
 template <typename T>
@@ -66,6 +64,17 @@ struct SPatternPPack {
 				dzcdf_sigma == rv.dzcdf_sigma &&
 				dzcdf_smooth == rv.dzcdf_smooth;
 		}
+	bool sane() const
+		{
+			return	env_scope > 0. && env_scope <= 1. &&
+				bwf_ffrom < bwf_fupto &&
+			        bwf_ffrom >= 0. && bwf_ffrom <= 50. &&
+				bwf_fupto >= 0. && bwf_fupto <= 50. &&
+				bwf_order > 0 && bwf_order <= 5 &&
+				dzcdf_step > 0. && dzcdf_step <= 1. &&
+				dzcdf_sigma > 0. && dzcdf_sigma <= 1. &&
+				dzcdf_smooth >= 0 && dzcdf_smooth <= 50;
+		}
 }; // keep fields in order, or edit ctor by initializer_list
 
 
@@ -178,6 +187,11 @@ struct SPattern {
 		Pp;
 	CMatch<T>
 		criteria;
+
+	bool operator==( const SPattern<T>& rv) const
+		{
+			return origin == rv.origin && name == rv.name;
+		}
 };
 
 
@@ -205,4 +219,8 @@ delete_pattern( const SPattern<T>&);
 
 #endif
 
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
+
diff --git a/src/sigproc/exstrom.hh b/src/sigproc/exstrom.hh
index 22dfe5f..4d4e239 100644
--- a/src/sigproc/exstrom.hh
+++ b/src/sigproc/exstrom.hh
@@ -1,11 +1,10 @@
-// ;-*-C++-*-
 /*
- *       File name:  libexstrom/exstrom.hh
+ *       File name:  sigproc/exstrom.hh
  *         Project:  Aghermann
- *          Author:  Andrei Zavada (johnhommer at gmail.com)
+ *          Author:  Andrei Zavada <johnhommer at gmail.com>
  * Initial version:  2010-12-26
  *
- *         Purpose:  various standalone signal processing functions
+ *         Purpose:  various signal processing functions
  *                   borrowed from exstrom.com
  *
  *         License:  GPL
@@ -56,8 +55,8 @@
 // In this file, I preserved individual comments by exstrom.com
 // developers in their original form.
 
-#ifndef _SIGPROC_EXSTROM_HH
-#define _SIGPROC_EXSTROM_HH
+#ifndef _AGH_SIGPROC_EXSTROM_H
+#define _AGH_SIGPROC_EXSTROM_H
 
 #include <valarray>
 
@@ -768,4 +767,7 @@ extern template valarray<TFloat> band_stop( const valarray<TFloat>&, size_t, flo
 
 #endif
 
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
diff --git a/src/sigproc/sigproc.cc b/src/sigproc/sigproc.cc
index b665584..262800f 100644
--- a/src/sigproc/sigproc.cc
+++ b/src/sigproc/sigproc.cc
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  sigproc/sigproc.cc
  *         Project:  Aghermann
@@ -138,4 +137,8 @@ interpolate( const vector<size_t>& xi,
 	return out;
 }
 
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
+
diff --git a/src/sigproc/sigproc.hh b/src/sigproc/sigproc.hh
index 59fc83d..da3b86d 100644
--- a/src/sigproc/sigproc.hh
+++ b/src/sigproc/sigproc.hh
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  sigproc/sigproc.hh
  *         Project:  Aghermann
@@ -101,6 +100,8 @@ struct SSignalRef {
 
 
 
+
+
 template <typename T>
 size_t
 envelope( const SSignalRef<T>& in,
@@ -111,6 +112,22 @@ envelope( const SSignalRef<T>& in,
 	  vector<size_t> *mini_p = nullptr,
 	  vector<size_t> *maxi_p = nullptr);
 
+template <typename T>
+valarray<T>
+raw_signal_profile( const SSignalRef<T>& sigref,
+		    double env_dh, double env_dt)
+{
+	valarray<T>
+		ret,
+		env_u, env_l;
+	envelope( sigref,
+		  env_dh, env_dt,
+		  &env_l, &env_u);
+	ret.resize( env_l.size());
+	ret = env_u - env_l;
+	return ret;
+}
+
 
 template <typename T>
 valarray<T>
@@ -308,4 +325,8 @@ phase_diff( const SSignalRef<T>& sig1,
 
 #endif
 
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
+
diff --git a/src/sigproc/sigproc.ii b/src/sigproc/sigproc.ii
index 22655bc..0829df7 100644
--- a/src/sigproc/sigproc.ii
+++ b/src/sigproc/sigproc.ii
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  sigproc/sigproc.ii
  *         Project:  Aghermann
@@ -80,8 +79,7 @@ envelope( const SSignalRef<T>& in,
 	  vector<size_t> *maxi_p = nullptr)
 {
 	auto&	S = in.signal;
-	size_t	i,
-		n_samples = S.size(),
+	ssize_t	n_samples = S.size(),
 		dh2 = dh_ * in.samplerate / 2;
 
 	vector<size_t>
@@ -93,6 +91,7 @@ envelope( const SSignalRef<T>& in,
 	maxi.push_back( 0);
 
 	// auto dS = derivative(in.signal); // will skip over many extrema due to quantization
+	ssize_t	i;
 	for ( i = dh2; i < n_samples-dh2; ++i ) {
 		auto lmax = S[ slice (i-dh2, dh2+dh2, 1) ].max();
 		if ( S[i] == lmax && i != i-dh2 && i+dh2 ) {
@@ -136,21 +135,29 @@ envelope( const SSignalRef<T>& in,
 template <typename T>
 valarray<T>
 dzcdf( const SSignalRef<T>& in,
+//       size_t sa, size_t sz,
        double dt,
        double sigma,
        size_t smooth_side)
 {
-	size_t i;
+      // // prepare with context
+      // 	ssize_t	csa = (ssize_t)sa - sigma * in.samplerate/2,
+      // 		csz = (ssize_t)sz + sigma * in.samplerate/2;
+      // 	agh::alg::ensure_within( csa, 0, in.signal.size());
+      // 	agh::alg::ensure_within( csz, 0, in.signal.size());
+      // 	size_t	dsa = sa - csa,
+      // 		dsz = csz - sz;
 
 	valarray<T>
-		tmp (in.signal),
-		deriv = derivative( in.signal);
-
+		// tmp (in.signal [slice (csa, csz-csa, 1)]);
+		tmp (in.signal);
 	smooth( tmp, smooth_side);
+	valarray<T>
+		deriv = derivative( tmp);
 
       // collect zerocrossings
 	vector<size_t> izx;
-	for ( i = 1; i < in.signal.size(); ++i )
+	for ( size_t i = 1; i < in.signal.size(); ++i )
 		if ( agh::alg::sign( deriv[i-1]) != agh::alg::sign( deriv[i]) )
 			izx.push_back( i);
 
@@ -161,10 +168,11 @@ dzcdf( const SSignalRef<T>& in,
 
       // calculate the bloody zcdf
 	double	window = 4*dt; // half a second, good enough
-	double	t = 0., tdiff;
+	double	t, tdiff;
 	size_t	I = 0, J;
-	for ( i = 0; i < out_size; ++i ) {
-		xi[i] = i * dt * in.samplerate;
+	for ( size_t i = 0; i < out_size; ++i ) {
+		t = i*dt;
+		xi[i] = t * in.samplerate;
 		for ( J = I; J > 0; --J ) {
 			tdiff = (double)izx[J]/in.samplerate - t;
 			if ( tdiff >  window )
@@ -181,7 +189,6 @@ dzcdf( const SSignalRef<T>& in,
 				break;
 			y[ xi[i] ] += exp( -gsl_pow_2(tdiff) / gsl_pow_2(sigma));
 		}
-		t = i*dt;
 		I = J;
 	}
 	return interpolate( xi, in.samplerate, y, 1./in.samplerate);
@@ -247,4 +254,8 @@ phase_diff( const SSignalRef<T>& sig1,
 }
 
 
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
+
diff --git a/src/ui/libcommon.cc b/src/ui/libcommon.cc
index 79be02c..2a6500c 100644
--- a/src/ui/libcommon.cc
+++ b/src/ui/libcommon.cc
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  ui/globals.cc
  *         Project:  Aghermann
@@ -13,6 +12,7 @@
 #include <cassert>
 #include <gtk/gtk.h>
 
+#include "common/alg.hh"
 #include "globals.hh"
 #include "misc.hh"
 #include "ui.hh"
@@ -179,7 +179,7 @@ void
 aghui::
 cairo_draw_signal( cairo_t *cr, const valarray<TFloat>& V,
 		   ssize_t start, ssize_t end,
-		   size_t hspan, double hoff, double voff, float scale,
+		   size_t hspan, float hoff, float voff, float scale,
 		   unsigned short decimate,
 		   aghui::TDrawSignalDirection direction,
 		   bool continue_path)
@@ -218,6 +218,28 @@ cairo_draw_signal( cairo_t *cr, const valarray<TFloat>& V,
 }
 
 
+void
+aghui::
+cairo_draw_envelope( cairo_t *cr, const valarray<TFloat>& V,
+		     ssize_t start, ssize_t end,
+		     size_t hspan, float hoff, float voff, float scale)
+{
+	agh::alg::ensure_within( start, (ssize_t)0, (ssize_t)V.size());
+	agh::alg::ensure_within( end,   (ssize_t)0, (ssize_t)V.size());
+
+	double dps = (double)(end - start) / hspan;
+	cairo_move_to( cr, hoff, voff);
+	size_t i = start;
+	for ( ; i < end; ++i )
+		cairo_line_to( cr, i / dps,
+			       voff - V[i] * scale/2);
+	for ( --i; i > start; --i )
+		cairo_line_to( cr, i / dps,
+			       voff + V[i] * scale/2);
+	cairo_fill( cr);
+}
+
+
 
 
 
@@ -353,4 +375,8 @@ SUIVar_<GtkListStore, list<string>>::down() const
 } // namespace aghui
 
 
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
+
diff --git a/src/ui/mw/Makefile.am b/src/ui/mw/Makefile.am
index d8290cc..e320e5d 100644
--- a/src/ui/mw/Makefile.am
+++ b/src/ui/mw/Makefile.am
@@ -8,18 +8,18 @@ AM_CXXFLAGS = \
 noinst_LIBRARIES = liba.a
 
 liba_a_SOURCES = \
-	mw-admit-one.cc \
-	mw-construct.cc \
-	mw-loadsave.cc \
-	mw-mainmenu_cb.cc \
-	mw-measurements.cc \
-	mw-measurements_cb.cc \
-	mw-populate.cc \
-	mw-settings_cb.cc \
-	mw-simulations.cc \
-	mw-simulations_cb.cc \
-	mw-splash.cc \
-	mw-widgets.hh \
+	admit-one.cc \
+	construct.cc \
+	loadsave.cc \
+	mainmenu_cb.cc \
+	measurements.cc \
+	measurements_cb.cc \
+	populate.cc \
+	settings_cb.cc \
+	simulations.cc \
+	simulations_cb.cc \
+	splash.cc \
+	widgets.hh \
 	mw.cc \
 	mw.hh \
 	mw_cb.cc \
@@ -28,7 +28,7 @@ liba_a_SOURCES = \
 if DO_PCH
 BUILT_SOURCES = \
 	mw.hh.gch \
-	mw-widgets.hh.gch \
+	widgets.hh.gch \
 	mw_cb.hh.gch
 %.hh.gch: %.hh
 	$(CXXCOMPILE) -c $<
diff --git a/src/ui/mw/mw-admit-one.cc b/src/ui/mw/admit-one.cc
similarity index 100%
rename from src/ui/mw/mw-admit-one.cc
rename to src/ui/mw/admit-one.cc
diff --git a/src/ui/mw/mw-construct.cc b/src/ui/mw/construct.cc
similarity index 87%
rename from src/ui/mw/mw-construct.cc
rename to src/ui/mw/construct.cc
index aed0ca9..65a4dfd 100644
--- a/src/ui/mw/mw-construct.cc
+++ b/src/ui/mw/construct.cc
@@ -1,6 +1,5 @@
-// ;-*-C++-*-
 /*
- *       File name:  ui/mw/mw-construct.cc
+ *       File name:  ui/mw/construct.cc
  *         Project:  Aghermann
  *          Author:  Andrei Zavada <johnhommer at gmail.com>
  * Initial version:  2011-07-02
@@ -12,7 +11,7 @@
 
 
 #include "ui/ui.hh"
-#include "mw-widgets.hh"
+#include "widgets.hh"
 #include "mw_cb.hh"
 
 using namespace std;
@@ -453,44 +452,46 @@ SExpDesignUIWidgets ()
 	G_CONNECT_1 (bSimParamRevertTunables, clicked);
 
       // ------ colours
-	if ( !(CwB[TColour::mw_night	  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourMWNight")) ||
-	     !(CwB[TColour::mw_day	  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourMWDay")) ||
-	     !(CwB[TColour::mw_profile	  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourMWProfile")) ||
-	     !(CwB[TColour::mw_ticks	  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourMWTicks")) ||
-	     !(CwB[TColour::mw_labels	  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourMWLabels")) ||
-
-	     !(CwB[TColour::sf_profile_psd].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourSFProfilePSD")) ||
-	     !(CwB[TColour::sf_profile_mc ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourSFProfileMC")) ||
-	     !(CwB[TColour::sf_profile_swu].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourSFProfileSWU")) ||
-	     !(CwB[TColour::sf_emg	  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourSFEMG")) ||
-	     !(CwB[TColour::sf_hypnogram  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourSFHypnogram")) ||
-	     !(CwB[TColour::sf_artifact	  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourSFArtifacts")) ||
-	     !(CwB[TColour::sf_annotations].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourSFAnnotations")) ||
-	     !(CwB[TColour::sf_selection  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourSFSelection")) ||
-	     !(CwB[TColour::sf_ticks	  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourSFTicks")) ||
-	     !(CwB[TColour::sf_labels	  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourSFLabels")) ||
-	     !(CwB[TColour::sf_cursor	  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourSFCursor")) ||
-
-	     !(CwB[TColour::mf_swa	  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourMFSWA")) ||
-	     !(CwB[TColour::mf_swa_sim	  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourMFSWASim")) ||
-	     !(CwB[TColour::mf_process_s  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourMFProcessS")) ||
-	     !(CwB[TColour::mf_paper	  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourMFPaper")) ||
-	     !(CwB[TColour::mf_ticks	  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourMFTicks")) ||
-	     !(CwB[TColour::mf_labels	  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourMFLabels")) ||
-
-	     !(CwB[TColour::score_none	  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourScoreNONE")) ||
-	     !(CwB[TColour::score_nrem1	  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourScoreNREM1")) ||
-	     !(CwB[TColour::score_nrem2	  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourScoreNREM2")) ||
-	     !(CwB[TColour::score_nrem3	  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourScoreNREM3")) ||
-	     !(CwB[TColour::score_nrem4	  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourScoreNREM4")) ||
-	     !(CwB[TColour::score_rem	  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourScoreREM")) ||
-	     !(CwB[TColour::score_wake	  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourScoreWake")) ||
-
-	     !(CwB[TColour::band_delta	  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourBandDelta")) ||
-	     !(CwB[TColour::band_theta	  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourBandTheta")) ||
-	     !(CwB[TColour::band_alpha	  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourBandAlpha")) ||
-	     !(CwB[TColour::band_beta	  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourBandBeta")) ||
-	     !(CwB[TColour::band_gamma	  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourBandGamma")) )
+	if ( !(CwB[TColour::mw_night	      ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourMWNight")) ||
+	     !(CwB[TColour::mw_day	      ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourMWDay")) ||
+	     !(CwB[TColour::mw_profile	      ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourMWProfile")) ||
+	     !(CwB[TColour::mw_ticks	      ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourMWTicks")) ||
+	     !(CwB[TColour::mw_labels	      ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourMWLabels")) ||
+
+	     !(CwB[TColour::sf_profile_psd    ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourSFProfilePSD")) ||
+	     !(CwB[TColour::sf_profile_mc     ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourSFProfileMC")) ||
+	     !(CwB[TColour::sf_profile_swu    ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourSFProfileSWU")) ||
+	     !(CwB[TColour::sf_phasic_spindle ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourSFPhasicSpindle")) ||
+	     !(CwB[TColour::sf_phasic_Kcomplex].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourSFPhasicKComplex")) ||
+	     !(CwB[TColour::sf_emg	      ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourSFEMG")) ||
+	     !(CwB[TColour::sf_hypnogram      ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourSFHypnogram")) ||
+	     !(CwB[TColour::sf_artifact	      ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourSFArtifacts")) ||
+	     !(CwB[TColour::sf_annotations    ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourSFAnnotations")) ||
+	     !(CwB[TColour::sf_selection      ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourSFSelection")) ||
+	     !(CwB[TColour::sf_ticks	      ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourSFTicks")) ||
+	     !(CwB[TColour::sf_labels	      ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourSFLabels")) ||
+	     !(CwB[TColour::sf_cursor	      ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourSFCursor")) ||
+
+	     !(CwB[TColour::mf_swa	      ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourMFSWA")) ||
+	     !(CwB[TColour::mf_swa_sim	      ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourMFSWASim")) ||
+	     !(CwB[TColour::mf_process_s      ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourMFProcessS")) ||
+	     !(CwB[TColour::mf_paper	      ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourMFPaper")) ||
+	     !(CwB[TColour::mf_ticks	      ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourMFTicks")) ||
+	     !(CwB[TColour::mf_labels	      ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourMFLabels")) ||
+
+	     !(CwB[TColour::score_none	      ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourScoreNONE")) ||
+	     !(CwB[TColour::score_nrem1	      ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourScoreNREM1")) ||
+	     !(CwB[TColour::score_nrem2	      ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourScoreNREM2")) ||
+	     !(CwB[TColour::score_nrem3	      ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourScoreNREM3")) ||
+	     !(CwB[TColour::score_nrem4	      ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourScoreNREM4")) ||
+	     !(CwB[TColour::score_rem	      ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourScoreREM")) ||
+	     !(CwB[TColour::score_wake	      ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourScoreWake")) ||
+
+	     !(CwB[TColour::band_delta	      ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourBandDelta")) ||
+	     !(CwB[TColour::band_theta	      ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourBandTheta")) ||
+	     !(CwB[TColour::band_alpha	      ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourBandAlpha")) ||
+	     !(CwB[TColour::band_beta	      ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourBandBeta")) ||
+	     !(CwB[TColour::band_gamma	      ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourBandGamma")) )
 		throw runtime_error ("Failed to construct widgets");
 
       // scrub colours
@@ -566,7 +567,8 @@ SExpDesignUIWidgets ()
 
       // ------- wEdfImport
 	if ( !AGH_GBGETOBJ (GtkDialog,		wSubjectDetails) ||
-	     !AGH_GBGETOBJ (GtkEntry,		eSubjectDetailsName) ||
+	     !AGH_GBGETOBJ (GtkEntry,		eSubjectDetailsShortName) ||
+	     !AGH_GBGETOBJ (GtkEntry,		eSubjectDetailsFullName) ||
 	     !AGH_GBGETOBJ (GtkSpinButton,	eSubjectDetailsAge) ||
 	     !AGH_GBGETOBJ (GtkRadioButton,	eSubjectDetailsGenderMale) ||
 	     !AGH_GBGETOBJ (GtkRadioButton,	eSubjectDetailsGenderFemale) ||
@@ -741,4 +743,7 @@ set_controls_for_empty_experiment( bool indeed, bool flush)
 }
 
 
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
diff --git a/src/ui/mw/mw-loadsave.cc b/src/ui/mw/loadsave.cc
similarity index 100%
rename from src/ui/mw/mw-loadsave.cc
rename to src/ui/mw/loadsave.cc
diff --git a/src/ui/mw/mw-mainmenu_cb.cc b/src/ui/mw/mainmenu_cb.cc
similarity index 98%
rename from src/ui/mw/mw-mainmenu_cb.cc
rename to src/ui/mw/mainmenu_cb.cc
index 73793ca..4e9a234 100644
--- a/src/ui/mw/mw-mainmenu_cb.cc
+++ b/src/ui/mw/mainmenu_cb.cc
@@ -109,7 +109,7 @@ iExpBasicSADetectUltradianCycles_activate_cb( GtkMenuItem*, gpointer userdata)
 	{
 		snprintf_buf(
 			"(%zu of %zu) %s/%s/%s", i, n,
-			ED.ED->group_of(J), J.name(), E.name());
+			ED.ED->group_of(J), J.short_name.c_str(), E.name());
 		ED.sb_message( __buf__);
 		gtk_widget_queue_draw( (GtkWidget*)ED.cMeasurements);
 		gdk_window_process_updates(
@@ -167,7 +167,7 @@ iExpGloballyDetectArtifacts_activate_cb( GtkMenuItem*, gpointer userdata)
 		{
 			snprintf_buf(
 				"(%zu of %zu) Detect artifacts in %s/%s/%s/%s:%s", i, total,
-				ED.ED->group_of(J), J.name(), D.c_str(), E.name(), R.F().channel_by_id(R.h()));
+				ED.ED->group_of(J), J.short_name.c_str(), D.c_str(), E.name(), R.F().channel_by_id(R.h()));
 			ED.sb_message( __buf__);
 			gtk_flush();
 		};
diff --git a/src/ui/mw/measurements.cc b/src/ui/mw/measurements.cc
new file mode 100644
index 0000000..c1051fc
--- /dev/null
+++ b/src/ui/mw/measurements.cc
@@ -0,0 +1,315 @@
+// ;-*-C++-*-
+/*
+ *       File name:  ui/mw/mw-measurements.cc
+ *         Project:  Aghermann
+ *          Author:  Andrei Zavada <johnhommer at gmail.com>
+ * Initial version:  2011-06-29
+ *
+ *         Purpose:  SExpDesignUI measurements view
+ *
+ *         License:  GPL
+ */
+
+
+#include <cstring>
+#include <ctime>
+
+#include <cairo.h>
+#include <cairo-svg.h>
+
+#include "model/beersma.hh"
+#include "ui/misc.hh"
+#include "mw.hh"
+
+using namespace std;
+
+bool
+aghui::SExpDesignUI::SSubjectPresentation::
+get_episode_from_timeline_click( unsigned along)
+{
+	try {
+		along -= tl_left_margin();
+		for ( auto& E : csubject.measurements[*_p._p._AghDi].episodes )
+			if ( along >= _p._p.T2P(E.start_rel) && along <= _p._p.T2P(E.end_rel) ) {
+				using_episode = &E;
+				return true;
+			}
+		using_episode = nullptr;
+		return false;
+	} catch (...) {
+		using_episode = nullptr;
+		return false;
+	}
+}
+
+void
+aghui::SExpDesignUI::SSubjectPresentation::
+draw_timeline( const char *fname) const
+{
+	cairo_surface_t *cs =
+		cairo_svg_surface_create( fname,
+					  timeline_width() + tl_left_margin() + tl_right_margin(),
+					  timeline_height());
+	cairo_t *cr = cairo_create( cs);
+	draw_timeline( cr);
+	cairo_destroy( cr);
+	cairo_surface_destroy( cs);
+}
+
+
+void
+aghui::SExpDesignUI::SSubjectPresentation::
+draw_timeline( cairo_t *cr) const
+{
+	bool have_episodes = cprofile != nullptr && not cprofile->mm_list().empty();
+	if ( not have_episodes ) {
+		cairo_move_to( cr, 50, timeline_height()/2+9);
+		cairo_select_font_face( cr, "sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
+		cairo_set_font_size( cr, 18);
+		cairo_set_source_rgba( cr, 0., 0., 0., .13);
+		cairo_show_text( cr, "(no episodes)");
+		cairo_stroke( cr);
+	}
+
+	if ( have_episodes ) {
+	      // day and night
+		{
+			cairo_pattern_t *cp =
+				cairo_pattern_create_linear( tl_left_margin(), 0.,
+							     timeline_width() - tl_right_margin(), 0.);
+			struct tm clock_time;
+			memcpy( &clock_time, localtime( &_p._p.timeline_start), sizeof(clock_time));
+			clock_time.tm_hour = 4;
+			clock_time.tm_min = clock_time.tm_sec = 0;
+			time_t	dawn = mktime( &clock_time),
+				t;
+			bool day = false;
+			for ( t = dawn; t < timeline_end(); t += 3600 * 12, day = !day )
+				if ( t > timeline_start() )
+					_p._p.CwB[day ? TColour::mw_day : TColour::mw_night].
+						pattern_add_color_stop_rgba( cp, (double)_p._p.T2P(t) / timeline_width());
+			cairo_set_source( cr, cp);
+			cairo_rectangle( cr, tl_left_margin(), 0., tl_left_margin() + timeline_width(), timeline_height());
+			cairo_fill( cr);
+			cairo_stroke( cr);
+			cairo_pattern_destroy( cp);
+		}
+
+		struct tm tl_start_fixed_tm;
+		memcpy( &tl_start_fixed_tm, localtime( &_p._p.timeline_start), sizeof(struct tm));
+		// determine the latest full hour before timeline_start
+		tl_start_fixed_tm.tm_min = 0;
+		time_t tl_start_fixed = mktime( &tl_start_fixed_tm);
+
+		double	scale = 0.;
+		switch (_p._p.display_profile_type ) {
+		case metrics::TType::psd: scale = _p._p.profile_scale_psd; break;
+		case metrics::TType::swu: scale = _p._p.profile_scale_swu; break;
+		case metrics::TType::mc : scale = _p._p.profile_scale_mc;  break;
+		default: break;
+		}
+
+	      // profile
+		auto& episodes = csubject.measurements[*_p._p._AghDi].episodes;
+	      // profile proper
+		unsigned
+			j_tl_pixel_start = _p._p.T2P( episodes.front().start_rel),
+			j_tl_pixel_end   = _p._p.T2P( episodes.back().end_rel),
+			j_tl_pixels = j_tl_pixel_end - j_tl_pixel_start;
+
+		_p._p.CwB[TColour::mw_profile].set_source_rgba( cr);
+		cairo_set_line_width( cr, .3);
+		cairo_move_to( cr, tl_left_margin() + j_tl_pixel_start, timeline_height()-12);
+		{
+			valarray<TFloat>
+				tmp (cprofile->timeline().size());
+			for ( size_t i = 0; i < tmp.size(); ++i )
+				tmp[i] = (*cprofile)[i].metric;
+			sigproc::smooth( tmp, _p._p.smooth_profile);
+			for ( size_t i = 0; i < tmp.size(); ++i )
+				cairo_line_to( cr,
+					       tl_left_margin() + j_tl_pixel_start + ((float)i)/tmp.size() * j_tl_pixels,
+					       -tmp[i] * scale + timeline_height()-12);
+		}
+		cairo_line_to( cr, j_tl_pixel_start + tl_left_margin() + j_tl_pixels, timeline_height()-12);
+		cairo_fill( cr);
+		cairo_stroke( cr);
+
+		// boundaries, with scored percentage bars
+		cairo_select_font_face( cr, "sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
+		cairo_set_font_size( cr, 11);
+		for ( auto& E : episodes ) {
+			unsigned
+				e_pixel_start = _p._p.T2P( E.start_rel),
+				e_pixel_end   = _p._p.T2P( E.end_rel),
+				e_pixels = e_pixel_end - e_pixel_start;
+
+			// episode start timestamp
+			cairo_move_to( cr, tl_left_margin() + e_pixel_start + 2, 12);
+			cairo_set_source_rgb( cr, 1., 1., 1.);
+			strftime( __buf__, 79, "%F %T",
+				  localtime( &E.start_time()));
+			g_string_printf( __ss__, "%s | %s",
+					 __buf__, E.name());
+			cairo_show_text( cr, __ss__->str);
+			cairo_stroke( cr);
+
+			// highlight
+			if ( is_focused && using_episode == &E ) {
+				const auto fuzz = 10;
+				cairo_pattern_t *cp =
+					cairo_pattern_create_linear(
+						tl_left_margin() + e_pixel_start - fuzz, 0,
+						tl_left_margin() + e_pixel_start + e_pixels + fuzz, 0);
+				cairo_pattern_add_color_stop_rgba( cp, 0.,					1., 1., 1., 0.);
+				cairo_pattern_add_color_stop_rgba( cp, 0. + (double)fuzz/(e_pixels + fuzz*2),	1., 1., 1., .3);
+				cairo_pattern_add_color_stop_rgba( cp, 1. - (double)fuzz/(e_pixels + fuzz*2),	1., 1., 1., .3);
+				cairo_pattern_add_color_stop_rgba( cp, 1.,					1., 1., 1., 0.);
+
+				cairo_set_line_width( cr, .2);
+				cairo_set_source( cr, cp);
+				cairo_rectangle( cr,
+						 tl_left_margin() + e_pixel_start - fuzz, 0,
+						 e_pixels + fuzz*2, timeline_height());
+				cairo_fill( cr);
+				cairo_stroke( cr);
+				cairo_pattern_destroy( cp);
+			}
+
+			// percentage bar graph
+			float pc_scored, pc_nrem, pc_rem, pc_wake;
+			pc_scored = E.sources.front().percent_scored( &pc_nrem, &pc_rem, &pc_wake);
+			pc_scored *= e_pixels / 100.;
+			pc_nrem   *= e_pixels / 100.;
+			pc_rem    *= e_pixels / 100.;
+			pc_wake   *= e_pixels / 100.;
+
+			cairo_set_line_width( cr, 4);
+
+			cairo_set_source_rgb( cr, 0., .1, .9);
+			cairo_move_to( cr, tl_left_margin() + e_pixel_start + 2, timeline_height()-5);
+			cairo_rel_line_to( cr, pc_nrem, 0);
+			cairo_stroke( cr);
+
+			cairo_set_source_rgb( cr, .9, .0, .5);
+			cairo_move_to( cr, tl_left_margin() + e_pixel_start + 2 + pc_nrem, timeline_height()-5);
+			cairo_rel_line_to( cr, pc_rem, 0);
+			cairo_stroke( cr);
+
+			cairo_set_source_rgb( cr, 0., .9, .1);
+			cairo_move_to( cr, tl_left_margin() + e_pixel_start + 2 + pc_nrem + pc_rem, timeline_height()-5);
+			cairo_rel_line_to( cr, pc_wake, 0);
+			cairo_stroke( cr);
+
+			cairo_set_line_width( cr, 10);
+			cairo_set_source_rgba( cr, 1., 1., 1., .5);
+			cairo_move_to( cr, tl_left_margin() + e_pixel_start + 2, timeline_height()-5);
+			cairo_rel_line_to( cr, pc_scored, 0);
+			cairo_stroke( cr);
+
+		      // ultradian cycle
+			if ( _p._p.draw_nremrem_cycles ) {
+				auto& M = E.recordings.at(_p._p.AghH());
+				if ( M.have_uc_determined() ) {
+					agh::beersma::FUltradianCycle F (*M.uc_params);
+					snprintf_buf( "T: %g  r: %g", F.T, F.r);
+					_p._p.CwB[TColour::mw_profile].set_source_rgba_contrasting( cr);
+					cairo_move_to( cr, tl_left_margin() + e_pixel_start + 2, timeline_height() - 22);
+					cairo_show_text( cr, __buf__);
+					cairo_stroke( cr);
+
+					_p._p.CwB[TColour::mw_ticks /* bounds? */].set_source_rgba( cr, .7);
+					cairo_set_line_width( cr, .5);
+
+					auto	dxe = tl_left_margin() + e_pixel_start,
+						dye = timeline_height() - 12;
+					cairo_move_to( cr, dxe, dye - F(0.) * timeline_height()/2);
+					for ( size_t i = 0; i < M.total_pages(); ++i ) {
+						float t = i * M.pagesize() / 60.;
+						cairo_line_to( cr,
+							       dxe + (t*60/M.F().recording_time()) * e_pixels,
+							       dye + -F(t) * timeline_height()/2);
+					}
+					cairo_stroke( cr);
+				}
+			}
+		}
+
+	      // ticks
+		if ( is_focused ) {
+			cairo_set_line_width( cr, .5);
+			_p._p.CwB[TColour::mw_ticks].set_source_rgb( cr);
+			cairo_select_font_face( cr, "sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
+			unsigned clock_d0 = localtime(&tl_start_fixed)->tm_mday + 1;
+			for ( time_t t = tl_start_fixed; t <= timeline_end(); t += 3600 ) {
+				size_t x = _p._p.T2P(t);
+				unsigned
+					clock_h  = localtime(&t)->tm_hour,
+					clock_d  = localtime(&t)->tm_mday;
+				if ( clock_h % 6 == 0 ) {
+					cairo_set_font_size( cr, (clock_h % 24 == 0) ? 10 : 8);
+					cairo_move_to( cr, tl_left_margin() + x, ( clock_h % 24 == 0 ) ? 0 : (timeline_height() - 16));
+					cairo_line_to( cr, tl_left_margin() + x, timeline_height() - 10);
+
+					snprintf_buf_ts_h( (clock_d - clock_d0) * 24 + clock_h);
+					cairo_text_extents_t extents;
+					cairo_text_extents( cr, __buf__, &extents);
+					cairo_move_to( cr, tl_left_margin() + x - extents.width/2, timeline_height()-1);
+					cairo_show_text( cr, __buf__);
+
+				} else {
+					cairo_move_to( cr, tl_left_margin() + x, timeline_height() - 14);
+					cairo_line_to( cr, tl_left_margin() + x, timeline_height() - 7);
+				}
+			}
+			cairo_stroke( cr);
+		}
+	}
+
+      // draw subject name, gender and age
+	cairo_move_to( cr, 2, 12);
+	cairo_select_font_face( cr, "serif", CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_BOLD);
+	cairo_set_font_size( cr, 12);
+	cairo_set_source_rgb( cr, 0., 0., 0.);
+	cairo_show_text( cr, csubject.short_name.c_str());
+	cairo_stroke( cr);
+
+	cairo_move_to( cr, 2, 25);
+	cairo_select_font_face( cr, "serif", CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_NORMAL);
+	cairo_set_font_size( cr, 9);
+	cairo_set_source_rgba( cr, .1, .1, .1, .5);
+	cairo_show_text( cr, csubject.full_name.c_str());
+	cairo_stroke( cr);
+
+	cairo_move_to( cr, 2, 35);
+	cairo_select_font_face( cr, "sans", CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_NORMAL);
+	cairo_set_font_size( cr, 9);
+	snprintf_buf( "%s %u y.o.",
+		      agh::CSubject::gender_sign( csubject.gender),
+		      csubject.age);
+	cairo_set_source_rgb( cr, .1, .1, .1);
+	cairo_show_text( cr, __buf__);
+}
+
+
+void
+aghui::SExpDesignUI::
+modify_profile_scales( GdkScrollDirection d)
+{
+	switch ( d ) {
+	case GDK_SCROLL_DOWN:
+		profile_scale_psd /= 1.05;
+		profile_scale_swu /= 1.05;
+		profile_scale_mc  /= 1.05;
+	    break;
+	case GDK_SCROLL_UP:
+		profile_scale_psd *= 1.05;
+		profile_scale_swu *= 1.05;
+		profile_scale_mc  *= 1.05;
+	    break;
+	default:
+	    break;
+	}
+}
+
+// eof
diff --git a/src/ui/mw/mw-measurements_cb.cc b/src/ui/mw/measurements_cb.cc
similarity index 96%
rename from src/ui/mw/mw-measurements_cb.cc
rename to src/ui/mw/measurements_cb.cc
index c2a5762..367926e 100644
--- a/src/ui/mw/mw-measurements_cb.cc
+++ b/src/ui/mw/measurements_cb.cc
@@ -184,7 +184,7 @@ iSubjectTimelineSaveAsSVG_activate_cb( GtkMenuItem *checkmenuitem, gpointer user
 	auto J = ED.using_subject;
 
 	snprintf_buf( "%s/%s/%s/%s/%s.svg",
-		      ED.ED->session_dir().c_str(), ED.ED->group_of( J->csubject), J->csubject.name(),
+		      ED.ED->session_dir().c_str(), ED.ED->group_of( J->csubject), J->csubject.short_name.c_str(),
 		      ED.AghD(), ED.AghT());
 	string tmp (__buf__);
 	J->is_focused = true;
@@ -202,7 +202,7 @@ iSubjectTimelineBrowse_activate_cb( GtkMenuItem *checkmenuitem, gpointer userdat
 	auto J = ED.using_subject;
 
 	snprintf_buf( "%s '%s/%s/%s/%s' &",
-		      ED.browse_command.c_str(), ED.ED->session_dir().c_str(), ED.ED->group_of( J->csubject), J->csubject.name(), ED.AghD());
+		      ED.browse_command.c_str(), ED.ED->session_dir().c_str(), ED.ED->group_of( J->csubject), J->csubject.short_name.c_str(), ED.AghD());
 	if ( system( __buf__) ) {}
 }
 
@@ -214,10 +214,10 @@ iSubjectTimelineResetMontage_activate_cb( GtkMenuItem *checkmenuitem, gpointer u
 
 	if ( not J->is_episode_focused() )
 		snprintf_buf( "find '%s/%s/%s/%s' -name '.*.montage' -delete",
-			      ED.ED->session_dir().c_str(), ED.ED->group_of( J->csubject), J->csubject.name(), ED.AghD());
+			      ED.ED->session_dir().c_str(), ED.ED->group_of( J->csubject), J->csubject.short_name.c_str(), ED.AghD());
 	else
 		snprintf_buf( "rm -f '%s/%s/%s/%s/.%s.montage'",
-			      ED.ED->session_dir().c_str(), ED.ED->group_of( J->csubject), J->csubject.name(), ED.AghD(), ED.AghE());
+			      ED.ED->session_dir().c_str(), ED.ED->group_of( J->csubject), J->csubject.short_name.c_str(), ED.AghD(), ED.AghE());
 
 	if ( system( __buf__) )
 		pop_ok_message( ED.wMainWindow, "Command '%s' returned a non-zero status. This is weird.", __buf__);
diff --git a/src/ui/mw/mw-measurements.cc b/src/ui/mw/mw-measurements.cc
deleted file mode 100644
index c5b64e4..0000000
--- a/src/ui/mw/mw-measurements.cc
+++ /dev/null
@@ -1,304 +0,0 @@
-// ;-*-C++-*-
-/*
- *       File name:  ui/mw/mw-measurements.cc
- *         Project:  Aghermann
- *          Author:  Andrei Zavada <johnhommer at gmail.com>
- * Initial version:  2011-06-29
- *
- *         Purpose:  SExpDesignUI measurements view
- *
- *         License:  GPL
- */
-
-
-#include <cstring>
-#include <ctime>
-
-#include <cairo.h>
-#include <cairo-svg.h>
-
-#include "model/beersma.hh"
-#include "ui/misc.hh"
-#include "mw.hh"
-
-using namespace std;
-
-bool
-aghui::SExpDesignUI::SSubjectPresentation::
-get_episode_from_timeline_click( unsigned along)
-{
-	try {
-		along -= tl_left_margin();
-		for ( auto& E : csubject.measurements[*_p._p._AghDi].episodes )
-			if ( along >= _p._p.T2P(E.start_rel) && along <= _p._p.T2P(E.end_rel) ) {
-				using_episode = &E;
-				return true;
-			}
-		using_episode = nullptr;
-		return false;
-	} catch (...) {
-		using_episode = nullptr;
-		return false;
-	}
-}
-
-void
-aghui::SExpDesignUI::SSubjectPresentation::
-draw_timeline( const char *fname) const
-{
-	cairo_surface_t *cs =
-		cairo_svg_surface_create( fname,
-					  timeline_width() + tl_left_margin() + tl_right_margin(),
-					  timeline_height());
-	cairo_t *cr = cairo_create( cs);
-	draw_timeline( cr);
-	cairo_destroy( cr);
-	cairo_surface_destroy( cs);
-}
-
-
-void
-aghui::SExpDesignUI::SSubjectPresentation::
-draw_timeline( cairo_t *cr) const
-{
-      // draw subject name, gender and age
-	cairo_move_to( cr, 2, 28);
-	cairo_select_font_face( cr, "sans", CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_NORMAL);
-	cairo_set_font_size( cr, 9);
-	snprintf_buf( "%s %u y.o.",
-		      agh::CSubject::gender_sign( csubject.gender),
-		      csubject.age);
-	cairo_show_text( cr, __buf__);
-
-	cairo_move_to( cr, 2, 12);
-	cairo_select_font_face( cr, "serif", CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_BOLD);
-	cairo_set_font_size( cr, 12);
-	cairo_show_text( cr, csubject.name());
-	cairo_stroke( cr);
-
-	if ( cprofile == nullptr || cprofile->mm_list().empty() ) {
-		cairo_move_to( cr, 50, timeline_height()/2+9);
-		cairo_select_font_face( cr, "sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
-		cairo_set_font_size( cr, 18);
-		cairo_set_source_rgba( cr, 0., 0., 0., .13);
-		cairo_show_text( cr, "(no episodes)");
-		cairo_stroke( cr);
-		return;
-	}
-
-      // day and night
-	{
-		cairo_pattern_t *cp =
-			cairo_pattern_create_linear( tl_left_margin(), 0.,
-						     timeline_width() - tl_right_margin(), 0.);
-		struct tm clock_time;
-		memcpy( &clock_time, localtime( &_p._p.timeline_start), sizeof(clock_time));
-		clock_time.tm_hour = 4;
-		clock_time.tm_min = clock_time.tm_sec = 0;
-		time_t	dawn = mktime( &clock_time),
-			t;
-		bool day = false;
-		for ( t = dawn; t < timeline_end(); t += 3600 * 12, day = !day )
-			if ( t > timeline_start() )
-				_p._p.CwB[day ? TColour::mw_day : TColour::mw_night].
-					pattern_add_color_stop_rgba( cp, (double)_p._p.T2P(t) / timeline_width());
-		cairo_set_source( cr, cp);
-		cairo_rectangle( cr, tl_left_margin(), 0., tl_left_margin() + timeline_width(), timeline_height());
-		cairo_fill( cr);
-		cairo_stroke( cr);
-		cairo_pattern_destroy( cp);
-	}
-
-	struct tm tl_start_fixed_tm;
-	memcpy( &tl_start_fixed_tm, localtime( &_p._p.timeline_start), sizeof(struct tm));
-	// determine the latest full hour before timeline_start
-	tl_start_fixed_tm.tm_min = 0;
-	time_t tl_start_fixed = mktime( &tl_start_fixed_tm);
-
-	double	scale = 0.;
-	switch (_p._p.display_profile_type ) {
-	case metrics::TType::psd: scale = _p._p.profile_scale_psd; break;
-	case metrics::TType::swu: scale = _p._p.profile_scale_swu; break;
-	case metrics::TType::mc : scale = _p._p.profile_scale_mc;  break;
-	default: break;
-	}
-
-      // profile
-	auto& episodes = csubject.measurements[*_p._p._AghDi].episodes;
-      // profile proper
-	unsigned
-		j_tl_pixel_start = _p._p.T2P( episodes.front().start_rel),
-		j_tl_pixel_end   = _p._p.T2P( episodes.back().end_rel),
-		j_tl_pixels = j_tl_pixel_end - j_tl_pixel_start;
-
-	_p._p.CwB[TColour::mw_profile].set_source_rgba( cr);
-	cairo_set_line_width( cr, .3);
-	cairo_move_to( cr, tl_left_margin() + j_tl_pixel_start, timeline_height()-12);
-	{
-		valarray<TFloat>
-			tmp (cprofile->timeline().size());
-		for ( size_t i = 0; i < tmp.size(); ++i )
-			tmp[i] = (*cprofile)[i].metric;
-		sigproc::smooth( tmp, _p._p.smooth_profile);
-		for ( size_t i = 0; i < tmp.size(); ++i )
-			cairo_line_to( cr,
-				       tl_left_margin() + j_tl_pixel_start + ((float)i)/tmp.size() * j_tl_pixels,
-				       -tmp[i] * scale + timeline_height()-12);
-	}
-	cairo_line_to( cr, j_tl_pixel_start + tl_left_margin() + j_tl_pixels, timeline_height()-12);
-	cairo_fill( cr);
-	cairo_stroke( cr);
-
-	// boundaries, with scored percentage bars
-	cairo_select_font_face( cr, "sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
-	cairo_set_font_size( cr, 11);
-	for ( auto& E : episodes ) {
-		unsigned
-			e_pixel_start = _p._p.T2P( E.start_rel),
-			e_pixel_end   = _p._p.T2P( E.end_rel),
-			e_pixels = e_pixel_end - e_pixel_start;
-
-		// episode start timestamp
-		cairo_move_to( cr, tl_left_margin() + e_pixel_start + 2, 12);
-		cairo_set_source_rgb( cr, 1., 1., 1.);
-		strftime( __buf__, 79, "%F %T",
-			  localtime( &E.start_time()));
-		g_string_printf( __ss__, "%s | %s",
-				 __buf__, E.name());
-		cairo_show_text( cr, __ss__->str);
-		cairo_stroke( cr);
-
-		// highlight
-		if ( is_focused && using_episode == &E ) {
-			const auto fuzz = 10;
-			cairo_pattern_t *cp =
-				cairo_pattern_create_linear(
-					tl_left_margin() + e_pixel_start - fuzz, 0,
-					tl_left_margin() + e_pixel_start + e_pixels + fuzz, 0);
-			cairo_pattern_add_color_stop_rgba( cp, 0.,					1., 1., 1., 0.);
-			cairo_pattern_add_color_stop_rgba( cp, 0. + (double)fuzz/(e_pixels + fuzz*2),	1., 1., 1., .3);
-			cairo_pattern_add_color_stop_rgba( cp, 1. - (double)fuzz/(e_pixels + fuzz*2),	1., 1., 1., .3);
-			cairo_pattern_add_color_stop_rgba( cp, 1.,					1., 1., 1., 0.);
-
-			cairo_set_line_width( cr, .2);
-			cairo_set_source( cr, cp);
-			cairo_rectangle( cr,
-					 tl_left_margin() + e_pixel_start - fuzz, 0,
-					 e_pixels + fuzz*2, timeline_height());
-			cairo_fill( cr);
-			cairo_stroke( cr);
-			cairo_pattern_destroy( cp);
-		}
-
-		// percentage bar graph
-		float pc_scored, pc_nrem, pc_rem, pc_wake;
-		pc_scored = E.sources.front().percent_scored( &pc_nrem, &pc_rem, &pc_wake);
-		pc_scored *= e_pixels / 100.;
-		pc_nrem   *= e_pixels / 100.;
-		pc_rem    *= e_pixels / 100.;
-		pc_wake   *= e_pixels / 100.;
-
-		cairo_set_line_width( cr, 4);
-
-		cairo_set_source_rgb( cr, 0., .1, .9);
-		cairo_move_to( cr, tl_left_margin() + e_pixel_start + 2, timeline_height()-5);
-		cairo_rel_line_to( cr, pc_nrem, 0);
-		cairo_stroke( cr);
-
-		cairo_set_source_rgb( cr, .9, .0, .5);
-		cairo_move_to( cr, tl_left_margin() + e_pixel_start + 2 + pc_nrem, timeline_height()-5);
-		cairo_rel_line_to( cr, pc_rem, 0);
-		cairo_stroke( cr);
-
-		cairo_set_source_rgb( cr, 0., .9, .1);
-		cairo_move_to( cr, tl_left_margin() + e_pixel_start + 2 + pc_nrem + pc_rem, timeline_height()-5);
-		cairo_rel_line_to( cr, pc_wake, 0);
-		cairo_stroke( cr);
-
-		cairo_set_line_width( cr, 10);
-		cairo_set_source_rgba( cr, 1., 1., 1., .5);
-		cairo_move_to( cr, tl_left_margin() + e_pixel_start + 2, timeline_height()-5);
-		cairo_rel_line_to( cr, pc_scored, 0);
-		cairo_stroke( cr);
-
-	      // ultradian cycle
-		if ( _p._p.draw_nremrem_cycles ) {
-			auto& M = E.recordings.at(_p._p.AghH());
-			if ( M.have_uc_determined() ) {
-				agh::beersma::FUltradianCycle F (*M.uc_params);
-				snprintf_buf( "T: %g  r: %g", F.T, F.r);
-				_p._p.CwB[TColour::mw_profile].set_source_rgba_contrasting( cr);
-				cairo_move_to( cr, tl_left_margin() + e_pixel_start + 2, timeline_height() - 22);
-				cairo_show_text( cr, __buf__);
-				cairo_stroke( cr);
-
-				_p._p.CwB[TColour::mw_ticks /* bounds? */].set_source_rgba( cr, .7);
-				cairo_set_line_width( cr, .5);
-
-				auto	dxe = tl_left_margin() + e_pixel_start,
-					dye = timeline_height() - 12;
-				cairo_move_to( cr, dxe, dye - F(0.) * timeline_height()/2);
-				for ( size_t i = 0; i < M.total_pages(); ++i ) {
-					float t = i * M.pagesize() / 60.;
-					cairo_line_to( cr,
-						       dxe + (t*60/M.F().recording_time()) * e_pixels,
-						       dye + -F(t) * timeline_height()/2);
-				}
-				cairo_stroke( cr);
-			}
-		}
-	}
-
-      // ticks
-	if ( is_focused ) {
-		cairo_set_line_width( cr, .5);
-		_p._p.CwB[TColour::mw_ticks].set_source_rgb( cr);
-		cairo_select_font_face( cr, "sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
-		unsigned clock_d0 = localtime(&tl_start_fixed)->tm_mday + 1;
-		for ( time_t t = tl_start_fixed; t <= timeline_end(); t += 3600 ) {
-			size_t x = _p._p.T2P(t);
-			unsigned
-				clock_h  = localtime(&t)->tm_hour,
-				clock_d  = localtime(&t)->tm_mday;
-			if ( clock_h % 6 == 0 ) {
-				cairo_set_font_size( cr, (clock_h % 24 == 0) ? 10 : 8);
-				cairo_move_to( cr, tl_left_margin() + x, ( clock_h % 24 == 0 ) ? 0 : (timeline_height() - 16));
-				cairo_line_to( cr, tl_left_margin() + x, timeline_height() - 10);
-
-				snprintf_buf_ts_h( (clock_d - clock_d0) * 24 + clock_h);
-				cairo_text_extents_t extents;
-				cairo_text_extents( cr, __buf__, &extents);
-				cairo_move_to( cr, tl_left_margin() + x - extents.width/2, timeline_height()-1);
-				cairo_show_text( cr, __buf__);
-
-			} else {
-				cairo_move_to( cr, tl_left_margin() + x, timeline_height() - 14);
-				cairo_line_to( cr, tl_left_margin() + x, timeline_height() - 7);
-			}
-		}
-		cairo_stroke( cr);
-	}
-}
-
-
-void
-aghui::SExpDesignUI::
-modify_profile_scales( GdkScrollDirection d)
-{
-	switch ( d ) {
-	case GDK_SCROLL_DOWN:
-		profile_scale_psd /= 1.05;
-		profile_scale_swu /= 1.05;
-		profile_scale_mc  /= 1.05;
-	    break;
-	case GDK_SCROLL_UP:
-		profile_scale_psd *= 1.05;
-		profile_scale_swu *= 1.05;
-		profile_scale_mc  *= 1.05;
-	    break;
-	default:
-	    break;
-	}
-}
-
-// eof
diff --git a/src/ui/mw/mw.cc b/src/ui/mw/mw.cc
index 86f7bed..a8e9d94 100644
--- a/src/ui/mw/mw.cc
+++ b/src/ui/mw/mw.cc
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  ui/mw/mw.cc
  *         Project:  Aghermann
@@ -85,7 +84,7 @@ create_cprofile()
 	} catch (...) {  // can be invalid_argument (no recording in such session/channel) or some TSimPrepError
 		cprofile = nullptr;
 		fprintf( stderr, "SSubjectPresentation::SSubjectPresentation(): subject %s has no recordings in session %s channel %s\n",
-			 csubject.name(), _p._p.AghD(), _p._p.AghT());
+			 csubject.short_name.c_str(), _p._p.AghD(), _p._p.AghT());
 	}
 }
 
@@ -567,7 +566,8 @@ void
 aghui::SExpDesignUI::
 update_subject_details_interactively( agh::CSubject& J)
 {
-	gtk_entry_set_text( eSubjectDetailsName, J.full_name.c_str());
+	gtk_entry_set_text( eSubjectDetailsShortName, J.short_name.c_str());
+	gtk_entry_set_text( eSubjectDetailsFullName, J.full_name.c_str());
 	gtk_spin_button_set_value( eSubjectDetailsAge, J.age);
 	gtk_toggle_button_set_active( (J.gender == agh::CSubject::TGender::male)
 				      ? (GtkToggleButton*)eSubjectDetailsGenderMale
@@ -576,7 +576,8 @@ update_subject_details_interactively( agh::CSubject& J)
 	gtk_entry_set_text( eSubjectDetailsComment, J.comment.c_str());
 
 	if ( gtk_dialog_run( (GtkDialog*)wSubjectDetails) == -5 ) {
-		J.full_name.assign( gtk_entry_get_text( eSubjectDetailsName));
+		J.short_name.assign( gtk_entry_get_text( eSubjectDetailsShortName));
+		J.full_name.assign( gtk_entry_get_text( eSubjectDetailsFullName));
 		J.age = gtk_spin_button_get_value( eSubjectDetailsAge);
 		J.gender =
 			gtk_toggle_button_get_active( (GtkToggleButton*)eSubjectDetailsGenderMale)
@@ -587,4 +588,7 @@ update_subject_details_interactively( agh::CSubject& J)
 }
 
 
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
diff --git a/src/ui/mw/mw.hh b/src/ui/mw/mw.hh
index 290cf15..1443459 100644
--- a/src/ui/mw/mw.hh
+++ b/src/ui/mw/mw.hh
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  ui/mw/mw.hh
  *         Project:  Aghermann
@@ -29,7 +28,7 @@
 #include "ui/ui.hh"
 #include "ui/ui++.hh"
 #include "ui/forward-decls.hh"
-#include "mw-widgets.hh"
+#include "widgets.hh"
 
 #if HAVE_CONFIG_H && !defined(VERSION)
 #  include "config.h"
@@ -373,4 +372,7 @@ SExpDesignUI::AghDi() const
 
 #endif
 
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
diff --git a/src/ui/mw/mw_cb.cc b/src/ui/mw/mw_cb.cc
index 1282e93..718195d 100644
--- a/src/ui/mw/mw_cb.cc
+++ b/src/ui/mw/mw_cb.cc
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  ui/mw/mw_cb.cc
  *         Project:  Aghermann
@@ -274,4 +273,7 @@ bMainCloseThatSF_clicked_cb( GtkButton*, gpointer userdata)
 
 } // extern "C"
 
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
diff --git a/src/ui/mw/mw_cb.hh b/src/ui/mw/mw_cb.hh
index b334216..1cb36fb 100644
--- a/src/ui/mw/mw_cb.hh
+++ b/src/ui/mw/mw_cb.hh
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  ui/mw/mw_cb.hh
  *         Project:  Aghermann
@@ -10,8 +9,8 @@
  *         License:  GPL
  */
 
-#ifndef _AGH_UI_EXPDESIGN_CB_H
-#define _AGH_UI_EXPDESIGN_CB_H
+#ifndef _AGH_UI_MW_CB_H
+#define _AGH_UI_MW_CB_H
 
 #include <gtk/gtk.h>
 
@@ -109,4 +108,8 @@ void bMainCloseThatSF_clicked_cb( GtkButton*, gpointer);
 
 #endif
 
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
+
diff --git a/src/ui/mw/mw-populate.cc b/src/ui/mw/populate.cc
similarity index 97%
rename from src/ui/mw/mw-populate.cc
rename to src/ui/mw/populate.cc
index 544fabe..dca983d 100644
--- a/src/ui/mw/mw-populate.cc
+++ b/src/ui/mw/populate.cc
@@ -1,6 +1,5 @@
-// ;-*-C++-*-
 /*
- *       File name:  ui/mw/mw-populate.cc
+ *       File name:  ui/mw/populate.cc
  *         Project:  Aghermann
  *          Author:  Andrei Zavada <johnhommer at gmail.com>
  * Initial version:  2012-10-19
@@ -286,10 +285,10 @@ populate_mGlobalAnnotations()
 									    -1);
 							last_j = last_d = last_e = NULL;
 						}
-						if ( last_j != J.name() ) {
+						if ( last_j != J.short_name.c_str() ) {  // comparing pointers here
 							gtk_tree_store_append( mGlobalAnnotations, &iter_j, &iter_g);
 							gtk_tree_store_set( mGlobalAnnotations, &iter_j,
-									    0, last_j = J.name(),
+									    0, last_j = J.short_name.c_str(),
 									    mannotations_visibility_switch_col, TRUE,
 									    -1);
 							last_d = last_e = NULL;
@@ -396,7 +395,7 @@ populate_1()
 						latest_end = ee.back().end_rel;
 				} else
 					fprintf( stderr, "SExpDesignUI::populate_1(): session \"%s\", channel \"%s\" for subject \"%s\" is empty\n",
-						 AghD(), AghT(), J.name());
+						 AghD(), AghT(), J.short_name.c_str());
 			}
 		}
 	}
@@ -472,7 +471,7 @@ populate_1()
 				cairo_text_extents_t extents;
 				cairo_select_font_face( cr, "serif", CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_BOLD);
 				cairo_set_font_size( cr, 11);
-				cairo_text_extents( cr, J.csubject.name(), &extents);
+				cairo_text_extents( cr, J.csubject.short_name.c_str(), &extents);
 				if ( tl_left_margin < extents.width )
 					tl_left_margin = extents.width;
 				cairo_destroy( cr);
@@ -546,6 +545,7 @@ populate_1()
 }
 
 
-
-
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
diff --git a/src/ui/mw/mw-settings_cb.cc b/src/ui/mw/settings_cb.cc
similarity index 100%
rename from src/ui/mw/mw-settings_cb.cc
rename to src/ui/mw/settings_cb.cc
diff --git a/src/ui/mw/mw-simulations.cc b/src/ui/mw/simulations.cc
similarity index 97%
rename from src/ui/mw/mw-simulations.cc
rename to src/ui/mw/simulations.cc
index 8099868..054e850 100644
--- a/src/ui/mw/mw-simulations.cc
+++ b/src/ui/mw/simulations.cc
@@ -42,7 +42,7 @@ populate_2()
 
 			gtk_tree_store_append( mSimulations, &iter_j, &iter_g);
 			gtk_tree_store_set( mSimulations, &iter_j,
-					    0, J.name(),
+					    0, J.short_name.c_str(),
 					    msimulations_visibility_switch_col, TRUE,
 					    -1);
 
@@ -100,7 +100,7 @@ populate_2()
 
 				agh::ach::CModelRun *virgin;
 				int retval =
-					ED->setup_modrun( J.name(), AghD(), AghT(),
+					ED->setup_modrun( J.short_name.c_str(), AghD(), AghT(),
 							  P_new,
 							  &virgin);
 				if ( retval ) {
diff --git a/src/ui/mw/mw-simulations_cb.cc b/src/ui/mw/simulations_cb.cc
similarity index 99%
rename from src/ui/mw/mw-simulations_cb.cc
rename to src/ui/mw/simulations_cb.cc
index 1c558bc..1dac204 100644
--- a/src/ui/mw/mw-simulations_cb.cc
+++ b/src/ui/mw/simulations_cb.cc
@@ -142,7 +142,7 @@ iSimulationsRunBatch_activate_cb( GtkMenuItem*, gpointer userdata)
 			{
 				snprintf_buf( "(%zu of %zu) Running simulation in channel %s (%s) for %s (session %s) ...",
 					      i, n, H.c_str(), T.display_name().c_str(),
-					      J.name(), D.c_str());
+					      J.short_name.c_str(), D.c_str());
 				ED.sb_message( __buf__);
 				gtk_flush();
 			};
diff --git a/src/ui/mw/mw-splash.cc b/src/ui/mw/splash.cc
similarity index 98%
rename from src/ui/mw/mw-splash.cc
rename to src/ui/mw/splash.cc
index 01a38ef..d9bc804 100644
--- a/src/ui/mw/mw-splash.cc
+++ b/src/ui/mw/splash.cc
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  ui/mw/mw-splash.cc
  *         Project:  Aghermann
@@ -156,5 +155,7 @@ try_download()
 	}
 }
 
-
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
diff --git a/src/ui/mw/mw-widgets.hh b/src/ui/mw/widgets.hh
similarity index 98%
rename from src/ui/mw/mw-widgets.hh
rename to src/ui/mw/widgets.hh
index f7a0b69..23269ff 100644
--- a/src/ui/mw/mw-widgets.hh
+++ b/src/ui/mw/widgets.hh
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  ui/mw/mw-widgets.hh
  *         Project:  Aghermann
@@ -282,7 +281,8 @@ struct SExpDesignUIWidgets {
 	GtkDialog
 		*wSubjectDetails;
 	GtkEntry
-		*eSubjectDetailsName,
+		*eSubjectDetailsShortName,
+		*eSubjectDetailsFullName,
 		*eSubjectDetailsComment;
 	GtkSpinButton
 		*eSubjectDetailsAge;
@@ -383,4 +383,8 @@ struct SExpDesignUIWidgets {
 
 #endif // _AGHUI_EXPDESIGN_WIDGETS_H
 
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
+
diff --git a/src/ui/sf/channel.cc b/src/ui/sf/channel.cc
index e47c8c6..fb61130 100644
--- a/src/ui/sf/channel.cc
+++ b/src/ui/sf/channel.cc
@@ -1,6 +1,5 @@
-// ;-*-C++-*-
 /*
- *       File name:  ui/sf/sf-channel.cc
+ *       File name:  ui/sf/channel.cc
  *         Project:  Aghermann
  *          Author:  Andrei Zavada <johnhommer at gmail.com>
  * Initial version:  2012-05-29
@@ -11,8 +10,7 @@
  */
 
 
-
-
+#include <type_traits>
 #include "common/lang.hh"
 #include "common/config-validate.hh"
 #include "sigproc/exstrom.hh"
@@ -23,6 +21,9 @@
 
 using namespace std;
 
+pattern::SPatternPPack<TFloat>
+	aghui::SScoringFacility::SChannel::pattern_params =
+		{.25,  0., 1.5, 1,  .1, .5, 3};
 
 aghui::SScoringFacility::SChannel::
 SChannel( agh::CRecording& r,
@@ -103,6 +104,9 @@ SChannel( agh::CRecording& r,
 	get_signal_original();
 	get_signal_filtered();
 
+      // irrespective (grown out of EMG, eventually for universal use)
+	// get_raw_profile(); // too heavy; make it on-demand
+
       // psd power and spectrum, mc
 	if ( sigfile::SChannel::signal_type_is_fftable( type) ) {
 	      // power in a single bin
@@ -138,21 +142,15 @@ SChannel( agh::CRecording& r,
 		// don't: interchannel_gap is rubbish yet
 		psd.focused_band = metrics::psd::TBand::delta;
 
-	} else if ( type == sigfile::SChannel::TType::emg ) {
-		valarray<TFloat> env_u, env_l;
- 		sigproc::envelope( {signal_original, samplerate()},
-				   .5, 1.,
-				   &env_l, &env_u);
-		emg_profile.resize( env_l.size());
-		emg_profile = env_u - env_l;
-	}
+	} else if ( type == sigfile::SChannel::TType::emg )
+		get_raw_profile();
 
       // prevent exceptions from phasic_events.at
 	phasic_events[metrics::phasic::TEventTypes::spindle].clear();
 	phasic_events[metrics::phasic::TEventTypes::K_complex].clear();
 
       // let it be so to avoid libconfig::readFile throwing exceptions
-	psd.display_scale = mc.display_scale =
+	psd.display_scale = mc.display_scale = swu.display_scale =
 		emg_display_scale = DBL_MIN;
 
 	percent_dirty = calculate_dirty_percent();
@@ -161,6 +159,8 @@ SChannel( agh::CRecording& r,
 
 
 
+
+
 void
 aghui::SScoringFacility::SChannel::
 get_signal_original()
@@ -286,19 +286,38 @@ get_mc_course()
 }
 
 
-valarray<TFloat>&
+void
 aghui::SScoringFacility::SChannel::
-which_profile( metrics::TType type)
+get_raw_profile()
+{
+	raw_profile = sigproc::raw_signal_profile<TFloat>(
+		{signal_filtered, samplerate()},
+		1., 3.);
+}
+
+
+tuple<metrics::TType, valarray<TFloat>&>
+aghui::SScoringFacility::SChannel::
+which_profile( metrics::TType metric)
 {
 	switch ( type ) {
-	case metrics::TType::mc:
-		return get_mc_course(), mc.course;
-	case metrics::TType::psd:
-		return get_psd_course(), psd.course;
-	case metrics::TType::swu:
-		return get_swu_course(), swu.course;
+	case sigfile::SChannel::TType::eeg:
+		switch ( metric ) {
+		case metrics::TType::mc:
+			return tuple<metrics::TType, valarray<TFloat>&>(metric, mc.course);
+		case metrics::TType::psd:
+			return tuple<metrics::TType, valarray<TFloat>&>(metric, psd.course);
+		case metrics::TType::swu:
+			return tuple<metrics::TType, valarray<TFloat>&>(metric, swu.course);
+		case metrics::TType::raw:
+			if ( raw_profile.size() == 0 )
+				get_raw_profile();
+			return tuple<metrics::TType, valarray<TFloat>&>(metrics::TType::raw, raw_profile);
+		}
 	default:
-		throw runtime_error ("which profile is it?");
+		if ( raw_profile.size() == 0 )
+			get_raw_profile();
+		return tuple<metrics::TType, valarray<TFloat>&>(metrics::TType::raw, raw_profile);
 	}
 }
 
@@ -336,6 +355,18 @@ update_profile_display_scales()
 			mc.course,
 			mc.course.size(),
 			_p.interchannel_gap/2.);
+
+	swu.display_scale =
+		agh::alg::calibrate_display_scale(
+			swu.course,
+			swu.course.size(),
+			_p.interchannel_gap/2.);
+
+	emg_display_scale =
+		agh::alg::calibrate_display_scale(
+			raw_profile,
+			raw_profile.size(),
+			_p.interchannel_gap/2.);
 }
 
 
@@ -372,6 +403,7 @@ detect_artifacts( const metrics::mc::SArtifactDetectionPP& P)
 		get_spectrum( _p.cur_page());
 		get_swu_course();
 		get_mc_course();
+		get_raw_profile();
 
 		// if ( this == channel currently displayed on measurements overview )
 		if ( strcmp( name, _p._p.AghH()) == 0 )
@@ -455,7 +487,8 @@ void
 aghui::SScoringFacility::SChannel::
 mark_region_as_annotation( const char *label)
 {
-	crecording.F().annotations(_h).emplace_back(
+	sigfile::mark_annotation(
+		crecording.F().annotations(_h),
 		selection_start, selection_end,
 		label);
 }
@@ -465,8 +498,8 @@ void
 aghui::SScoringFacility::SChannel::
 mark_region_as_pattern()
 {
-	_p.patterns_d().import_from_selection( *this);
-	gtk_widget_show( (GtkWidget*)_p.patterns_d().wSFFD);
+	if ( _p.patterns_d().import_from_selection( *this) == 0 )
+		gtk_widget_show( (GtkWidget*)_p.patterns_d().wSFFD);
 }
 
 
@@ -477,19 +510,25 @@ update_channel_check_menu_items()
 {
 	_p.suppress_redraw = true;
 
-	gtk_check_menu_item_set_active( _p.iSFPageShowOriginal,  (gboolean)draw_original_signal);
-	gtk_check_menu_item_set_active( _p.iSFPageShowProcessed, (gboolean)draw_filtered_signal);
-	gtk_check_menu_item_set_active( _p.iSFPageUseResample,   (gboolean)resample_signal);
-	gtk_check_menu_item_set_active( _p.iSFPageDrawZeroline,  (gboolean)draw_zeroline);
+	bool	need_filtered = (have_low_pass() or have_high_pass() or have_notch_filter())
+		or (not artifacts().empty());
+
+	gtk_widget_set_visible( (GtkWidget*)_p.iSFPageShowOriginal, need_filtered);
+	gtk_widget_set_visible( (GtkWidget*)_p.iSFPageShowProcessed, need_filtered);
+
+	gtk_check_menu_item_set_active( _p.iSFPageShowOriginal,  draw_original_signal);
+	gtk_check_menu_item_set_active( _p.iSFPageShowProcessed, draw_filtered_signal);
+	gtk_check_menu_item_set_active( _p.iSFPageUseResample,   resample_signal);
+	gtk_check_menu_item_set_active( _p.iSFPageDrawZeroline,  draw_zeroline);
 
-	gtk_check_menu_item_set_active( _p.iSFPageDrawPSDProfile,  (gboolean)draw_psd);
-	gtk_check_menu_item_set_active( _p.iSFPageDrawPSDSpectrum, (gboolean)draw_spectrum);
-	gtk_check_menu_item_set_active( _p.iSFPageDrawMCProfile,   (gboolean)draw_mc);
-	gtk_check_menu_item_set_active( _p.iSFPageDrawSWUProfile,  (gboolean)draw_swu);
+	gtk_check_menu_item_set_active( _p.iSFPageDrawPSDProfile,  draw_psd);
+	gtk_check_menu_item_set_active( _p.iSFPageDrawPSDSpectrum, draw_spectrum);
+	gtk_check_menu_item_set_active( _p.iSFPageDrawMCProfile,   draw_mc);
+	gtk_check_menu_item_set_active( _p.iSFPageDrawSWUProfile,  draw_swu);
 
-	gtk_check_menu_item_set_active( _p.iSFPageSelectionDrawCourse,   (gboolean)draw_selection_course);
-	gtk_check_menu_item_set_active( _p.iSFPageSelectionDrawEnvelope, (gboolean)draw_selection_envelope);
-	gtk_check_menu_item_set_active( _p.iSFPageSelectionDrawDzxdf,    (gboolean)draw_selection_dzcdf);
+	gtk_check_menu_item_set_active( _p.iSFPageSelectionDrawCourse,   draw_selection_course);
+	gtk_check_menu_item_set_active( _p.iSFPageSelectionDrawEnvelope, draw_selection_envelope);
+	gtk_check_menu_item_set_active( _p.iSFPageSelectionDrawDzxdf,    draw_selection_dzcdf);
 
 	bool	is_eeg = (type == sigfile::SChannel::TType::eeg),
 		is_emg = (type == sigfile::SChannel::TType::emg),
@@ -575,6 +614,7 @@ _put_selection()
 	if ( selection_end_time - selection_start_time > 1. ) {
 		_p.artifacts_d().W_V.down();
 		auto& P = _p.artifacts_d().P;
+	FAFA;
 		auto sssu =
 			metrics::mc::do_sssu_reduction(
 				valarray<TFloat> {signal_filtered[ slice (selection_start, (selection_end - selection_start), 1) ]},
@@ -583,9 +623,13 @@ _put_selection()
 				P.f0, P.fc, P.bandwidth);
 		selection_SS = sssu.first[0];
 		selection_SU = sssu.second[0];
+	FAFA;
 	}
 }
 
 
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
 
-// eof
diff --git a/src/ui/sf/construct.cc b/src/ui/sf/construct.cc
index 8d3a124..277d483 100644
--- a/src/ui/sf/construct.cc
+++ b/src/ui/sf/construct.cc
@@ -315,15 +315,6 @@ SScoringFacilityWidgets ()
 
 	mSFAnnotationsAtCursor = gtk_list_store_new(1, G_TYPE_STRING);
 	gtk_combo_box_set_model_properly( eSFAnnotationSelectorWhich, mSFAnnotationsAtCursor);
-
-	// simple artifact detection
-	if ( !AGH_GBGETOBJ (GtkDialog,		wSFSimpleArtifactDetectionParams) ||
-	     !AGH_GBGETOBJ (GtkSpinButton,	eSFSimpleArtifactDetectionMinFlatRegionSize) ||
-	     !AGH_GBGETOBJ (GtkSpinButton,	eSFSimpleArtifactDetectionPad) )
-		throw runtime_error ("Failed to construct SF widgets (8)");
-
-
-
 }
 
 
diff --git a/src/ui/sf/d/Makefile.am b/src/ui/sf/d/Makefile.am
index 027a390..a9cbd2a 100644
--- a/src/ui/sf/d/Makefile.am
+++ b/src/ui/sf/d/Makefile.am
@@ -12,6 +12,10 @@ liba_a_SOURCES := \
 	artifacts.cc \
 	artifacts-construct.cc \
 	artifacts_cb.cc \
+	artifacts-simple.hh \
+	artifacts-simple.cc \
+	artifacts-simple-construct.cc \
+	artifacts-simple_cb.cc \
 	filters.hh \
 	filters.cc \
 	filters-construct.cc \
@@ -20,8 +24,9 @@ liba_a_SOURCES := \
 	patterns.cc \
 	patterns-construct.cc \
 	patterns-draw.cc \
-	patterns-enumerate.cc \
+	patterns-profiles.cc \
 	patterns_cb.cc \
+	patterns-profiles_cb.cc \
 	phasediff.hh \
 	phasediff.cc \
 	phasediff-construct.cc \
diff --git a/src/ui/sf/d/artifacts-simple-construct.cc b/src/ui/sf/d/artifacts-simple-construct.cc
new file mode 100644
index 0000000..c38a2aa
--- /dev/null
+++ b/src/ui/sf/d/artifacts-simple-construct.cc
@@ -0,0 +1,45 @@
+/*
+ *       File name:  ui/sf/d/artifacts-simple-construct.cc
+ *         Project:  Aghermann
+ *          Author:  Andrei Zavada <johnhommer at gmail.com>
+ * Initial version:  2013-10-25
+ *
+ *         Purpose:  scoring facility Artifacts Simple (flat signal detection) construct
+ *
+ *         License:  GPL
+ */
+
+#include <stdexcept>
+
+#include "ui/ui.hh"
+#include "artifacts-simple.hh"
+
+using namespace std;
+
+
+aghui::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);
+
+	if ( !AGH_GBGETOBJ (GtkDialog,		wSFADS) ||
+	     !AGH_GBGETOBJ (GtkSpinButton,	eSFADSMinFlatRegionSize) ||
+	     !AGH_GBGETOBJ (GtkSpinButton,	eSFADSPad) )
+		throw runtime_error ("Failed to construct SF widgets (8)");
+}
+
+
+aghui::SArtifactsSimpleDialogWidgets::
+~SArtifactsSimpleDialogWidgets ()
+{
+	gtk_widget_destroy( (GtkWidget*)wSFADS);
+	g_object_unref( (GObject*)builder);
+}
+
+
+// Local Variables:
+// indent-tabs-mode: 8
+// End:
diff --git a/src/ui/sf/d/artifacts-simple.cc b/src/ui/sf/d/artifacts-simple.cc
new file mode 100644
index 0000000..440c6b8
--- /dev/null
+++ b/src/ui/sf/d/artifacts-simple.cc
@@ -0,0 +1,41 @@
+/*
+ *       File name:  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;
+
+aghui::SScoringFacility::SArtifactsSimpleDialog&
+aghui::SScoringFacility::
+artifacts_simple_d()
+{
+	if ( not _artifacts_simple_d )
+		_artifacts_simple_d = new SArtifactsSimpleDialog(*this);
+	return *_artifacts_simple_d;
+}
+
+
+aghui::SScoringFacility::SArtifactsSimpleDialog::
+SArtifactsSimpleDialog (aghui::SScoringFacility& p_)
+      : min_size (0.5),
+	pad (),
+	_p (p_)
+{
+	W_V.reg( eSFADSMinFlatRegionSize,	&min_size);
+	W_V.reg( eSFADSPad,			&pad);
+}
+
+
+
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
diff --git a/src/ui/sf/d/artifacts-simple.hh b/src/ui/sf/d/artifacts-simple.hh
new file mode 100644
index 0000000..f30dad1
--- /dev/null
+++ b/src/ui/sf/d/artifacts-simple.hh
@@ -0,0 +1,68 @@
+/*
+ *       File name:  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_UI_SF_ARTIFACTS_SIMPLE_H
+#define _AGH_UI_SF_ARTIFACTS_SIMPLE_H
+
+#include <gtk/gtk.h>
+
+#include "ui/ui++.hh"
+#include "ui/sf/sf.hh"
+
+#if HAVE_CONFIG_H && !defined(VERSION)
+#  include "config.h"
+#endif
+
+using namespace std;
+
+namespace aghui {
+
+struct SArtifactsSimpleDialogWidgets {
+
+	SArtifactsSimpleDialogWidgets ();
+       ~SArtifactsSimpleDialogWidgets ();
+
+	GtkBuilder *builder;
+
+	GtkDialog
+		*wSFADS;
+	GtkSpinButton
+		*eSFADSMinFlatRegionSize,
+		*eSFADSPad;
+};
+
+struct SScoringFacility::SArtifactsSimpleDialog
+  : public SArtifactsSimpleDialogWidgets {
+
+	DELETE_DEFAULT_METHODS (SArtifactsSimpleDialog);
+
+	SArtifactsSimpleDialog (SScoringFacility&);
+
+	double	min_size,
+		pad;
+
+	SUIVarCollection
+		W_V;
+
+	SScoringFacility&
+		_p;
+};
+
+} // namespace aghui
+
+extern "C" {
+}
+
+#endif // _AGH_UI_SF_FILTERS_H
+
+// Local Variables:
+// indent-tabs-mode: 8
+// End:
diff --git a/src/ui/sf/d/artifacts-simple_cb.cc b/src/ui/sf/d/artifacts-simple_cb.cc
new file mode 100644
index 0000000..f8339d6
--- /dev/null
+++ b/src/ui/sf/d/artifacts-simple_cb.cc
@@ -0,0 +1,22 @@
+/*
+ *       File name:  ui/sf/d/artifacts-simple_cb.cc
+ *         Project:  Aghermann
+ *          Author:  Andrei Zavada <johnhommer at gmail.com>
+ * Initial version:  2013-01-26
+ *
+ *         Purpose:  scoring facility: simple artifact detection dialog callbacks
+ *
+ *         License:  GPL
+ */
+
+#include "ui/misc.hh"
+#include "artifacts-simple.hh"
+
+using namespace std;
+using namespace aghui;
+
+
+
+// Local Variables:
+// indent-tabs-mode: 8
+// End:
diff --git a/src/ui/sf/d/artifacts.hh b/src/ui/sf/d/artifacts.hh
index 5e6122d..4af01e3 100644
--- a/src/ui/sf/d/artifacts.hh
+++ b/src/ui/sf/d/artifacts.hh
@@ -9,8 +9,8 @@
  *         License:  GPL
  */
 
-#ifndef _AGH_UI_SF_ARTIFACTS_H
-#define _AGH_UI_SF_ARTIFACTS_H
+#ifndef _AGH_UI_SF_D_ARTIFACTS_H
+#define _AGH_UI_SF_D_ARTIFACTS_H
 
 #include <list>
 
@@ -125,7 +125,7 @@ void bSFADApply_clicked_cb( GtkButton*, gpointer);
 void bSFADCancel_clicked_cb( GtkButton*, gpointer);
 }
 
-#endif // _AGH_UI_SF_ARTIFACTS_H
+#endif // _AGH_UI_SF_D_ARTIFACTS_H
 
 // Local Variables:
 // indent-tabs-mode: 8
diff --git a/src/ui/sf/d/filters.hh b/src/ui/sf/d/filters.hh
index 2cd2844..2f5dfb3 100644
--- a/src/ui/sf/d/filters.hh
+++ b/src/ui/sf/d/filters.hh
@@ -9,8 +9,8 @@
  *         License:  GPL
  */
 
-#ifndef _AGH_UI_SF_FILTERS_H
-#define _AGH_UI_SF_FILTERS_H
+#ifndef _AGH_UI_SF_D_FILTERS_H
+#define _AGH_UI_SF_D_FILTERS_H
 
 #include <gtk/gtk.h>
 
@@ -71,7 +71,7 @@ void eSFFilterHighPassCutoff_value_changed_cb( GtkSpinButton*, gpointer);
 void eSFFilterLowPassCutoff_value_changed_cb( GtkSpinButton*, gpointer);
 }
 
-#endif // _AGH_UI_SF_FILTERS_H
+#endif // _AGH_UI_SF_D_FILTERS_H
 
 // Local Variables:
 // indent-tabs-mode: 8
diff --git a/src/ui/sf/d/patterns-construct.cc b/src/ui/sf/d/patterns-construct.cc
index e32f627..24cf66a 100644
--- a/src/ui/sf/d/patterns-construct.cc
+++ b/src/ui/sf/d/patterns-construct.cc
@@ -30,6 +30,12 @@ SPatternsDialogWidgets (SScoringFacility& SF)
 	     !AGH_GBGETOBJ (GtkScrolledWindow,	swSFFDThing) ||
 	     !AGH_GBGETOBJ (GtkDrawingArea,	daSFFDField) ||
 	     !AGH_GBGETOBJ (GtkMenu,		iiSFFDField) ||
+	     !AGH_GBGETOBJ (GtkMenu,		iiSFFDFieldProfileTypes) ||
+	     !AGH_GBGETOBJ (GtkCheckMenuItem,	iSFFDFieldDrawMatchIndex) ||
+	     !AGH_GBGETOBJ (GtkRadioMenuItem,	iSFFDFieldProfileTypeRaw) ||
+	     !AGH_GBGETOBJ (GtkRadioMenuItem,	iSFFDFieldProfileTypePSD) ||
+	     !AGH_GBGETOBJ (GtkRadioMenuItem,	iSFFDFieldProfileTypeMC)  ||
+	     !AGH_GBGETOBJ (GtkRadioMenuItem,	iSFFDFieldProfileTypeSWU) ||
 	     !AGH_GBGETOBJ (GtkScrolledWindow,	swSFFDField) ||
 	     !AGH_GBGETOBJ (GtkTable,		cSFFDSearchButton) ||
 	     !AGH_GBGETOBJ (GtkTable,		cSFFDAgainButton) ||
@@ -52,6 +58,7 @@ SPatternsDialogWidgets (SScoringFacility& SF)
 	     !AGH_GBGETOBJ (GtkSpinButton,	eSFFDParameterB) ||
 	     !AGH_GBGETOBJ (GtkSpinButton,	eSFFDParameterC) ||
 	     !AGH_GBGETOBJ (GtkSpinButton,	eSFFDParameterD) ||
+	     !AGH_GBGETOBJ (GtkSpinButton,	eSFFDIncrement) ||
 	     !AGH_GBGETOBJ (GtkHBox,		cSFFDLabelBox) ||
 	     !AGH_GBGETOBJ (GtkLabel,		lSFFDParametersBrief) ||
 	     !AGH_GBGETOBJ (GtkLabel,		lSFFDFoundInfo) ||
@@ -61,7 +68,8 @@ SPatternsDialogWidgets (SScoringFacility& SF)
 	     !AGH_GBGETOBJ (GtkEntry,		eSFFDPatternSaveName) ||
 	     !AGH_GBGETOBJ (GtkToggleButton,	eSFFDPatternSaveOriginSubject) ||
 	     !AGH_GBGETOBJ (GtkToggleButton,	eSFFDPatternSaveOriginExperiment) ||
-	     !AGH_GBGETOBJ (GtkToggleButton,	eSFFDPatternSaveOriginUser) )
+	     !AGH_GBGETOBJ (GtkToggleButton,	eSFFDPatternSaveOriginUser) ||
+	     !AGH_GBGETOBJ (GtkButton,		bSFFDPatternSaveOK) )
 		throw runtime_error ("Failed to construct SF widgets (9)");
 
 	gtk_combo_box_set_model_properly( eSFFDPatternList, mSFFDPatterns);
@@ -74,6 +82,7 @@ SPatternsDialogWidgets (SScoringFacility& SF)
 
 	G_CONNECT_2 (wSFFD, configure, event);
 	G_CONNECT_1 (daSFFDThing, draw);
+	G_CONNECT_3 (daSFFDThing, button, press, event);
 	G_CONNECT_2 (daSFFDThing, scroll, event);
 	G_CONNECT_1 (daSFFDField, draw);
 	G_CONNECT_2 (daSFFDField, scroll, event);
@@ -84,6 +93,8 @@ SPatternsDialogWidgets (SScoringFacility& SF)
 	G_CONNECT_1 (bSFFDProfileRevert, clicked);
 	G_CONNECT_1 (bSFFDSearch, clicked);
 	G_CONNECT_1 (bSFFDAgain, clicked);
+	G_CONNECT_1 (eSFFDPatternSaveName, changed);
+	G_CONNECT_1 (iSFFDFieldDrawMatchIndex, toggled);
 
 	for ( auto& W : {eSFFDEnvTightness,
 			 eSFFDBandPassFrom, eSFFDBandPassUpto, eSFFDBandPassOrder,
@@ -91,10 +102,23 @@ SPatternsDialogWidgets (SScoringFacility& SF)
 		g_signal_connect( W, "value-changed",
 				  (GCallback)eSFFD_any_pattern_value_changed_cb,
 				  this);
-	for ( auto& W : {eSFFDParameterA, eSFFDParameterB, eSFFDParameterC, eSFFDParameterD} )
+	for ( auto& W : {eSFFDParameterA, eSFFDParameterB, eSFFDParameterC, eSFFDParameterD} ) {
 		g_signal_connect( W, "value-changed",
 				  (GCallback)eSFFD_any_criteria_value_changed_cb,
 				  this);
+		g_signal_connect( W, "focus-in-event",
+				  (GCallback)eSFFD_any_criteria_focus_in_event_cb,
+				  this);
+	}
+	for ( auto& W : {eSFFDPatternSaveOriginUser, eSFFDPatternSaveOriginExperiment, eSFFDPatternSaveOriginSubject} )
+		g_signal_connect( W, "toggled",
+				  (GCallback)eSFFD_any_pattern_origin_toggled_cb,
+				  this);
+	for ( auto& W : {iSFFDFieldProfileTypeRaw, iSFFDFieldProfileTypePSD, iSFFDFieldProfileTypeMC, iSFFDFieldProfileTypeSWU} )
+		g_signal_connect( W, "toggled",
+				  (GCallback)iSFFD_any_field_profile_type_toggled_cb,
+				  this);
+
 
 	G_CONNECT_1 (wSFFD, show);
 	G_CONNECT_1 (wSFFD, hide);
diff --git a/src/ui/sf/d/patterns-draw.cc b/src/ui/sf/d/patterns-draw.cc
index 5364641..f561fd1 100644
--- a/src/ui/sf/d/patterns-draw.cc
+++ b/src/ui/sf/d/patterns-draw.cc
@@ -20,8 +20,9 @@ void
 aghui::SScoringFacility::SPatternsDialog::
 set_thing_da_width( int width)
 {
+	static int scrollbar_width = 15;
 	g_object_set( (GObject*)daSFFDThing,
-		      "width-request", da_thing_wd = max( width+5, 600),
+		      "width-request", da_thing_wd = max( width-scrollbar_width, 600),
 		      "height-request", da_thing_ht,
 		      NULL);
 }
@@ -30,8 +31,9 @@ void
 aghui::SScoringFacility::SPatternsDialog::
 set_field_da_width( int width)
 {
+	static int scrollbar_width = 15;
 	g_object_set( (GObject*)daSFFDField,
-		      "width-request", da_field_wd = max( width+5, 600),
+		      "width-request", da_field_wd = max( width-scrollbar_width, 600),
 		      "height-request", da_field_ht,
 		      NULL);
 }
@@ -43,7 +45,7 @@ aghui::SScoringFacility::SPatternsDialog::
 draw_thing( cairo_t *cr)
 {
 	if ( current_pattern == patterns.end() ) {
-		aghui::cairo_put_banner( cr, da_thing_wd, da_thing_ht, "(select a pattern)");
+		aghui::cairo_put_banner( cr, da_thing_wd, da_thing_ht, "(make a selection)");
 		return;
 	}
 
@@ -162,16 +164,28 @@ draw_field( cairo_t *cr)
       // field
 	_p._p.CwB[SExpDesignUI::TColour::sf_profile_psd].set_source_rgba( cr, .5);
 	cairo_set_line_width( cr, 1.);
-	cairo_move_to( cr, 0, da_field_ht/2);
-	auto& profile = field_channel->which_profile( field_profile_type);
-	aghui::cairo_draw_signal(
-		cr,
-		profile, 0, profile.size(),
-		da_field_wd, 0., da_field_ht/2,
-		field_display_scale,
-		1, TDrawSignalDirection::forward, true);
-	cairo_line_to( cr, da_field_wd, da_field_ht/2);
-	cairo_fill( cr);
+
+	auto profile_with_corrected_type = field_channel->which_profile( field_profile_type);
+	field_profile_type = get<0>(profile_with_corrected_type);
+	auto& profile = get<1>(profile_with_corrected_type);
+	if ( field_profile_type == metrics::TType::raw )
+		aghui::cairo_draw_envelope(
+			cr,
+			profile, 0, profile.size(),
+			da_field_wd, 0., da_field_ht/4,
+			field_display_scale);
+	else {
+		aghui::cairo_draw_signal(
+			cr,
+			profile, 0, profile.size(),
+			da_field_wd, 0., da_field_ht/2,
+			field_display_scale,
+			1, TDrawSignalDirection::forward, true);
+		cairo_line_to( cr, da_field_wd, da_field_ht/2);
+		cairo_line_to( cr, 0, da_field_ht/2);
+		cairo_close_path( cr);
+		cairo_fill( cr);
+	}
 	cairo_stroke( cr);
 
       // occurrences
@@ -186,7 +200,7 @@ draw_field( cairo_t *cr)
 
 			cairo_rectangle(
 				cr,
-				x - 1, da_field_ht * .75 - 5,
+				x - 1, da_field_ht/2 + 5,
 				2, 10);
 			cairo_fill( cr);
 			cairo_stroke( cr);
@@ -196,23 +210,29 @@ draw_field( cairo_t *cr)
 			cr, da_field_wd, da_field_ht / .75, "Nothing found");
 
       // diff line with degree of criteria attainment
-	cairo_set_line_width( cr, .5);
+	cairo_set_line_width( cr, .2);
 	valarray<TFloat> tmp (diff_line.size());
 
-#define KEKE(R,G,B,N)		 \
-	cairo_set_source_rgba( cr, R, G, B, 1.); \
-	for ( size_t i = 0; i < diff_line.size(); ++i ) tmp[i] = get<N>(diff_line[i]); \
-	aghui::cairo_draw_signal( cr, tmp, 0, tmp.size(), da_field_wd, 0., da_field_ht-20, get<N>(criteria) / 20); \
+	cairo_move_to( cr, 0, da_field_ht-25);
+	cairo_rel_line_to( cr, da_field_wd, 0);
 	cairo_stroke( cr);
 
-	// FAFA;
-	// KEKE(.1, .5, .8, 0);
-	// FAFA;
-	// KEKE(.5, .1, .8, 1);
-	// FAFA;
-	// KEKE(.1, .8, .5, 2);
-	// FAFA;
-	// KEKE(.5, .8, .1, 3);
+#define KEKE(R,G,B,N)							\
+	{cairo_set_source_rgba( cr, R, G, B, .5);			\
+		cairo_move_to( cr, 0, da_field_ht-5);			\
+		size_t inc = max((int)(increment * current_pattern->samplerate), 1); \
+		for ( size_t i = 0; i < diff_line.size(); i += inc )	\
+			cairo_line_to( cr, ((double)i)/diff_line.size() * da_field_wd, \
+				       da_field_ht - 5 - get<N>(criteria) / get<N>(diff_line[i]) * 20); \
+	cairo_stroke( cr); }
+
+	if ( draw_match_index )
+		switch ( now_tweaking ) {
+		case 1: KEKE(.1, .5, .8, 0); break;
+		case 2: KEKE(.5, .1, .8, 1); break;
+		case 3: KEKE(.1, .8, .5, 2); break;
+		case 4: KEKE(.5, .8, .1, 3); break;
+		}
 #undef KEKE
 }
 
diff --git a/src/ui/sf/d/patterns-enumerate.cc b/src/ui/sf/d/patterns-profiles.cc
similarity index 90%
rename from src/ui/sf/d/patterns-enumerate.cc
rename to src/ui/sf/d/patterns-profiles.cc
index 173655a..4e9de4a 100644
--- a/src/ui/sf/d/patterns-enumerate.cc
+++ b/src/ui/sf/d/patterns-profiles.cc
@@ -1,5 +1,5 @@
 /*
- *       File name:  ui/sf/d/patterns-enumerate.cc
+ *       File name:  ui/sf/d/patterns-profiles.cc
  *         Project:  Aghermann
  *          Author:  Andrei Zavada <johnhommer at gmail.com>
  * Initial version:  2013-01-16
@@ -16,14 +16,24 @@
 using namespace std;
 
 
-void
+int
 aghui::SScoringFacility::SPatternsDialog::
 import_from_selection( SScoringFacility::SChannel& field)
 {
 	// double check, possibly redundant after due check in callback
+	double	run_time = field.selection_end_time - field.selection_start_time;
 	size_t	run = field.selection_end - field.selection_start;
 	if ( run == 0 )
-		return;
+		return -1;
+	if ( run_time > 60. ) {
+		aghui::pop_ok_message( (GtkWindow*)wSFFD, "Selection greater than a minute", "This is surely the single occurrence, I tell you!");
+		return -2;
+	}
+	if ( run_time > 10. and
+	     GTK_RESPONSE_YES !=
+	     aghui::pop_question( (GtkWindow*)wSFFD, "The selection is greater than 10 sec. Sure to proceed with search?") ) {
+		return -3;
+	}
 
 	size_t	context_before = // agh::alg::ensure_within(
 		(field.selection_start < current_pattern->context_pad)
@@ -45,6 +55,7 @@ import_from_selection( SScoringFacility::SChannel& field)
 	 : (patterns.push_back( pattern::SPattern<TFloat> ()), patterns.back())
 		) = tim;
 	current_pattern = prev(patterns.end());
+	populate_combo();
 
 	field_channel = &field;
 
@@ -57,6 +68,8 @@ import_from_selection( SScoringFacility::SChannel& field)
 	setup_controls_for_find();
 
 	gtk_widget_queue_draw( (GtkWidget*)daSFFDThing);
+
+	return 0;
 }
 
 
diff --git a/src/ui/sf/d/patterns-profiles_cb.cc b/src/ui/sf/d/patterns-profiles_cb.cc
new file mode 100644
index 0000000..64c368a
--- /dev/null
+++ b/src/ui/sf/d/patterns-profiles_cb.cc
@@ -0,0 +1,178 @@
+/*
+ *       File name:  ui/sf/d/patterns-profiles_cb.cc
+ *         Project:  Aghermann
+ *          Author:  Andrei Zavada <johnhommer at gmail.com>
+ * Initial version:  2011-07-03
+ *
+ *         Purpose:  scoring facility patterns
+ *
+ *         License:  GPL
+ */
+
+#include <sys/time.h>
+
+#include "ui/misc.hh"
+#include "patterns.hh"
+
+
+using namespace std;
+
+using namespace aghui;
+
+
+extern "C" {
+
+void
+eSFFDPatternList_changed_cb( GtkComboBox *combo, gpointer userdata)
+{
+	auto& FD = *(SScoringFacility::SPatternsDialog*)userdata;
+
+	if ( FD.current_pattern != FD.patterns.end() ) {
+		FD.current_pattern->Pp = FD.Pp2;
+		FD.current_pattern->criteria = FD.criteria;
+	}
+
+	gint ci = gtk_combo_box_get_active( combo);
+	if ( ci != -1 ) {
+		FD.current_pattern = FD.pattern_by_idx(ci);
+		FD.Pp2 = FD.current_pattern->Pp;
+		FD.criteria = FD.current_pattern->criteria;
+		FD.atomic_up();
+		FD.thing_display_scale = FD.field_channel->signal_display_scale;
+	} else
+		gtk_label_set_text( FD.lSFFDParametersBrief, "");
+
+	FD.setup_controls_for_find();
+	FD.set_profile_manage_buttons_visibility();
+
+	gtk_widget_queue_draw( (GtkWidget*)FD.daSFFDThing);
+}
+
+
+
+void
+bSFFDProfileSave_clicked_cb( GtkButton*, gpointer userdata)
+{
+	auto& FD = *(SScoringFacility::SPatternsDialog*)userdata;
+
+	g_signal_emit_by_name( FD.eSFFDPatternSaveName, "changed");
+
+	if ( gtk_dialog_run( FD.wSFFDPatternSave) == GTK_RESPONSE_OK ) {
+		pattern::SPattern<TFloat> P (*FD.current_pattern);
+		P.name = gtk_entry_get_text( FD.eSFFDPatternSaveName);
+		P.origin = gtk_toggle_button_get_active( FD.eSFFDPatternSaveOriginSubject)
+			? pattern::TOrigin::subject
+			: gtk_toggle_button_get_active( FD.eSFFDPatternSaveOriginExperiment)
+			? pattern::TOrigin::experiment
+			: pattern::TOrigin::user;
+		P.saved = false;
+
+		if ( FD.current_pattern->origin == pattern::TOrigin::transient ) // replace unnamed
+			FD.patterns.back() = P;
+		else {
+			auto found = find( FD.patterns.begin(), FD.patterns.end(), P);
+			if ( found == FD.patterns.end() )
+				FD.patterns.insert( FD.current_pattern, move(P));
+			else
+				*(FD.current_pattern = found) = P;
+		}
+
+		FD.populate_combo();
+		FD.set_profile_manage_buttons_visibility();
+	}
+}
+
+
+inline namespace {
+void
+hildebranden(gpointer userdata)
+{
+	auto& FD = *(SScoringFacility::SPatternsDialog*)userdata;
+
+	gtk_widget_set_sensitive(
+		(GtkWidget*)FD.bSFFDPatternSaveOK,
+		gtk_entry_get_text_length( FD.eSFFDPatternSaveName) > 0);
+
+	auto this_name = gtk_entry_get_text( FD.eSFFDPatternSaveName);
+	auto this_origin = gtk_toggle_button_get_active( FD.eSFFDPatternSaveOriginSubject)
+			? pattern::TOrigin::subject
+			: gtk_toggle_button_get_active( FD.eSFFDPatternSaveOriginExperiment)
+			? pattern::TOrigin::experiment
+			: pattern::TOrigin::user;
+
+	bool overwriting =
+		find_if( FD.patterns.begin(), FD.patterns.end(),
+			 [&] ( const pattern::SPattern<TFloat>& P) -> bool
+			 { return P.name == this_name && P.origin == this_origin; })
+		!= FD.patterns.end();
+	gtk_button_set_label(
+		FD.bSFFDPatternSaveOK,
+		overwriting ? "Overwrite" : "Save");
+}
+}
+
+void eSFFDPatternSaveName_changed_cb( GtkEditable*, gpointer userdata)
+{
+	hildebranden(userdata);
+}
+
+void
+eSFFD_any_pattern_origin_toggled_cb(GtkRadioButton*, gpointer userdata)
+{
+	hildebranden(userdata);
+}
+
+
+void
+bSFFDProfileDiscard_clicked_cb( GtkButton*, gpointer userdata)
+{
+	auto& FD = *(SScoringFacility::SPatternsDialog*)userdata;
+
+	gint ci = gtk_combo_box_get_active( FD.eSFFDPatternList);
+
+	assert ( FD.current_pattern != FD.patterns.end() );
+	assert ( FD.current_pattern->origin != pattern::TOrigin::transient );
+	assert ( ci != -1 );
+	assert ( ci < (int)FD.patterns.size() );
+
+	FD.discard_current_pattern();
+
+	if ( not FD.patterns.empty() ) {
+		FD.Pp2 = FD.current_pattern->Pp;
+		FD.criteria = FD.current_pattern->criteria;
+
+		FD.atomic_up();
+	}
+
+	FD.populate_combo();
+	FD.set_profile_manage_buttons_visibility();
+	FD.setup_controls_for_find();
+
+	gtk_widget_queue_draw( (GtkWidget*)FD.daSFFDThing);
+}
+
+
+void
+bSFFDProfileRevert_clicked_cb( GtkButton*, gpointer userdata)
+{
+	auto& FD = *(SScoringFacility::SPatternsDialog*)userdata;
+
+	assert ( FD.current_pattern != FD.patterns.end() );
+	assert ( FD.current_pattern->origin != pattern::TOrigin::transient );
+
+	FD.Pp2 = FD.current_pattern->Pp;
+	FD.criteria = FD.current_pattern->criteria;
+
+	FD.atomic_up();
+
+	FD.set_profile_manage_buttons_visibility();
+}
+
+} // extern "C"
+
+
+
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
diff --git a/src/ui/sf/d/patterns.cc b/src/ui/sf/d/patterns.cc
index fca1524..c0ed573 100644
--- a/src/ui/sf/d/patterns.cc
+++ b/src/ui/sf/d/patterns.cc
@@ -1,11 +1,10 @@
-// ;-*-C++-*-
 /*
- *       File name:  ui/sf/sf-patterns.cc
+ *       File name:  ui/sf/d/patterns.cc
  *         Project:  Aghermann
  *          Author:  Andrei Zavada <johnhommer at gmail.com>
  * Initial version:  2011-01-14
  *
- *         Purpose:  scoring facility patterns
+ *         Purpose:  scoring facility Patterns dialog crazy state machine
  *
  *         License:  GPL
  */
@@ -28,15 +27,15 @@ aghui::SScoringFacility::SPatternsDialog::
 SPatternsDialog (SScoringFacility& parent)
       : SPatternsDialogWidgets (parent),
 	Pp2 {.25,  0., 1.5, 1,  .1, .5, 3},
-	cpattern (nullptr),
-	increment (.05),
+	increment (.03),
 	field_profile_type (metrics::TType::mc),
+	suppress_redraw (false),
 	draw_details (true),
+	draw_match_index (true),
 	_p (parent)
 {
-	suppress_w_v = true;
 	W_V.reg( eSFFDEnvTightness, 	&Pp2.env_scope);
-	W_V.reg( eSFFDBandPassOrder, &Pp2.bwf_order);
+	W_V.reg( eSFFDBandPassOrder,	&Pp2.bwf_order);
 	W_V.reg( eSFFDBandPassFrom, 	&Pp2.bwf_ffrom);
 	W_V.reg( eSFFDBandPassUpto, 	&Pp2.bwf_fupto);
 	W_V.reg( eSFFDDZCDFStep, 	&Pp2.dzcdf_step);
@@ -48,8 +47,9 @@ SPatternsDialog (SScoringFacility& parent)
 	W_V.reg( eSFFDParameterC, 	&get<2>(criteria));
 	W_V.reg( eSFFDParameterD, 	&get<3>(criteria));
 
-	W_V.up();
-	suppress_w_v = false;
+	W_V.reg( eSFFDIncrement, 	&increment);
+
+	atomic_up();
 
 	load_patterns();
 }
@@ -59,8 +59,6 @@ aghui::SScoringFacility::SPatternsDialog::
 {
 	save_patterns();
 
-	assert ( cpattern == nullptr );
-
 	// g_object_unref( mPatterns);
 	gtk_widget_destroy( (GtkWidget*)wSFFDPatternSave);
 	gtk_widget_destroy( (GtkWidget*)wSFFD);
@@ -88,28 +86,23 @@ void
 aghui::SScoringFacility::SPatternsDialog::
 search()
 {
-	if ( unlikely
-	     (not field_channel or current_pattern == patterns.end()) )
-		return;
+	assert (field_channel and current_pattern != patterns.end());
 
 	if ( field_channel != field_channel_saved )
 		field_channel_saved = field_channel;
 
-	cpattern = new pattern::CPatternTool<TFloat>
+	pattern::CPatternTool<TFloat> cpattern
 		({current_pattern->thing, current_pattern->samplerate},
 		 current_pattern->context_before, current_pattern->context_after,
 		 Pp2); // use this for the case when modiified current_pattern changes have not been committed
 	diff_line =
-		(cpattern->do_search(
+		(cpattern.do_search(
 			field_channel->signal_envelope( Pp2.env_scope).first,
 			field_channel->signal_envelope( Pp2.env_scope).second,
 			field_channel->signal_bandpass( Pp2.bwf_ffrom, Pp2.bwf_fupto, Pp2.bwf_order),
 			field_channel->signal_dzcdf( Pp2.dzcdf_step, Pp2.dzcdf_sigma, Pp2.dzcdf_smooth),
 			increment * current_pattern->samplerate),
-		 cpattern->diff);
-
-	delete cpattern;
-	cpattern = nullptr; // don't really care though
+		 cpattern.diff);
 }
 
 
@@ -122,7 +115,7 @@ find_occurrences()
 
 	occurrences.resize(0);
 	size_t inc = max((int)(increment * current_pattern->samplerate), 1);
-	for ( size_t i = 0; i < diff_line.size(); i += inc )
+	for ( size_t i = 0; i < diff_line.size() - current_pattern->thing.size(); i += inc )
 		if ( diff_line[i].good_enough( criteria) ) {
 			occurrences.push_back(i);
 			i +=  // avoid overlapping occurrences *and* ensure we hit the stride
@@ -131,6 +124,7 @@ find_occurrences()
 
 	restore_annotations();
 	occurrences_to_annotations();
+	_p.queue_redraw_all();
 
 	return occurrences.size();
 }
@@ -144,8 +138,7 @@ occurrences_to_annotations()
 		sigfile::mark_annotation(
 			field_channel->annotations,
 			occurrences[o], occurrences[o] + current_pattern->pattern_size_essential(),
-			(snprintf_buf("%s (%zu)", current_pattern->name.c_str(), o), __buf__));
-	_p._p.populate_mGlobalAnnotations();
+			(snprintf_buf("%s (%zu)", current_pattern->name.c_str(), o+1), __buf__));
 }
 
 void
@@ -153,7 +146,6 @@ aghui::SScoringFacility::SPatternsDialog::
 save_annotations()
 {
 	saved_annotations = field_channel->annotations;
-	_p._p.populate_mGlobalAnnotations();
 }
 
 void
@@ -162,7 +154,6 @@ restore_annotations()
 {
 	field_channel->annotations = saved_annotations;
 	saved_annotations.clear();
-	_p._p.populate_mGlobalAnnotations();
 }
 
 
@@ -183,6 +174,8 @@ setup_controls_for_find()
 	gtk_widget_set_visible( (GtkWidget*)swSFFDField, FALSE);
 	gtk_widget_set_visible( (GtkWidget*)cSFFDCriteria, FALSE);
 
+	gtk_widget_set_sensitive( (GtkWidget*)eSFFDPatternList, TRUE);
+
 	gtk_label_set_markup( lSFFDFoundInfo, "");
 }
 
@@ -198,6 +191,8 @@ setup_controls_for_wait()
 
 	gtk_widget_set_visible( (GtkWidget*)swSFFDField, FALSE);
 	gtk_widget_set_visible( (GtkWidget*)cSFFDCriteria, FALSE);
+
+	gtk_widget_set_sensitive( (GtkWidget*)eSFFDPatternList, FALSE);
 }
 
 void
@@ -212,6 +207,8 @@ setup_controls_for_tune()
 
 	gtk_widget_set_visible( (GtkWidget*)swSFFDField, TRUE);
 	gtk_widget_set_visible( (GtkWidget*)cSFFDCriteria, TRUE);
+
+	gtk_widget_set_sensitive( (GtkWidget*)eSFFDPatternList, FALSE);
 }
 
 
@@ -222,8 +219,8 @@ set_profile_manage_buttons_visibility()
 {
 	bool	have_any = current_pattern != patterns.end(),
 		is_transient = have_any && current_pattern->origin == pattern::TOrigin::transient,
-		is_modified  = have_any && not (current_pattern->Pp == Pp2);
-	gtk_widget_set_visible( (GtkWidget*)bSFFDProfileSave, have_any and is_transient);
+		is_modified  = have_any && not (current_pattern->Pp == Pp2) and not (current_pattern->criteria == criteria);
+	gtk_widget_set_visible( (GtkWidget*)bSFFDProfileSave, have_any);
 	gtk_widget_set_visible( (GtkWidget*)bSFFDProfileRevert, have_any and not is_transient and is_modified);
 	gtk_widget_set_visible( (GtkWidget*)bSFFDProfileDiscard, have_any and not is_transient);
 }
@@ -274,4 +271,37 @@ nearest_occurrence( double x) const
 }
 
 
+
+
+void
+aghui::SScoringFacility::SPatternsDialog::
+update_field_check_menu_items()
+{
+	suppress_redraw = true;
+	gtk_check_menu_item_set_active( iSFFDFieldDrawMatchIndex, draw_match_index);
+
+	if ( not sigfile::SChannel::signal_type_is_fftable( field_channel->type) ) {
+		field_profile_type = metrics::TType::raw;
+		gtk_widget_set_visible( (GtkWidget*)iiSFFDFieldProfileTypes, FALSE);
+	} else
+		gtk_widget_set_visible( (GtkWidget*)iiSFFDFieldProfileTypes, TRUE);
+
+	switch ( field_profile_type ) {
+	case metrics::TType::raw:
+		gtk_check_menu_item_set_active( (GtkCheckMenuItem*)iSFFDFieldProfileTypeRaw, TRUE);
+		break;
+	case metrics::TType::psd:
+		gtk_check_menu_item_set_active( (GtkCheckMenuItem*)iSFFDFieldProfileTypePSD, TRUE);
+		break;
+	case metrics::TType::mc:
+		gtk_check_menu_item_set_active( (GtkCheckMenuItem*)iSFFDFieldProfileTypeMC, TRUE);
+		break;
+	case metrics::TType::swu:
+		gtk_check_menu_item_set_active( (GtkCheckMenuItem*)iSFFDFieldProfileTypeSWU, TRUE);
+		break;
+	}
+
+	suppress_redraw = false;
+}
+
 // eof
diff --git a/src/ui/sf/d/patterns.hh b/src/ui/sf/d/patterns.hh
index 3f1af20..b445803 100644
--- a/src/ui/sf/d/patterns.hh
+++ b/src/ui/sf/d/patterns.hh
@@ -9,8 +9,8 @@
  *         License:  GPL
  */
 
-#ifndef _AGH_UI_SF_PATTERNS_H
-#define _AGH_UI_SF_PATTERNS_H
+#ifndef _AGH_UI_SF_D_PATTERNS_H
+#define _AGH_UI_SF_D_PATTERNS_H
 
 #include "patterns/patterns.hh"
 #include "ui/sf/sf.hh"
@@ -31,7 +31,6 @@ struct SPatternsDialogWidgets {
 
 	GtkBuilder *builder;
 
-	// find/patterns dialog
 	GtkListStore
 		*mSFFDPatterns;
 	GtkDialog
@@ -51,7 +50,15 @@ struct SPatternsDialogWidgets {
 	GtkDrawingArea
 		*daSFFDThing,
 		*daSFFDField;
-	GtkMenu	*iiSFFDField;
+	GtkMenu	*iiSFFDField,
+		*iiSFFDFieldProfileTypes;
+	GtkCheckMenuItem
+		*iSFFDFieldDrawMatchIndex;
+	GtkRadioMenuItem
+		*iSFFDFieldProfileTypeRaw,
+		*iSFFDFieldProfileTypePSD,
+		*iSFFDFieldProfileTypeMC,
+		*iSFFDFieldProfileTypeSWU;
 	GtkButton
 		*bSFFDSearch, *bSFFDAgain,
 		*bSFFDProfileSave, *bSFFDProfileDiscard, *bSFFDProfileRevert;
@@ -60,7 +67,8 @@ struct SPatternsDialogWidgets {
 		*eSFFDBandPassFrom, *eSFFDBandPassUpto, *eSFFDBandPassOrder,
 		*eSFFDDZCDFStep, *eSFFDDZCDFSigma, *eSFFDDZCDFSmooth,
 		*eSFFDParameterA, *eSFFDParameterB,
-		*eSFFDParameterC, *eSFFDParameterD;
+		*eSFFDParameterC, *eSFFDParameterD,
+		*eSFFDIncrement;
 	GtkHBox
 		*cSFFDLabelBox;
 	GtkLabel
@@ -74,6 +82,8 @@ struct SPatternsDialogWidgets {
 		*eSFFDPatternSaveOriginSubject,
 		*eSFFDPatternSaveOriginExperiment,
 		*eSFFDPatternSaveOriginUser;
+	GtkButton
+		*bSFFDPatternSaveOK;
 	gulong	eSFFDChannel_changed_cb_handler_id,
 		eSFFDPatternList_changed_cb_handler_id;
 };
@@ -96,7 +106,7 @@ struct SScoringFacility::SPatternsDialog
 	list<pattern::SPattern<TFloat>>::iterator
 	pattern_by_idx( size_t);
 
-	void import_from_selection( SScoringFacility::SChannel&);
+	int import_from_selection( SScoringFacility::SChannel&);
 	void load_patterns();
 	void save_patterns();
 	void discard_current_pattern();
@@ -105,8 +115,6 @@ struct SScoringFacility::SPatternsDialog
       // finding tool
   	pattern::SPatternPPack<TFloat>
 		Pp2;
-	pattern::CPatternTool<TFloat>
-		*cpattern;
 	double	increment; // in seconds
 
       // matches
@@ -120,6 +128,7 @@ struct SScoringFacility::SPatternsDialog
 	void search();
 	size_t find_occurrences();
 	size_t nearest_occurrence( double) const;
+	int	now_tweaking; // limit draw similarity index to this item
 
       // field
 	SScoringFacility::SChannel
@@ -133,10 +142,13 @@ struct SScoringFacility::SPatternsDialog
 
 	metrics::TType
 		field_profile_type; // where appropriate; otherwise draw compressed raw
+	void update_field_check_menu_items();
 
       // draw
-	bool	draw_details:1,
-		suppress_w_v:1;
+	bool	suppress_w_v:1,
+		suppress_redraw:1,
+		draw_details:1,
+		draw_match_index:1;
 	void draw_thing( cairo_t*);
 	void draw_field( cairo_t*);
 	float	thing_display_scale,
@@ -145,6 +157,12 @@ struct SScoringFacility::SPatternsDialog
       // widgets
 	SUIVarCollection
 		W_V;
+	void atomic_up()
+		{
+			suppress_w_v = true;
+			W_V.up();
+			suppress_w_v = false;
+		}
 
 	void preselect_channel( const char*);
 
@@ -155,7 +173,7 @@ struct SScoringFacility::SPatternsDialog
 
 	static const int
 		da_thing_ht = 200,
-		da_field_ht = 130;
+		da_field_ht = 160;
 	int	da_thing_wd,
 		da_field_wd;
 	void set_thing_da_width( int);
@@ -176,19 +194,29 @@ gboolean daSFFDField_scroll_event_cb( GtkWidget*, GdkEventScroll*, gpointer);
 gboolean daSFFDField_button_press_event_cb( GtkWidget*, GdkEventButton*, gpointer);
 gboolean daSFFDField_motion_notify_event_cb( GtkWidget*, GdkEventMotion*, gpointer);
 gboolean daSFFDThing_draw_cb( GtkWidget*, cairo_t*, gpointer);
+gboolean daSFFDThing_button_press_event_cb( GtkWidget*, GdkEventButton*, gpointer);
 gboolean daSFFDThing_scroll_event_cb( GtkWidget*, GdkEventScroll*, gpointer);
 void bSFFDSearch_clicked_cb( GtkButton*, gpointer);
 void bSFFDAgain_clicked_cb( GtkButton*, gpointer);
 void bSFFDProfileSave_clicked_cb( GtkButton*, gpointer);
 void bSFFDProfileDiscard_clicked_cb( GtkButton*, gpointer);
 void bSFFDProfileRevert_clicked_cb( GtkButton*, gpointer);
-void eSFFD_any_pattern_value_changed_cb( GtkSpinButton*, gpointer);
-void eSFFD_any_criteria_value_changed_cb( GtkSpinButton*, gpointer);
+gboolean eSFFD_any_criteria_focus_in_event_cb(GtkWidget*, GdkEvent*, gpointer);
 void wSFFD_show_cb( GtkWidget*, gpointer);
 void wSFFD_hide_cb( GtkWidget*, gpointer);
 gboolean wSFFD_configure_event_cb( GtkWidget*, GdkEventConfigure*, gpointer);
+void iSFFDFieldDrawMatchIndex_toggled_cb(GtkCheckMenuItem*, gpointer);
+void eSFFDPatternSaveName_changed_cb(GtkEditable*, gpointer);
+
+void eSFFD_any_pattern_origin_toggled_cb(GtkRadioButton*, gpointer);
+void eSFFD_any_pattern_value_changed_cb( GtkSpinButton*, gpointer);
+void eSFFD_any_criteria_value_changed_cb( GtkSpinButton*, gpointer);
+void iSFFD_any_field_profile_type_toggled_cb( GtkRadioMenuItem*, gpointer);
 }
 
-#endif // _AGH_UI_SF_PATTERNS_H
+#endif // _AGH_UI_SF_D_PATTERNS_H
 
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
diff --git a/src/ui/sf/d/patterns_cb.cc b/src/ui/sf/d/patterns_cb.cc
index db6486b..eefbf36 100644
--- a/src/ui/sf/d/patterns_cb.cc
+++ b/src/ui/sf/d/patterns_cb.cc
@@ -1,6 +1,5 @@
-// ;-*-C++-*-
 /*
- *       File name:  ui/sf/sf-patterns_cb.cc
+ *       File name:  ui/sf/d/patterns_cb.cc
  *         Project:  Aghermann
  *          Author:  Andrei Zavada <johnhommer at gmail.com>
  * Initial version:  2011-07-03
@@ -45,6 +44,26 @@ daSFFDField_draw_cb( GtkWidget *wid, cairo_t *cr, gpointer userdata)
 
 
 gboolean
+daSFFDThing_button_press_event_cb( GtkWidget *wid, GdkEventButton *event, gpointer userdata)
+{
+	auto& FD = *(SScoringFacility::SPatternsDialog*)userdata;
+
+	switch ( event->button ) {
+	case 2:
+		FD.thing_display_scale = FD.field_channel->signal_display_scale;
+	    break;
+	default:
+	    break;
+	}
+
+	gtk_widget_queue_draw( wid);
+
+	return TRUE;
+}
+
+
+
+gboolean
 daSFFDThing_scroll_event_cb( GtkWidget *wid, GdkEventScroll *event, gpointer userdata)
 {
 	auto& FD = *(SScoringFacility::SPatternsDialog*)userdata;
@@ -72,6 +91,80 @@ daSFFDThing_scroll_event_cb( GtkWidget *wid, GdkEventScroll *event, gpointer use
 	return TRUE;
 }
 
+
+
+gboolean
+daSFFDField_button_press_event_cb( GtkWidget *wid, GdkEventButton *event, gpointer userdata)
+{
+	auto& FD = *(SScoringFacility::SPatternsDialog*)userdata;
+	auto& SF = FD._p;
+
+	switch ( event->button ) {
+	case 1:
+		if ( event->y > FD.da_field_ht/2 ) {
+			if ( FD.highlighted_occurrence != (size_t)-1 )
+				SF.set_cur_vpage(
+					((double)FD.occurrences[FD.highlighted_occurrence] / FD.diff_line.size()) * SF.total_vpages());
+		} else
+			SF.set_cur_vpage(
+				((double)event->x/FD.da_field_wd * SF.total_vpages()));
+		gtk_widget_queue_draw( wid);
+	    break;
+	case 3:
+		FD.update_field_check_menu_items();
+		gtk_menu_popup(
+			FD.iiSFFDField,
+			NULL, NULL, NULL, NULL, 3, event->time);
+	    break;
+	}
+
+	return TRUE;
+}
+
+void
+iSFFDFieldDrawMatchIndex_toggled_cb( GtkCheckMenuItem* mitem, gpointer userdata)
+{
+	auto& FD = *(SScoringFacility::SPatternsDialog*)userdata;
+	if ( FD.suppress_redraw )
+		return;
+	FD.draw_match_index = gtk_check_menu_item_get_active( mitem);
+	gtk_widget_queue_draw( (GtkWidget*)FD.daSFFDField);
+}
+
+
+void
+iSFFD_any_field_profile_type_toggled_cb( GtkRadioMenuItem* ritem, gpointer userdata)
+{
+	auto& FD = *(SScoringFacility::SPatternsDialog*)userdata;
+	if ( FD.suppress_redraw )
+		return;
+	if ( not gtk_check_menu_item_get_active( (GtkCheckMenuItem*)ritem) )
+		return; // let the item being turned on handle
+
+	if ( ritem == FD.iSFFDFieldProfileTypeRaw )
+		FD.field_profile_type = metrics::TType::raw;
+	else if ( ritem == FD.iSFFDFieldProfileTypePSD )
+		FD.field_profile_type = metrics::TType::psd;
+	else if ( ritem == FD.iSFFDFieldProfileTypeMC )
+		FD.field_profile_type = metrics::TType::mc;
+	else if ( ritem == FD.iSFFDFieldProfileTypeSWU )
+		FD.field_profile_type = metrics::TType::swu;
+
+	// autoscale
+	auto profile_with_corrected_type =
+		FD.field_channel->which_profile( FD.field_profile_type);
+	auto& profile = get<1>(profile_with_corrected_type);
+	FD.field_display_scale =
+		agh::alg::calibrate_display_scale(
+			profile,
+			profile.size(),
+			FD.da_field_ht/2);
+
+	gtk_widget_queue_draw( (GtkWidget*)FD.daSFFDField);
+}
+
+
+
 gboolean
 daSFFDField_scroll_event_cb( GtkWidget *wid, GdkEventScroll *event, gpointer userdata)
 {
@@ -100,40 +193,21 @@ daSFFDField_scroll_event_cb( GtkWidget *wid, GdkEventScroll *event, gpointer use
 	return TRUE;
 }
 
+
 gboolean
-daSFFDField_button_press_event_cb( GtkWidget *wid, GdkEventButton *event, gpointer userdata)
+daSFFDField_motion_notify_event_cb( GtkWidget *wid, GdkEventMotion *event, gpointer userdata)
 {
 	auto& FD = *(SScoringFacility::SPatternsDialog*)userdata;
-	auto& SF = FD._p;
 
-	switch ( event->button ) {
-	case 1:
-		if ( FD.highlighted_occurrence != (size_t)-1 )
-			SF.set_cur_vpage(
-				((double)FD.occurrences[FD.highlighted_occurrence] / FD.diff_line.size()) * SF.total_vpages());
-	    break;
-	case 3:
-		gtk_menu_popup( FD.iiSFFDField,
-				NULL, NULL, NULL, NULL, 3, event->time);
-	    break;
-	}
-	gtk_widget_queue_draw( wid);
+	auto prev_ho = FD.highlighted_occurrence;
+	if ( prev_ho != (FD.highlighted_occurrence = FD.nearest_occurrence( event->x)) )
+	     gtk_widget_queue_draw( wid);
 
 	return TRUE;
 }
 
 
-gboolean
-daSFFDField_motion_notify_event_cb( GtkWidget *wid, GdkEventMotion *event, gpointer userdata)
-{
-	auto& FD = *(SScoringFacility::SPatternsDialog*)userdata;
-
-	FD.highlighted_occurrence = FD.nearest_occurrence( event->x);
-
-	gtk_widget_queue_draw( wid);
 
-	return TRUE;
-}
 
 
 
@@ -147,23 +221,18 @@ bSFFDSearch_clicked_cb( GtkButton *button, gpointer userdata)
 
 	FD.setup_controls_for_wait();
 	gtk_flush();
+
 	FD.search();
+	FD.save_annotations();
 
-	FD.set_field_da_width( SF.total_pages() * 3);
+	FD.set_field_da_width( SF.total_pages() * SF.pagesize() / 3600 * SF._p.timeline_pph);
 
 	FD.field_display_scale =
-		(FD.field_channel->type == sigfile::SChannel::TType::eeg)
-		? agh::alg::calibrate_display_scale(
-			FD.field_channel->which_profile(FD.field_profile_type),
-			SF.total_pages(),
-			FD.da_field_ht)
-		: agh::alg::calibrate_display_scale(
-			FD.field_channel->signal_filtered,
+		agh::alg::calibrate_display_scale(
+			get<1>(FD.field_channel->which_profile(FD.field_profile_type)),
 			SF.total_pages(),
 			FD.da_field_ht);
 
-	FD.save_annotations();
-
 	FD.setup_controls_for_tune();
 	snprintf_buf( "A: <b>%g</b>  "
 		      "B: <b>%g</b>/<b>%g</b>/<b>%d</b>  "
@@ -172,10 +241,16 @@ bSFFDSearch_clicked_cb( GtkButton *button, gpointer userdata)
 		      FD.Pp2.bwf_ffrom, FD.Pp2.bwf_fupto, FD.Pp2.bwf_order,
 		      FD.Pp2.dzcdf_step, FD.Pp2.dzcdf_sigma, FD.Pp2.dzcdf_smooth);
 	gtk_label_set_markup( FD.lSFFDParametersBrief, __buf__);
+
+	gtk_widget_queue_draw( (GtkWidget*)FD.daSFFDField);
+
+	g_signal_emit_by_name( FD.eSFFDParameterA, "value-changed");
 }
 
+
+
 void
-bSFFDAgain_clicked_cb( GtkButton *button, gpointer userdata)
+bSFFDAgain_clicked_cb( GtkButton*, gpointer userdata)
 {
 	auto& FD = *(SScoringFacility::SPatternsDialog*)userdata;
 
@@ -187,7 +262,7 @@ bSFFDAgain_clicked_cb( GtkButton *button, gpointer userdata)
 
 
 void
-eSFFD_any_pattern_value_changed_cb( GtkSpinButton *spinbutton, gpointer userdata)
+eSFFD_any_pattern_value_changed_cb( GtkSpinButton*, gpointer userdata)
 {
 	auto& FD = *(SScoringFacility::SPatternsDialog*)userdata;
 
@@ -212,13 +287,22 @@ timeval_elapsed( const struct timeval &x, const struct timeval &y)
 }
 
 void
-eSFFD_any_criteria_value_changed_cb( GtkSpinButton *spinbutton, gpointer userdata)
+eSFFD_any_criteria_value_changed_cb( GtkSpinButton* button, gpointer userdata)
 {
 	auto& FD = *(SScoringFacility::SPatternsDialog*)userdata;
 
 	if ( FD.suppress_w_v )
 		return;
 
+	if      ( button == FD.eSFFDParameterA )
+		FD.now_tweaking = 1;
+	else if ( button == FD.eSFFDParameterB )
+		FD.now_tweaking = 2;
+	else if ( button == FD.eSFFDParameterC )
+		FD.now_tweaking = 3;
+	else if ( button == FD.eSFFDParameterD )
+		FD.now_tweaking = 4;
+
 	static struct timeval last_criteria_change = {0, 0};
 	struct timeval currently;
 	gettimeofday( &currently, NULL);
@@ -228,8 +312,10 @@ eSFFD_any_criteria_value_changed_cb( GtkSpinButton *spinbutton, gpointer userdat
 		FD.W_V.down();
 		FD.find_occurrences();
 
-		snprintf_buf( "%zu match%s\n",
-			      FD.occurrences.size(), (FD.occurrences.size() == 1) ? "" : "es");
+		snprintf_buf(
+			"%zu match%s in <b>%s</b>",
+			FD.occurrences.size(), (FD.occurrences.size() == 1) ? "" : "es",
+			FD.field_channel->name);
 		gtk_label_set_markup( FD.lSFFDFoundInfo, __buf__);
 
 		FD.set_profile_manage_buttons_visibility();
@@ -238,102 +324,22 @@ eSFFD_any_criteria_value_changed_cb( GtkSpinButton *spinbutton, gpointer userdat
 	}
 }
 
-
-
-
-
-
-void
-eSFFDPatternList_changed_cb( GtkComboBox *combo, gpointer userdata)
-{
-	auto& FD = *(SScoringFacility::SPatternsDialog*)userdata;
-
-	if ( FD.current_pattern != FD.patterns.end() ) {
-		FD.current_pattern->Pp = FD.Pp2;
-		FD.current_pattern->criteria = FD.criteria;
-	}
-
-	gint ci = gtk_combo_box_get_active( combo);
-	if ( ci == -1 )
-		return;
-
-	auto now_current = FD.pattern_by_idx(ci);
-	FD.Pp2 = now_current->Pp;
-	FD.criteria = now_current->criteria;
-
-	FD.set_profile_manage_buttons_visibility();
-
-	gtk_widget_queue_draw( (GtkWidget*)FD.daSFFDThing);
-}
-
-
-
-void
-bSFFDProfileSave_clicked_cb( GtkButton *button, gpointer userdata)
-{
-	auto& FD = *(SScoringFacility::SPatternsDialog*)userdata;
-
-	assert (FD.current_pattern->origin == pattern::TOrigin::transient );
-
-	auto& P = *FD.current_pattern;
-	if ( gtk_dialog_run( FD.wSFFDPatternSave) == GTK_RESPONSE_OK ) {
-		P.name = gtk_entry_get_text( FD.eSFFDPatternSaveName);
-		P.origin = gtk_toggle_button_get_active( FD.eSFFDPatternSaveOriginSubject)
-			? pattern::TOrigin::subject
-			: gtk_toggle_button_get_active( FD.eSFFDPatternSaveOriginExperiment)
-			? pattern::TOrigin::experiment
-			: pattern::TOrigin::user;
-		P.Pp = FD.Pp2;
-		P.criteria = FD.criteria;
-
-		FD.populate_combo();
-		FD.set_profile_manage_buttons_visibility();
-	}
-}
-
-
-void
-bSFFDProfileDiscard_clicked_cb( GtkButton *button, gpointer userdata)
-{
-	auto& FD = *(SScoringFacility::SPatternsDialog*)userdata;
-
-	gint ci = gtk_combo_box_get_active( FD.eSFFDPatternList);
-
-	assert ( FD.current_pattern != FD.patterns.end() );
-	assert ( FD.current_pattern->origin != pattern::TOrigin::transient );
-	assert ( ci != -1 );
-	assert ( ci < (int)FD.patterns.size() );
-
-	FD.discard_current_pattern();
-
-	if ( not FD.patterns.empty() ) {
-		FD.Pp2 = FD.current_pattern->Pp;
-		FD.criteria = FD.current_pattern->criteria;
-
-		FD.suppress_w_v = true;
-		FD.W_V.up();
-		FD.suppress_w_v = false;
-	}
-
-	FD.populate_combo();
-	FD.set_profile_manage_buttons_visibility();
-}
-
-
-void
-bSFFDProfileRevert_clicked_cb( GtkButton *button, gpointer userdata)
+gboolean
+eSFFD_any_criteria_focus_in_event_cb( GtkWidget *button, GdkEvent*, gpointer userdata)
 {
 	auto& FD = *(SScoringFacility::SPatternsDialog*)userdata;
+	if      ( button == (GtkWidget*)FD.eSFFDParameterA )
+		FD.now_tweaking = 1;
+	else if ( button == (GtkWidget*)FD.eSFFDParameterB )
+		FD.now_tweaking = 2;
+	else if ( button == (GtkWidget*)FD.eSFFDParameterC )
+		FD.now_tweaking = 3;
+	else if ( button == (GtkWidget*)FD.eSFFDParameterD )
+		FD.now_tweaking = 4;
 
-	assert ( FD.current_pattern != FD.patterns.end() );
-	assert ( FD.current_pattern->origin != pattern::TOrigin::transient );
+	gtk_widget_queue_draw( (GtkWidget*)FD.daSFFDField);
 
-	FD.Pp2 = FD.current_pattern->Pp;
-	FD.criteria = FD.current_pattern->criteria;
-
-	FD.suppress_w_v = true;
-	FD.W_V.up();
-	FD.suppress_w_v = false;
+	return FALSE;
 }
 
 
@@ -386,10 +392,13 @@ wSFFD_hide_cb( GtkWidget *widget, gpointer userdata)
 	auto& FD = *(SScoringFacility::SPatternsDialog*)userdata;
 	auto& SF = FD._p;
 
-	if ( not FD.occurrences.empty() )  // closing while dialog is in matching state
+	if ( not FD.occurrences.empty() ) { // closing while dialog is in matching state
 		if ( GTK_RESPONSE_YES !=
 		     aghui::pop_question( SF.wSF, "Keep annotations?") )
 			FD.restore_annotations();
+		else
+			SF._p.populate_mGlobalAnnotations();
+	}
 
 	FD.occurrences.clear();
 
@@ -415,4 +424,9 @@ wSFFD_configure_event_cb( GtkWidget *widget,
 
 } // extern "C"
 
-// eof
+
+
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
diff --git a/src/ui/sf/d/phasediff-construct.cc b/src/ui/sf/d/phasediff-construct.cc
index 5032e45..91a07b3 100644
--- a/src/ui/sf/d/phasediff-construct.cc
+++ b/src/ui/sf/d/phasediff-construct.cc
@@ -18,8 +18,8 @@ aghui::SPhasediffDialogWidgets::
 SPhasediffDialogWidgets (SScoringFacility& SF)
 {
 	builder = gtk_builder_new();
-	if ( !gtk_builder_add_from_resource( builder, "/org/gtk/aghermann/sf-patterns.glade", NULL) )
-		throw runtime_error( "Failed to load SF::patterns glade resource");
+	if ( !gtk_builder_add_from_resource( builder, "/org/gtk/aghermann/sf-phasediff.glade", NULL) )
+		throw runtime_error( "Failed to load SF::phasediff glade resource");
 	gtk_builder_connect_signals( builder, NULL);
 
 	if ( !(AGH_GBGETOBJ (GtkDialog,		wSFPD)) ||
diff --git a/src/ui/sf/d/phasediff.hh b/src/ui/sf/d/phasediff.hh
index bbe543a..f38edca 100644
--- a/src/ui/sf/d/phasediff.hh
+++ b/src/ui/sf/d/phasediff.hh
@@ -9,8 +9,8 @@
  *         License:  GPL
  */
 
-#ifndef _AGH_UI_SF_PHASEDIFF_H
-#define _AGH_UI_SF_PHASEDIFF_H
+#ifndef _AGH_UI_SF_D_PHASEDIFF_H
+#define _AGH_UI_SF_D_PHASEDIFF_H
 
 #include "ui/sf/sf.hh"
 
@@ -98,7 +98,7 @@ void wSFPD_hide_cb( GtkWidget*, gpointer);
 }
 
 
-#endif // _AGH_UI_SF_PHASEDIFF_H
+#endif // _AGH_UI_SF_D_PHASEDIFF_H
 
 // Local Variables:
 // Mode: c++
diff --git a/src/ui/sf/d/phasediff_cb.cc b/src/ui/sf/d/phasediff_cb.cc
index 786db83..0ed6b49 100644
--- a/src/ui/sf/d/phasediff_cb.cc
+++ b/src/ui/sf/d/phasediff_cb.cc
@@ -1,6 +1,5 @@
-// ;-*-C++-*-
 /*
- *       File name:  ui/sf/sf-phasediff_cb.cc
+ *       File name:  ui/sf/d/phasediff_cb.cc
  *         Project:  Aghermann
  *          Author:  Andrei Zavada <johnhommer at gmail.com>
  * Initial version:  2012-06-18
@@ -27,8 +26,6 @@ daSFPD_draw_cb( GtkWidget *wid, cairo_t *cr, gpointer userdata)
 	if ( PD.suspend_draw )
 		return TRUE;
 
-	aghui::SBusyBlock bb (PD.wSFPD);
-
 	PD.draw( cr,
 		 gtk_widget_get_allocated_width( wid),
 		 gtk_widget_get_allocated_height( wid));
@@ -182,4 +179,8 @@ wSFPD_hide_cb( GtkWidget *wid, gpointer userdata)
 } // extern "C"
 
 
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
+
diff --git a/src/ui/sf/hypnogram_cb.cc b/src/ui/sf/hypnogram_cb.cc
index 0233ca8..88b5acd 100644
--- a/src/ui/sf/hypnogram_cb.cc
+++ b/src/ui/sf/hypnogram_cb.cc
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  ui/sf/sf-hypnogram_cb.cc
  *         Project:  Aghermann
@@ -180,6 +179,8 @@ iSFScoreClear_activate_cb( GtkMenuItem *menuitem, gpointer userdata)
 
 } // extern "C"
 
-
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
 
diff --git a/src/ui/sf/montage-overlays.cc b/src/ui/sf/montage-overlays.cc
index a4ccd37..2d55a10 100644
--- a/src/ui/sf/montage-overlays.cc
+++ b/src/ui/sf/montage-overlays.cc
@@ -280,19 +280,19 @@ draw_overlays( cairo_t* cr,
 	     type == sigfile::SChannel::TType::emg ) {
 		overlay = true;
 
-		_p._p.CwB[SExpDesignUI::TColour::sf_emg].set_source_rgba( cr);
+		cairo_pattern_t *cp = cairo_pattern_create_linear( 0., pbot-EMGProfileHeight, 0., pbot);
+		_p._p.CwB[SExpDesignUI::TColour::sf_emg].pattern_add_color_stop_rgba( cp, 0., 1.);
+		_p._p.CwB[SExpDesignUI::TColour::sf_emg].pattern_add_color_stop_rgba( cp, .5, 0.6);
+		_p._p.CwB[SExpDesignUI::TColour::sf_emg].pattern_add_color_stop_rgba( cp, 1., 1.);
+		cairo_set_source( cr, cp);
+
 		cairo_set_line_width( cr, .3);
-		double dps = (double)emg_profile.size() / _p.da_wd;
-		cairo_move_to( cr, 0., pbot - EMGProfileHeight/2);
-		size_t i = 0;
-		for ( ; i < emg_profile.size(); ++i )
-			cairo_line_to( cr, i / dps,
-				       pbot - EMGProfileHeight/2 - emg_profile[i] * signal_display_scale/2);
-		for ( --i; i > 0; --i )
-			cairo_line_to( cr, i / dps,
-				       pbot - EMGProfileHeight/2 + emg_profile[i] * signal_display_scale/2);
-		cairo_fill( cr);
+		aghui::cairo_draw_envelope(
+			cr,
+			raw_profile, 0, raw_profile.size(),
+			_p.da_wd, 0., pbot - EMGProfileHeight/2, emg_display_scale);
 		cairo_stroke( cr);
+		cairo_pattern_destroy( cp);
 	}
 
 	if ( overlay )
diff --git a/src/ui/sf/montage.cc b/src/ui/sf/montage.cc
index d0545b1..48f2854 100644
--- a/src/ui/sf/montage.cc
+++ b/src/ui/sf/montage.cc
@@ -180,13 +180,6 @@ expand_by_factor( double fac)
 
 
 
-
-
-
-
-
-
-
 void
 aghui::SScoringFacility::SChannel::
 draw_for_montage( const char *fname, int width, int height) // to a file
@@ -222,19 +215,37 @@ draw_page( cairo_t *cr,
 	int	ptop = y0 - _p.interchannel_gap/2,
 		pbot = ptop + _p.interchannel_gap;
 
+      // zeroline
+	if ( draw_zeroline ) {
+		cairo_set_line_width( cr, fine_line());
+		_p._p.CwB[SExpDesignUI::TColour::sf_ticks].set_source_rgba( cr);
+		cairo_move_to( cr, 0, y0);
+		cairo_rel_line_to( cr, wd, 0);
+		cairo_stroke( cr);
+	}
+
       // marquee, goes first, not to obscure waveforms
 	if ( draw_marquee // possibly undesired (such as when drawing for unfazer (what unfazer?))
 	     && agh::alg::overlap(
 		     selection_start_time, selection_end_time,
 		     _p.cur_xvpage_start(), _p.cur_xvpage_end()) ) {
+
 		double	pre = _p.skirting_run_per1 * _p.vpagesize(),
 			ma = (selection_start_time - _p.cur_xvpage_start()) / _p.xvpagesize() * wd,
 			me = (selection_end_time   - _p.cur_xvpage_start()) / _p.xvpagesize() * wd;
-		_p._p.CwB[SExpDesignUI::TColour::sf_selection].set_source_rgba( cr);
-		cairo_rectangle( cr,
-				 ma, ptop, me - ma, _p.interchannel_gap);
-		cairo_fill( cr);
-		cairo_stroke( cr);
+		{
+			cairo_pattern_t *cp = cairo_pattern_create_linear( 0., ptop, 0., pbot);
+			_p._p.CwB[SExpDesignUI::TColour::sf_selection].pattern_add_color_stop_rgba( cp, 0., .6);
+			_p._p.CwB[SExpDesignUI::TColour::sf_selection].pattern_add_color_stop_rgba( cp, .2, .3);
+			_p._p.CwB[SExpDesignUI::TColour::sf_selection].pattern_add_color_stop_rgba( cp, .8, .4);
+			_p._p.CwB[SExpDesignUI::TColour::sf_selection].pattern_add_color_stop_rgba( cp, 1., .6);
+			cairo_set_source( cr, cp);
+			cairo_rectangle( cr,
+					 ma, ptop, me - ma, _p.interchannel_gap);
+			cairo_fill( cr);
+			cairo_stroke( cr);
+			cairo_pattern_destroy( cp);
+		}
 
 	      // start timestamp
 		cairo_set_font_size( cr, 10);
@@ -253,23 +264,24 @@ draw_page( cairo_t *cr,
 		cairo_show_text( cr, __buf__);
 		cairo_stroke( cr);
 
-		if ( selection_end - selection_start > 5 ) {  // don't mark end if selection is too short
+		if ( (draw_selection_envelope || draw_selection_course || draw_selection_dzcdf) &&
+		     selection_end_time - selection_start_time > .5 ) {
 		      // signal properties
-			auto& Pp = _p.patterns_d().Pp2;
+			const valarray<TFloat>
+				selection {(draw_filtered_signal
+					    ? signal_filtered
+					    : signal_original)[ slice (selection_start,
+								       selection_end - selection_start,
+								       1) ]};
 			if ( draw_selection_envelope ) {
 				valarray<TFloat>
-					selection {(draw_filtered_signal
-						    ? signal_filtered
-						    : signal_original)[ slice (selection_start,
-									       selection_end - selection_start,
-									       1) ]};
-				valarray<TFloat>
 					env_u, env_l;
 				if ( sigproc::envelope(
 					     {selection, samplerate()},
-					     Pp.env_scope,
+					     pattern_params.env_scope,
 					     1./samplerate(),
-					     &env_l, &env_u) != 0 ) {
+					     &env_l, &env_u) > 2 ) {
+
 					cairo_set_source_rgba( cr, 1, 1, 1, .6);
 					cairo_set_line_width( cr, 1);
 					aghui::cairo_draw_signal(
@@ -286,15 +298,12 @@ draw_page( cairo_t *cr,
 			}
 			if ( draw_selection_course ) {
 				valarray<TFloat>
-					selection {(draw_filtered_signal
-						    ? signal_filtered
-						    : signal_original)[ slice (selection_start,
-									       selection_end - selection_start,
-									       1) ]},
 					course
 						= exstrom::band_pass(
 							selection, samplerate(),
-							Pp.bwf_ffrom, Pp.bwf_fupto, Pp.bwf_order, true);
+							pattern_params.bwf_ffrom,
+							pattern_params.bwf_fupto,
+							pattern_params.bwf_order, true);
 
 				cairo_set_source_rgba( cr, 0.3, 0.3, 0.3, .5);
 				cairo_set_line_width( cr, 3.);
@@ -304,20 +313,14 @@ draw_page( cairo_t *cr,
 				cairo_stroke( cr);
 			}
 			if ( draw_selection_dzcdf ) {
-				valarray<TFloat>
-					selection {(draw_filtered_signal
-						    ? signal_filtered
-						    : signal_original)[ slice (selection_start,
-									       selection_end - selection_start,
-									       1) ]};
 				if ( samplerate() > 10 &&
-				     Pp.dzcdf_step * 10 < selection_end_time - selection_start_time ) {
+				     pattern_params.dzcdf_step * 10 < selection_end_time - selection_start_time ) {
 					valarray<TFloat>
 						dzcdf = sigproc::dzcdf(
 							sigproc::SSignalRef<TFloat> {selection, samplerate()},
-							Pp.dzcdf_step,
-							Pp.dzcdf_sigma,
-							Pp.dzcdf_smooth);
+							pattern_params.dzcdf_step,
+							pattern_params.dzcdf_sigma,
+							pattern_params.dzcdf_smooth);
 					float	dzcdf_display_scale = (pbot-ptop)/2. / dzcdf.max();
 
 					cairo_set_source_rgba( cr, 0.3, 0.3, 0.99, .8);
@@ -328,8 +331,10 @@ draw_page( cairo_t *cr,
 					cairo_stroke( cr);
 				}
 			}
+		}
 
-		      // labels
+	      // labels
+		if ( selection_end_time - selection_start_time > .25 ) {  // don't mark end if selection is too short
 			_p._p.CwB[SExpDesignUI::TColour::sf_cursor].set_source_rgba( cr);
 			snprintf_buf( "%5.2fs",
 				      selection_end_time - _p.cur_xvpage_start() - pre);
@@ -351,7 +356,8 @@ draw_page( cairo_t *cr,
 			// MC metrics
 			if ( _p.mode != SScoringFacility::TMode::marking &&
 			     type == sigfile::SChannel::TType::eeg &&
-			     selection_end_time - selection_start_time > 1. ) {
+			     selection_end_time - selection_start_time > 2. ) {
+
 				cairo_set_font_size( cr, 12);
 				cairo_select_font_face( cr, "sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
 				snprintf_buf( "%4.2f / %4.2f",
@@ -365,18 +371,10 @@ draw_page( cairo_t *cr,
 		}
 	}
 
-      // zeroline
-	if ( draw_zeroline ) {
-		cairo_set_line_width( cr, fine_line());
-		_p._p.CwB[SExpDesignUI::TColour::sf_ticks].set_source_rgba( cr);
-		cairo_move_to( cr, 0, y0);
-		cairo_rel_line_to( cr, wd, 0);
-		cairo_stroke( cr);
-	}
-
       // waveform: signal_filtered
-	bool one_signal_drawn = false;
-	if ( draw_filtered_signal ) {
+	bool	need_filtered = (have_low_pass() or have_high_pass() or have_notch_filter()) or (not artifacts().empty()),
+		one_signal_drawn = false;
+	if ( draw_filtered_signal and need_filtered ) {
 		cairo_set_line_width( cr, fine_line());
 		cairo_set_source_rgb( cr, 0., 0., 0.); // bg is uniformly light shades
 
@@ -395,7 +393,7 @@ draw_page( cairo_t *cr,
 	}
 
       // waveform: signal_original
-	if ( draw_original_signal ) {
+	if ( draw_original_signal or not one_signal_drawn ) {
 		if ( one_signal_drawn ) {  // attenuate the other signal
 			cairo_set_line_width( cr, fine_line() * .6);
 			cairo_set_source_rgba( cr, 0., 0.3, 0., .4);
@@ -513,10 +511,9 @@ draw_page( cairo_t *cr,
 
       // annotations
 	{
-		auto& Aa = crecording.F().annotations(name);
-		if ( not Aa.empty() ) {
+		if ( not annotations.empty() ) {
 			int on_this_page = 0;
-			for ( auto &A : Aa ) {
+			for ( auto &A : annotations ) {
 				if ( agh::alg::overlap( (int)A.span.a, (int)A.span.z, cvpa, cvpe) ) {
 					int disp = ptop + ++on_this_page * 5;
 					cairo_pattern_t *cp = cairo_pattern_create_linear( 0., disp, 0., pbot);
diff --git a/src/ui/sf/montage_cb.cc b/src/ui/sf/montage_cb.cc
index 1ca55ee..40bfdf3 100644
--- a/src/ui/sf/montage_cb.cc
+++ b/src/ui/sf/montage_cb.cc
@@ -16,6 +16,7 @@
 #include "ui/misc.hh"
 #include "sf.hh"
 #include "d/artifacts.hh"
+#include "d/artifacts-simple.hh"
 #include "d/filters.hh"
 
 
@@ -295,6 +296,7 @@ daSFMontage_button_release_event_cb( GtkWidget *wid, GdkEventButton *event, gpoi
 			Ch->put_selection( Ch->selection_start, Ch->selection_end);
 			gtk_widget_queue_draw( wid);
 			Ch->selectively_enable_selection_menu_items();
+			Ch->update_channel_check_menu_items();
 			if ( fabs(SF.using_channel->marquee_mstart - SF.using_channel->marquee_mend) > 5 ) {
 				gtk_menu_popup( SF.iiSFPageSelection,
 						NULL, NULL, NULL, NULL, 3, event->time);
@@ -318,8 +320,7 @@ daSFMontage_button_release_event_cb( GtkWidget *wid, GdkEventButton *event, gpoi
 
 
 
-
-
+#define smoothness 1.05
 
 gboolean
 daSFMontage_scroll_event_cb( GtkWidget *wid, GdkEventScroll *event, gpointer userdata)
@@ -344,9 +345,7 @@ daSFMontage_scroll_event_cb( GtkWidget *wid, GdkEventScroll *event, gpointer use
 		    break;
 		}
 
-	} else if ( Ch->type == sigfile::SChannel::TType::eeg
-	     && event->y > Ch->zeroy
-	     && (Ch->draw_psd || Ch->draw_mc) ) {
+	} else if ( event->y > Ch->zeroy ) {
 		if ( event->state & GDK_SHIFT_MASK && Ch->draw_psd ) {
 			switch ( event->direction ) {
 			case GDK_SCROLL_DOWN:
@@ -395,42 +394,47 @@ daSFMontage_scroll_event_cb( GtkWidget *wid, GdkEventScroll *event, gpointer use
 		} else {
 			switch ( event->direction ) {
 			case GDK_SCROLL_DOWN:
-				Ch->psd.display_scale /= 1.1;
-				Ch->swu.display_scale /= 1.1;
-				Ch->mc.display_scale /= 1.1;
+				Ch->psd.display_scale /= smoothness;
+				Ch->swu.display_scale /= smoothness;
+				Ch->mc.display_scale  /= smoothness;
+				Ch->emg_display_scale /= smoothness;
 			    break;
 			case GDK_SCROLL_UP:
-				Ch->psd.display_scale *= 1.1;
-				Ch->swu.display_scale *= 1.1;
-				Ch->mc.display_scale *= 1.1;
+				Ch->psd.display_scale *= smoothness;
+				Ch->swu.display_scale *= smoothness;
+				Ch->mc.display_scale  *= smoothness;
+				Ch->emg_display_scale *= smoothness;
 			    break;
 			case GDK_SCROLL_LEFT:
-				if ( SF.cur_vpage() > 0 ) {
+				if ( SF.cur_vpage() > 0 )
 					SF.set_cur_vpage( SF.cur_vpage() - 1);
-				}
-			    break;
 			case GDK_SCROLL_RIGHT:
-				if ( SF.cur_vpage() < SF.total_vpages() ) {
+				if ( SF.cur_vpage() < SF.total_vpages() )
 					SF.set_cur_vpage( SF.cur_vpage() + 1);
-				}
 			    break;
 			default:
 			    break;
 			}
 			if ( event->state & GDK_CONTROL_MASK )
 				for ( auto& H : SF.channels ) {
-					H.psd.display_scale = Ch->psd.display_scale;
-					H.mc.display_scale = Ch->mc.display_scale;
+					if ( Ch->type == sigfile::SChannel::TType::eeg &&
+					     H.type == sigfile::SChannel::TType::eeg ) {
+						H.psd.display_scale = Ch->psd.display_scale;
+						H.mc.display_scale  = Ch->mc.display_scale;
+						H.swu.display_scale = Ch->swu.display_scale;
+					} else if ( Ch->type == sigfile::SChannel::TType::emg &&
+					     H.type == sigfile::SChannel::TType::emg )
+						H.emg_display_scale = Ch->emg_display_scale;
 				}
 			gtk_widget_queue_draw( wid);
 		}
 	} else {
 		switch ( event->direction ) {
 		case GDK_SCROLL_DOWN:
-			Ch->signal_display_scale /= 1.1;
+			Ch->signal_display_scale /= smoothness;
 			break;
 		case GDK_SCROLL_UP:
-			Ch->signal_display_scale *= 1.1;
+			Ch->signal_display_scale *= smoothness;
 			break;
 		default:
 			break;
@@ -445,7 +449,7 @@ daSFMontage_scroll_event_cb( GtkWidget *wid, GdkEventScroll *event, gpointer use
 	return TRUE;
 }
 
-
+#undef smoothness
 
 
 
@@ -664,13 +668,12 @@ void
 iSFPageArtifactsMarkFlat_activate_cb( GtkMenuItem*, gpointer userdata)
 {
 	auto& SF = *(SScoringFacility*)userdata;
-
+	auto& AS = SF.artifacts_simple_d();
 	if ( GTK_RESPONSE_OK ==
-	     gtk_dialog_run( (GtkDialog*)SF.wSFSimpleArtifactDetectionParams) ) {
-		double	minsize = gtk_spin_button_get_value( SF.eSFSimpleArtifactDetectionMinFlatRegionSize),
-			pad = gtk_spin_button_get_value( SF.eSFSimpleArtifactDetectionPad);
+	     gtk_dialog_run( (GtkDialog*)AS.wSFADS) ) {
+		AS.W_V.down();
 
-		auto marked = SF.using_channel->mark_flat_regions_as_artifacts( minsize, pad);
+		auto marked = SF.using_channel->mark_flat_regions_as_artifacts( AS.min_size, AS.pad);
 
 		snprintf_buf( "Detected %.2g sec of flat regions, adding %.2g sec to already marked",
 			      marked.first, marked.second);
@@ -894,8 +897,11 @@ iSFPageSelectionAnnotate_activate_cb( GtkMenuItem *menuitem, gpointer userdata)
 	gtk_entry_set_text( SF.eSFAnnotationLabel, "");
 	if ( GTK_RESPONSE_OK ==
 	     gtk_dialog_run( (GtkDialog*)SF.wSFAnnotationLabel) ) {
-		SF.using_channel->mark_region_as_annotation(
-			gtk_entry_get_text( SF.eSFAnnotationLabel));
+		auto new_ann = gtk_entry_get_text( SF.eSFAnnotationLabel);
+		if ( strlen( new_ann) == 0 )
+			return;
+
+		SF.using_channel->mark_region_as_annotation( new_ann);
 
 		gtk_widget_queue_draw( (GtkWidget*)SF.daSFMontage);
 		gtk_widget_queue_draw( (GtkWidget*)SF.daSFHypnogram);
@@ -910,6 +916,8 @@ iSFPageSelectionDrawCourse_toggled_cb( GtkCheckMenuItem *cb, gpointer userdata)
 {
 	auto& SF = *(SScoringFacility*)userdata;
 	SF.using_channel->draw_selection_course = gtk_check_menu_item_get_active( cb);
+	if ( SF.suppress_redraw )
+		return;
 	gtk_widget_queue_draw( (GtkWidget*)SF.daSFMontage);
 }
 
@@ -918,6 +926,8 @@ iSFPageSelectionDrawEnvelope_toggled_cb( GtkCheckMenuItem *cb, gpointer userdata
 {
 	auto& SF = *(SScoringFacility*)userdata;
 	SF.using_channel->draw_selection_envelope = gtk_check_menu_item_get_active( cb);
+	if ( SF.suppress_redraw )
+		return;
 	gtk_widget_queue_draw( (GtkWidget*)SF.daSFMontage);
 }
 
@@ -926,6 +936,8 @@ iSFPageSelectionDrawDzxdf_toggled_cb( GtkCheckMenuItem *cb, gpointer userdata)
 {
 	auto& SF = *(SScoringFacility*)userdata;
 	SF.using_channel->draw_selection_dzcdf = gtk_check_menu_item_get_active( cb);
+	if ( SF.suppress_redraw )
+		return;
 	gtk_widget_queue_draw( (GtkWidget*)SF.daSFMontage);
 }
 
diff --git a/src/ui/sf/sf.cc b/src/ui/sf/sf.cc
index 59d552c..94f3481 100644
--- a/src/ui/sf/sf.cc
+++ b/src/ui/sf/sf.cc
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  ui/sf/sf.cc
  *         Project:  Aghermann
@@ -86,6 +85,7 @@ SScoringFacility (agh::CSubject& J,
 	_filters_d (nullptr),
 	_phasediff_d (nullptr),
 	_artifacts_d (nullptr),
+	_artifacts_simple_d (nullptr),
 	using_channel (nullptr),
 	da_ht (NAN) // bad value, to be estimated unless previously saved
 {
@@ -134,7 +134,7 @@ SScoringFacility (agh::CSubject& J,
 		}
 	}
 	if ( channels.empty() )
-		throw invalid_argument( string ("No channels found for combination (") + J.name() + ", " + D + ", " + E + ")");
+		throw invalid_argument( string ("No channels found for combination (") + J.short_name + ", " + D + ", " + E + ")");
 
       // count n_eeg_channels
 	n_eeg_channels =
@@ -150,7 +150,7 @@ SScoringFacility (agh::CSubject& J,
 		estimate_montage_height();
 
 	for ( auto &h : channels ) {
-		if ( not isfinite(h.signal_display_scale) || h.signal_display_scale <= DBL_MIN )
+		if ( not isfinite(h.signal_display_scale) || h.signal_display_scale <= 1e-9 )
 			h.signal_display_scale =
 				agh::alg::calibrate_display_scale(
 					h.signal_filtered,
@@ -158,24 +158,31 @@ SScoringFacility (agh::CSubject& J,
 					interchannel_gap / 2);
 		if ( h.type == sigfile::SChannel::TType::eeg ) {
 		      // calibrate profile display scales
-			if ( not isfinite(h.psd.display_scale) || h.psd.display_scale <= DBL_MIN )
+			if ( not isfinite(h.psd.display_scale) || h.psd.display_scale <= 1e-9 )
 				h.psd.display_scale =
 					agh::alg::calibrate_display_scale(
 						h.psd.course_in_bands[metrics::psd::TBand::delta],
 						h.psd.course.size(),
 						interchannel_gap / 4);
-			if ( not isfinite(h.mc.display_scale) || h.mc.display_scale <= DBL_MIN )
+			if ( not isfinite(h.mc.display_scale) || h.mc.display_scale <= 1e-9 )
 				h.mc.display_scale =
 					agh::alg::calibrate_display_scale(
 						h.mc.course,
 						h.mc.course.size(),
 						interchannel_gap / 4);
-			if ( not isfinite(h.swu.display_scale) || h.swu.display_scale <= DBL_MIN )
+			if ( not isfinite(h.swu.display_scale) || h.swu.display_scale <= 1e-9 )
 				h.swu.display_scale =
 					agh::alg::calibrate_display_scale(
 						h.swu.course,
 						h.swu.course.size(),
 						interchannel_gap / 4);
+		} else if ( h.type == sigfile::SChannel::TType::emg ) {
+			if ( not isfinite(h.emg_display_scale) || h.emg_display_scale <= 1e-9 )
+				h.emg_display_scale =
+					agh::alg::calibrate_display_scale(
+						h.raw_profile,
+						h.raw_profile.size(),
+						interchannel_gap / 4);
 		}
 		h._put_selection();
 	}
@@ -183,7 +190,7 @@ SScoringFacility (agh::CSubject& J,
       // set up other controls
 	// set window title
 	snprintf_buf( "Scoring: %s’s %s in %s",
-		      J.name(), E.c_str(), D.c_str());
+		      J.full_name.c_str(), E.c_str(), D.c_str());
 	gtk_window_set_title( (GtkWindow*)wSF,
 			      __buf__);
 
@@ -738,6 +745,8 @@ set_tooltip( TTipIdx i) const
 }
 
 
-
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
 
diff --git a/src/ui/sf/sf.hh b/src/ui/sf/sf.hh
index 3ecc19a..dae24e3 100644
--- a/src/ui/sf/sf.hh
+++ b/src/ui/sf/sf.hh
@@ -22,6 +22,7 @@
 #include "common/config-validate.hh"
 #include "sigproc/winfun.hh"
 #include "sigproc/sigproc.hh"
+#include "patterns/patterns.hh"
 #include "metrics/mc-artifacts.hh"
 #include "metrics/phasic-events.hh"
 #include "expdesign/primaries.hh"
@@ -119,6 +120,8 @@ class SScoringFacility
 		in_annotations( double time) const;
 
 	      // signal metrics
+	  	static pattern::SPatternPPack<TFloat>
+			pattern_params;
 		sigproc::SCachedLowPassCourse<TFloat>
 			signal_lowpass;
 		sigproc::SCachedBandPassCourse<TFloat>
@@ -173,7 +176,8 @@ class SScoringFacility
 			mc;
 		void get_mc_course();
 
-		valarray<TFloat>& which_profile( metrics::TType);
+		tuple<metrics::TType, valarray<TFloat>&>
+		which_profile( metrics::TType);
 
 		void update_profile_display_scales();
 
@@ -187,9 +191,12 @@ class SScoringFacility
 		void get_spectrum(); // at current page
 		void get_spectrum( size_t p);
 
-	      // emg
+	      // raw profile
 		valarray<TFloat>
-			emg_profile;
+			raw_profile;
+		void get_raw_profile();
+
+	      // emg
 		double	emg_display_scale;
 
 	      // phasic events
@@ -512,6 +519,10 @@ class SScoringFacility
 	SArtifactsDialog&
 	artifacts_d();
 
+	struct SArtifactsSimpleDialog;
+	SArtifactsSimpleDialog&
+	artifacts_simple_d();
+
     private:
 	SPatternsDialog
 		*_patterns_d;
@@ -521,6 +532,8 @@ class SScoringFacility
 		*_phasediff_d;
 	SArtifactsDialog
 		*_artifacts_d;
+	SArtifactsSimpleDialog
+		*_artifacts_simple_d;
 
     public:
       // menu support
@@ -835,4 +848,8 @@ gboolean wSF_delete_event_cb( GtkWidget*, GdkEvent*, gpointer);
 
 #endif
 
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
+
diff --git a/src/ui/sf/widgets.hh b/src/ui/sf/widgets.hh
index c11d2df..d423499 100644
--- a/src/ui/sf/widgets.hh
+++ b/src/ui/sf/widgets.hh
@@ -13,15 +13,12 @@
 #define _AGH_UI_SCORING_FACILITY_WIDGETS_H
 
 #include <gtk/gtk.h>
-#include "ui/forward-decls.hh"
 
+// stow this crowd away from first-class gents
 namespace aghui {
 
 struct SScoringFacilityWidgets {
 
-	// we load and construct own widget set (wSF and all its contents)
-	// ourself, for every SScoringFacility instance being created, so
-	// construct_widgets below takes an arg
 	SScoringFacilityWidgets ();
        ~SScoringFacilityWidgets ();
 
@@ -179,15 +176,11 @@ struct SScoringFacilityWidgets {
 	// less important dialogs
 	GtkDialog
 		*wSFAnnotationLabel,
-		*wSFAnnotationSelector,
-		*wSFSimpleArtifactDetectionParams;
+		*wSFAnnotationSelector;
 	GtkEntry
 		*eSFAnnotationLabel;
 	GtkComboBox
 		*eSFAnnotationSelectorWhich;
-	GtkSpinButton
-		*eSFSimpleArtifactDetectionMinFlatRegionSize,
-		*eSFSimpleArtifactDetectionPad;
 
 };
 
diff --git a/src/ui/ui.hh b/src/ui/ui.hh
index 5fc15b6..752a29e 100644
--- a/src/ui/ui.hh
+++ b/src/ui/ui.hh
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  ui/ui.hh
  *         Project:  Aghermann
@@ -127,10 +126,15 @@ void
 cairo_draw_signal( cairo_t*,
 		   const valarray<TFloat>&,
 		   ssize_t start, ssize_t end,
-		   size_t da_wd, double hdisp, double vdisp, float display_scale,
+		   size_t da_wd, float hdisp, float vdisp, float display_scale,
 		   unsigned short decimate = 1,
 		   TDrawSignalDirection direction = TDrawSignalDirection::forward,
 		   bool continue_path = false);
+void
+cairo_draw_envelope( cairo_t*,
+		     const valarray<TFloat>&,
+		     ssize_t start, ssize_t end,
+		     size_t da_wd, float hdisp, float vdisp, float display_scale);
 
 inline void
 cairo_draw_signal( cairo_t *cr,
@@ -187,4 +191,8 @@ void set_cursor_busy( bool busy, GtkWidget *wid);
 
 #endif
 
-// eof
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
+

-- 
Sleep experiment manager



More information about the debian-med-commit mailing list