[med-svn] [aghermann] 05/85: ICM

andrei zavada hmmr-guest at alioth.debian.org
Thu Sep 26 23:46:22 UTC 2013


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

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

commit 0bd54a4977a18eb4795c854b2f8ce750dbe3813a
Author: Andrei Zavada <johnhommer at gmail.com>
Date:   Mon Sep 2 19:48:34 2013 +0300

    ICM
    
    also complete 0453af650c (tabs to spaces, outside src/aghermann)
---
 upstream/src/aghermann/expdesign/expdesign.cc    |   66 +-
 upstream/src/aghermann/expdesign/profile.hh      |  108 +-
 upstream/src/aghermann/expdesign/recording.cc    |   12 +-
 upstream/src/aghermann/expdesign/recording.hh    |  118 +--
 upstream/src/aghermann/expdesign/subject.cc      |    4 +-
 upstream/src/aghermann/expdesign/subject.hh      |   36 +-
 upstream/src/aghermann/expdesign/tree-scanner.cc |   74 +-
 upstream/src/aghermann/ui/mw/mw_cb.cc            |    2 +-
 upstream/src/common/alg.hh                       |  156 +--
 upstream/src/common/config-validate.hh           |  170 +--
 upstream/src/common/containers.hh                |    8 +-
 upstream/src/common/fs.hh                        |   30 +-
 upstream/src/common/lang.hh                      |   34 +-
 upstream/src/common/libcommon.cc                 |  286 ++---
 upstream/src/common/string.hh                    |   34 +-
 upstream/src/common/subject_id.cc                |  214 ++--
 upstream/src/common/subject_id.hh                |  138 +--
 upstream/src/libmetrics/bands.hh                 |   12 +-
 upstream/src/libmetrics/mc-artifacts.cc          |   22 +-
 upstream/src/libmetrics/mc-artifacts.hh          |   48 +-
 upstream/src/libmetrics/mc.cc                    |  194 ++--
 upstream/src/libmetrics/mc.hh                    |  286 ++---
 upstream/src/libmetrics/page-metrics-base.cc     |  210 ++--
 upstream/src/libmetrics/page-metrics-base.hh     |  222 ++--
 upstream/src/libmetrics/psd.cc                   |  332 +++---
 upstream/src/libmetrics/psd.hh                   |  194 ++--
 upstream/src/libmetrics/swu.cc                   |  150 +--
 upstream/src/libmetrics/swu.hh                   |   88 +-
 upstream/src/libsigfile/channel.cc               |  136 +--
 upstream/src/libsigfile/channel.hh               |  272 ++---
 upstream/src/libsigfile/edf-io.cc                |  140 +--
 upstream/src/libsigfile/edf.cc                   | 1214 +++++++++++-----------
 upstream/src/libsigfile/edf.hh                   |  646 ++++++------
 upstream/src/libsigfile/page.cc                  |  210 ++--
 upstream/src/libsigfile/page.hh                  |  354 +++----
 upstream/src/libsigfile/source-base.cc           |  760 +++++++-------
 upstream/src/libsigfile/source-base.hh           |  692 ++++++------
 upstream/src/libsigfile/tsv.cc                   |  556 +++++-----
 upstream/src/libsigfile/tsv.hh                   |  566 +++++-----
 upstream/src/libsigfile/typed-source.cc          |   88 +-
 upstream/src/libsigfile/typed-source.hh          |   78 +-
 upstream/src/libsigproc/exstrom.hh               |  796 +++++++-------
 upstream/src/libsigproc/ext-filters.hh           |  284 ++---
 upstream/src/libsigproc/sigproc.cc               |   52 +-
 upstream/src/libsigproc/sigproc.hh               |  318 +++---
 upstream/src/libsigproc/winfun.cc                |   78 +-
 upstream/src/libsigproc/winfun.hh                |   20 +-
 upstream/src/tools/agh-profile-gen.cc            |  289 +++--
 upstream/src/tools/edfcat.cc                     |  670 ++++++------
 upstream/src/tools/edfhed-gtk.cc                 |  588 +++++------
 upstream/src/tools/edfhed.cc                     |  668 ++++++------
 51 files changed, 6348 insertions(+), 6375 deletions(-)

diff --git a/upstream/src/aghermann/expdesign/expdesign.cc b/upstream/src/aghermann/expdesign/expdesign.cc
index b5e31d4..00c797b 100644
--- a/upstream/src/aghermann/expdesign/expdesign.cc
+++ b/upstream/src/aghermann/expdesign/expdesign.cc
@@ -14,7 +14,7 @@
 #include <string>
 
 #ifdef _OPENMP
-#include <omp.h>
+# include <omp.h>
 #endif
 
 #include "aghermann/globals.hh"
@@ -54,47 +54,44 @@ CExpDesign (const string& session_dir_,
         strict_subject_id_checks (false),
         _id_pool (0),
         config_keys_g ({
-                SValidator<double>("ctl_param.step_size",        &ctl_params0.siman_params.step_size),
-                SValidator<double>("ctl_param.boltzmann_k",        &ctl_params0.siman_params.k,                        SValidator<double>::SVFRangeEx( DBL_MIN, 1e9)),
-                SValidator<double>("ctl_param.t_initial",        &ctl_params0.siman_params.t_initial,                SValidator<double>::SVFRangeEx( DBL_MIN, 1e9)),
-                SValidator<double>("ctl_param.damping_mu",        &ctl_params0.siman_params.mu_t,                        SValidator<double>::SVFRangeEx( DBL_MIN, 1e9)),
-                SValidator<double>("ctl_param.t_min",                &ctl_params0.siman_params.t_min,                SValidator<double>::SVFRangeEx( DBL_MIN, 1e9)),
-                SValidator<double>("profile.req_scored_pc",        &req_percent_scored,                                SValidator<double>::SVFRangeIn( 80., 100.)),
-                SValidator<double>("fft_param.pagesize",        &fft_params.pagesize,                                SValidator<double>::SVFRangeIn( 4., 120.)),
-                SValidator<double>("fft_param.binsize",                &fft_params.binsize,                                SValidator<double>::SVFRangeIn( .125, 1.)),
-                SValidator<double>("artifacts.dampen_factor",        &af_dampen_factor,                                SValidator<double>::SVFRangeIn( 0., 1.)),
-                SValidator<double>("mc_param.mc_gain",                &mc_params.mc_gain,                                SValidator<double>::SVFRangeIn( 0., 100.)),
-                SValidator<double>("mc_param.f0fc",                &mc_params.f0fc,                                SValidator<double>::SVFRangeEx( 0., 80.)),
-                SValidator<double>("mc_param.bandwidth",        &mc_params.bandwidth,                                SValidator<double>::SVFRangeIn( 0.125, 2.)),
-                SValidator<double>("mc_param.iir_backpolate",        &mc_params.iir_backpolate,                        SValidator<double>::SVFRangeIn( 0., 1.)),
-                SValidator<double>("swu_param.min_upswing_duration",
-                                                                &swu_params.min_upswing_duration,                SValidator<double>::SVFRangeIn( 0.01, 1.)),
+                SValidator<double>("ctl_param.step_size",            &ctl_params0.siman_params.step_size),
+                SValidator<double>("ctl_param.boltzmann_k",          &ctl_params0.siman_params.k,            SValidator<double>::SVFRangeEx( DBL_MIN, 1e9)),
+                SValidator<double>("ctl_param.t_initial",            &ctl_params0.siman_params.t_initial,    SValidator<double>::SVFRangeEx( DBL_MIN, 1e9)),
+                SValidator<double>("ctl_param.damping_mu",           &ctl_params0.siman_params.mu_t,         SValidator<double>::SVFRangeEx( DBL_MIN, 1e9)),
+                SValidator<double>("ctl_param.t_min",                &ctl_params0.siman_params.t_min,        SValidator<double>::SVFRangeEx( DBL_MIN, 1e9)),
+                SValidator<double>("profile.req_scored_pc",          &req_percent_scored,                    SValidator<double>::SVFRangeIn( 80., 100.)),
+                SValidator<double>("fft_param.pagesize",             &fft_params.pagesize,                   SValidator<double>::SVFRangeIn( 4., 120.)),
+                SValidator<double>("fft_param.binsize",              &fft_params.binsize,                    SValidator<double>::SVFRangeIn( .125, 1.)),
+                SValidator<double>("artifacts.dampen_factor",        &af_dampen_factor,                      SValidator<double>::SVFRangeIn( 0., 1.)),
+                SValidator<double>("mc_param.mc_gain",               &mc_params.mc_gain,                     SValidator<double>::SVFRangeIn( 0., 100.)),
+                SValidator<double>("mc_param.f0fc",                  &mc_params.f0fc,                        SValidator<double>::SVFRangeEx( 0., 80.)),
+                SValidator<double>("mc_param.bandwidth",             &mc_params.bandwidth,                   SValidator<double>::SVFRangeIn( 0.125, 2.)),
+                SValidator<double>("mc_param.iir_backpolate",        &mc_params.iir_backpolate,              SValidator<double>::SVFRangeIn( 0., 1.)),
+                SValidator<double>("swu_param.min_upswing_duration", &swu_params.min_upswing_duration,       SValidator<double>::SVFRangeIn( 0.01, 1.)),
         }),
         config_keys_d ({
-                SValidator<int>("fft_param.welch_window_type",        (int*)&fft_params.welch_window_type,                SValidator<int>::SVFRangeIn( 0, (int)sigproc::TWinType_total - 1)),
-                SValidator<int>("fft_param.plan_type",                (int*)&fft_params.plan_type,                        SValidator<int>::SVFRangeIn( 0, (int)metrics::psd::TFFTWPlanType_total - 1)),
-                SValidator<int>("artifacts.dampen_window_type",        (int*)&af_dampen_window_type,                        SValidator<int>::SVFRangeIn( 0, (int)sigproc::TWinType_total - 1)),
-                SValidator<int>("ctl_param.iters_fixed_t",        &ctl_params0.siman_params.iters_fixed_T,        SValidator<int>::SVFRangeIn( 1, 1000000)),
-                SValidator<int>("ctl_param.n_tries",                &ctl_params0.siman_params.n_tries,                SValidator<int>::SVFRangeIn( 1, 10000)),
+                SValidator<int>("fft_param.welch_window_type",  (int*)&fft_params.welch_window_type,           SValidator<int>::SVFRangeIn( 0, (int)sigproc::TWinType_total - 1)),
+                SValidator<int>("fft_param.plan_type",          (int*)&fft_params.plan_type,                   SValidator<int>::SVFRangeIn( 0, (int)metrics::psd::TFFTWPlanType_total - 1)),
+                SValidator<int>("artifacts.dampen_window_type", (int*)&af_dampen_window_type,                  SValidator<int>::SVFRangeIn( 0, (int)sigproc::TWinType_total - 1)),
+                SValidator<int>("ctl_param.iters_fixed_t",            &ctl_params0.siman_params.iters_fixed_T, SValidator<int>::SVFRangeIn( 1, 1000000)),
+                SValidator<int>("ctl_param.n_tries",                  &ctl_params0.siman_params.n_tries,       SValidator<int>::SVFRangeIn( 1, 10000)),
         }),
         config_keys_z ({
-                SValidator<size_t>("smp.num_threads",                &num_threads,                                        SValidator<size_t>::SVFRangeIn( 0, 20)),
-                SValidator<size_t>("mc_params.n_bins",                &mc_params.n_bins,                                SValidator<size_t>::SVFRangeIn( 1, 100)),
-                SValidator<size_t>("profile.swa_laden_pages_before_SWA_0",
-                                                                &swa_laden_pages_before_SWA_0,                        SValidator<size_t>::SVFRangeIn( 1, 100)),
-                SValidator<size_t>("mc_param.smooth_side",        &mc_params.smooth_side,                                SValidator<size_t>::SVFRangeIn( 0, 5)),
+                SValidator<size_t>("smp.num_threads",                      &num_threads,                  SValidator<size_t>::SVFRangeIn( 0, 20)),
+                SValidator<size_t>("mc_params.n_bins",                     &mc_params.n_bins,             SValidator<size_t>::SVFRangeIn( 1, 100)),
+                SValidator<size_t>("profile.swa_laden_pages_before_SWA_0", &swa_laden_pages_before_SWA_0, SValidator<size_t>::SVFRangeIn( 1, 100)),
+                SValidator<size_t>("mc_param.smooth_side",                 &mc_params.smooth_side,        SValidator<size_t>::SVFRangeIn( 0, 5)),
         }),
         config_keys_b ({
-                SValidator<bool>("ctl_param.DBAmendment1",        &ctl_params0.DBAmendment1),
-                SValidator<bool>("ctl_param.DBAmendment2",        &ctl_params0.DBAmendment2),
-                SValidator<bool>("ctl_param.AZAmendment1",        &ctl_params0.AZAmendment1),
-                SValidator<bool>("ctl_param.AZAmendment2",        &ctl_params0.AZAmendment2),
-                SValidator<bool>("profile.score_unscored_as_wake",
-                                                                  &score_unscored_as_wake),
-                SValidator<bool>("StrictSubjectIdChecks",        &strict_subject_id_checks),
+                SValidator<bool>("ctl_param.DBAmendment1",         &ctl_params0.DBAmendment1),
+                SValidator<bool>("ctl_param.DBAmendment2",         &ctl_params0.DBAmendment2),
+                SValidator<bool>("ctl_param.AZAmendment1",         &ctl_params0.AZAmendment1),
+                SValidator<bool>("ctl_param.AZAmendment2",         &ctl_params0.AZAmendment2),
+                SValidator<bool>("profile.score_unscored_as_wake", &score_unscored_as_wake),
+                SValidator<bool>("StrictSubjectIdChecks",          &strict_subject_id_checks),
         }),
         config_keys_s ({
-                SValidator<string>("LastUsedVersion",                &last_used_version),
+                SValidator<string>("LastUsedVersion", &last_used_version),
         })
 {
         char *tmp = canonicalize_file_name(session_dir_.c_str());
@@ -197,6 +194,7 @@ for_all_subjects( const TSubjectOpFun& F, const TSubjectReportFun& report, const
                         report( *get<0>(v[i]), *get<1>(v[i]),
                                 ++global_i, v.size());
                 }
+// rest of loop, expressly not critical, and so, will be eligible for OMP
                 F( *get<1>(v[i]));
         }
 }
diff --git a/upstream/src/aghermann/expdesign/profile.hh b/upstream/src/aghermann/expdesign/profile.hh
index c64c59e..a668d13 100644
--- a/upstream/src/aghermann/expdesign/profile.hh
+++ b/upstream/src/aghermann/expdesign/profile.hh
@@ -15,12 +15,9 @@
 
 #include "recording.hh"
 
-namespace agh {
-
 using namespace std;
 
-
-
+namespace agh {
 
 class CProfile
   : private SProfileParamSet {
@@ -30,93 +27,90 @@ class CProfile
                   const SProfileParamSet&);
         CProfile (CSubject&, const string& d, const sigfile::SChannel& h,
                   const SProfileParamSet&);
-        void create_timeline( const SProfileParamSet& params)
-                {
-                        *(SProfileParamSet*)this = params;
-                        create_timeline();
-                }
-        void create_timeline();
-        bool need_compute( const SProfileParamSet&);
 
-        const SProfileParamSet& P() const
-                                        { return *this; }
-        size_t sim_start() const        { return _sim_start; }
-        size_t sim_end() const                { return _sim_end; }
-        size_t baseline_end() const        { return _baseline_end; }
-        size_t pages_with_swa() const        { return _pages_with_SWA; }
-        size_t pages_non_wake() const        { return _pages_non_wake; }
-        size_t pages_in_bed() const        { return _pages_in_bed; }
-        double SWA_L() const                { return _SWA_L; }
-        double SWA_0() const                { return _SWA_0; }
-        double SWA_100() const                { return _SWA_100; }
-        double metric_avg() const        { return _metric_avg; }
+        const SProfileParamSet& P() const { return *this; }
+        size_t sim_start()          const { return _sim_start; }
+        size_t sim_end()            const { return _sim_end; }
+        size_t baseline_end()       const { return _baseline_end; }
+        size_t pages_with_swa()     const { return _pages_with_SWA; }
+        size_t pages_non_wake()     const { return _pages_non_wake; }
+        size_t pages_in_bed()       const { return _pages_in_bed; }
+        double SWA_L()              const { return _SWA_L; }
+        double SWA_0()              const { return _SWA_0; }
+        double SWA_100()            const { return _SWA_100; }
+        double metric_avg()         const { return _metric_avg; }
+        size_t pagesize()           const { return _pagesize; }
 
         const vector<sigfile::SPageSimulated>&
-        timeline() const                { return _timeline; }
+        timeline() const
+                { return _timeline; }
 
         typedef pair<size_t, size_t> TBounds;
         const vector<TBounds>&
-        mm_bounds() const                { return _mm_bounds; }
+        mm_bounds() const
+                { return _mm_bounds; }
 
         const vector<CRecording*>&
-        mm_list()                         { return _mm_list; }
+        mm_list()
+                { return _mm_list; }
+
+        const char* subject() const;
+        const char* session() const;
+        const char* channel() const;
 
         const sigfile::SPageSimulated&
         operator[]( size_t p) const
-                {
-                        return _timeline[p];
-                }
+                { return _timeline[p]; }
 
         time_t nth_episode_start_time( size_t n) const;
-        time_t nth_episode_end_time( size_t n) const;
-        size_t nth_episode_start_page( size_t n) const;
-        size_t nth_episode_end_page( size_t n) const;
+        time_t nth_episode_end_time( size_t) const;
+        size_t nth_episode_start_page( size_t) const;
+        size_t nth_episode_end_page( size_t) const;
 
-        size_t pagesize() const
+        void create_timeline();
+        void create_timeline( const SProfileParamSet& params)
                 {
-                        return _pagesize;
+                        *(SProfileParamSet*)this = params;
+                        create_timeline();
                 }
 
-        const char* subject() const;
-        const char* session() const;
-        const char* channel() const;
+        bool need_compute( const SProfileParamSet&);
 
-        enum TFlags {
-                ok                        = 0,
-                enoscore                = 1,
-                efarapart                = 2,
-                esigtype                = 4,
-                etoomanymsmt                = 8,
-                enoswa                        = 16,
-                eamendments_ineffective        = 32,
-                ers_nonsensical                = 64,
-                enegoffset                = 128,
-                euneq_pagesize                = 256
+        enum TFlags : int16_t {
+                ok                      = 0,
+                enoscore                = 1 << 1,
+                efarapart               = 1 << 2,
+                esigtype                = 1 << 3,
+                etoomanymsmt            = 1 << 4,
+                enoswa                  = 1 << 5,
+                eamendments_ineffective = 1 << 6,
+                ers_nonsensical         = 1 << 7,
+                enegoffset              = 1 << 8,
+                euneq_pagesize          = 1 << 9,
         };
 
         static string explain_status( int);
 
     protected:
-        int        _status;
+        int     _status;
 
         CProfile (const CProfile&) = delete;
         CProfile ()
-                {
-                        throw runtime_error ("nono");
-                }
+                { throw runtime_error ("nono"); }
         CProfile (CProfile&& rv);
 
-        size_t        _sim_start,
+        size_t  _sim_start,
                 _sim_end,
                 _baseline_end,
                 _pages_with_SWA,
                 _pages_non_wake,
                 _pages_in_bed;
-        double        _SWA_L,
-                _SWA_0,        _SWA_100,
+        double  _SWA_L,
+                _SWA_0,
+                _SWA_100,
                 _metric_avg;
 
-        time_t        _0at;
+        time_t  _0at;
         vector<sigfile::SPageSimulated>
                 _timeline;
         vector<TBounds>  // in pages
@@ -125,7 +119,7 @@ class CProfile
         vector<CRecording*>
                 _mm_list;
     private:
-        size_t        _pagesize;  // since power is binned each time it is
+        size_t  _pagesize;  // since power is binned each time it is
                             // collected in layout_measurements() and
                             // then detached, we keep it here
                             // privately
diff --git a/upstream/src/aghermann/expdesign/recording.cc b/upstream/src/aghermann/expdesign/recording.cc
index f6a8e40..be4c0ab 100644
--- a/upstream/src/aghermann/expdesign/recording.cc
+++ b/upstream/src/aghermann/expdesign/recording.cc
@@ -52,10 +52,10 @@ display_name() const
 {
         using agh::str::sasprintf;
         switch ( metric ) {
-        case metrics::TType::psd: return sasprintf( "%s (%g-%g Hz)", metric_name(), P.psd.freq_from, P.psd.freq_upto);
-        case metrics::TType::swu: return sasprintf( "%s (%g Hz)",    metric_name(), P.swu.f0);
-        case metrics::TType::mc : return sasprintf( "%s (%g Hz)",    metric_name(), P.mc.f0);
-        default: return sasprintf( "(invalid metric: %d)", metric);
+        case metrics::TType::psd: return move(sasprintf( "%s (%g-%g Hz)", metric_name(), P.psd.freq_from, P.psd.freq_upto));
+        case metrics::TType::swu: return move(sasprintf( "%s (%g Hz)",    metric_name(), P.swu.f0));
+        case metrics::TType::mc : return move(sasprintf( "%s (%g Hz)",    metric_name(), P.mc.f0));
+        default: return move(sasprintf( "(invalid metric: %d)", metric));
         }
 }
 
@@ -175,9 +175,9 @@ CProfile (CRecording& M,
         _pagesize = M.psd_profile.Pp.pagesize;
         _pages_in_bed = 0;
 
-        int        pa = (size_t)difftime( M.F().start_time(), _0at) / _pagesize,
+        int     pa = (size_t)difftime( M.F().start_time(), _0at) / _pagesize,
                 pz = (size_t)difftime( M.F().end_time(), _0at) / _pagesize;
-        time_t        dima = M.F().start_time();
+        time_t  dima = M.F().start_time();
         printf( "CProfile::CProfile(): adding single recording %s of [%s, %s, %s] %zu pages (%zu full, %zu in hypnogram) recorded %s",
                 metrics::name(params.metric), M.F().subject().id.c_str(), M.F().session(), M.F().episode(),
                 M.total_pages(), M.full_pages(), M.hypnogram().pages(), ctime( &dima));
diff --git a/upstream/src/aghermann/expdesign/recording.hh b/upstream/src/aghermann/expdesign/recording.hh
index 3b8a41a..62191ae 100644
--- a/upstream/src/aghermann/expdesign/recording.hh
+++ b/upstream/src/aghermann/expdesign/recording.hh
@@ -20,29 +20,26 @@
 #include "aghermann/model/forward-decls.hh"
 #include "forward-decls.hh"
 
-namespace agh {
-
 using namespace std;
 
+namespace agh {
 
 struct SProfileParamSet {
         metrics::TType
                 metric;
         const char*
         metric_name() const
-                {
-                        return metrics::name(metric);
-                }
+                { return metrics::name(metric); }
 
         struct PSD {
-                double        freq_from,
+                double  freq_from,
                         freq_upto;
         };
         struct MC {
-                double        f0;
+                double  f0;
         };
         struct SWU {
-                double        f0;
+                double  f0;
         };
 
         union {
@@ -51,9 +48,9 @@ struct SProfileParamSet {
                 SWU swu;
         } P;
 
-        double        req_percent_scored;
-        size_t        swa_laden_pages_before_SWA_0;
-        bool        score_unscored_as_wake;
+        double  req_percent_scored;
+        size_t  swa_laden_pages_before_SWA_0;
+        bool    score_unscored_as_wake;
 
         SProfileParamSet (const SProfileParamSet::PSD& psd_,
                           double req_percent_scored_ = 90.,
@@ -95,9 +92,7 @@ struct SProfileParamSet {
         SProfileParamSet ()
                 {} // if initialised as part of a class with us as base, exception already thrown by those
         bool operator<( const SProfileParamSet&) const
-                {
-                        return false;
-                }
+                { return false; }
 };
 
 template<metrics::TType t>
@@ -157,63 +152,51 @@ class CRecording {
         const char* episode() const      {  return _source().episode(); }
         const char* channel() const      {  return _source().channel_by_id(_sig_no).name(); }
 
-        sigfile::SChannel::TType signal_type() const
-                {
-                        return _source().signal_type(_sig_no);
-                }
+        sigfile::SChannel::TType
+        signal_type() const
+                { return _source().signal_type(_sig_no); }
+
+        const sigfile::CSource&
+        F() const
+                { return _source(); }
+        sigfile::CSource&             // although we shouldn't want to access CEDFFile writably from CRecording,
+        F()                           // this shortcut saves us the trouble of AghCC->subject_by_x(,,,).measurements...
+                { return _source(); } // on behalf of agh::ui::SChannelPresentation
 
-        const sigfile::CSource& F() const
-                {
-                        return _source();
-                }
-        sigfile::CSource& F()  // although we shouldn't want to access CEDFFile writably from CRecording,
-                {      // this shortcut saves us the trouble of AghCC->subject_by_x(,,,).measurements...
-                        return _source();  // on behalf of agh::ui::SChannelPresentation
-                }
         const sigfile::CHypnogram&
         hypnogram() const
-                {
-                        return *(sigfile::CHypnogram*)&_source;
-                }
+                { return *(sigfile::CHypnogram*)&_source; }
 
-        int h() const
-                {
-                        return _sig_no;
-                }
+        int
+        h() const
+                { return _sig_no; }
 
-        bool operator<( const CRecording &o) const
-                {
-                        return _source().end_time() < o._source().start_time();
-                }
+        bool
+        operator<( const CRecording &o) const
+                { return _source().end_time() < o._source().start_time(); }
 
-        time_t start() const
-                {
-                        return _source().start_time();
-                }
-        time_t end() const
-                {
-                        return _source().end_time();
-                }
+        time_t
+        start() const
+                { return _source().start_time(); }
+        time_t
+        end() const
+                { return _source().end_time(); }
 
         // this one damn identical in all bases
-        size_t pagesize() const
-                {
-                        return ((metrics::psd::CProfile*)this) -> Pp.pagesize;
-                }
+        size_t
+        pagesize() const
+                { return ((metrics::psd::CProfile*)this) -> Pp.pagesize; }
 
         // actual page counts based on actual edf samples
-        size_t total_pages() const
-                {
-                        return _source().recording_time() / pagesize();
-                }
-        size_t full_pages() const
-                {
-                        return round(_source().recording_time() / pagesize());
-                }
-        size_t total_samples() const
-                {
-                        return _source().recording_time() * _source().samplerate(_sig_no);
-                }
+        size_t
+        total_pages() const
+                { return _source().recording_time() / pagesize(); }
+        size_t
+        full_pages() const
+                { return round(_source().recording_time() / pagesize()); }
+        size_t
+        total_samples() const
+                { return _source().recording_time() * _source().samplerate(_sig_no); }
 
         valarray<TFloat>
         course( const SProfileParamSet::PSD&);
@@ -256,21 +239,20 @@ class CRecording {
 
         metrics::psd::CProfile psd_profile;
         metrics::swu::CProfile swu_profile;
-        metrics::mc::CProfile        mc_profile;
+        metrics::mc::CProfile  mc_profile;
 
-        bool have_uc_determined() const
-                {
-                        return uc_params;
-                }
+        bool
+        have_uc_determined() const
+                { return uc_params; }
         agh::beersma::SUltradianCycle
                 *uc_params;
 
     protected:
-        int        _status;
+        int     _status;
 
         sigfile::CTypedSource&
                 _source;
-        int        _sig_no;
+        int     _sig_no;
 };
 
 
diff --git a/upstream/src/aghermann/expdesign/subject.cc b/upstream/src/aghermann/expdesign/subject.cc
index eea9bdc..9046950 100644
--- a/upstream/src/aghermann/expdesign/subject.cc
+++ b/upstream/src/aghermann/expdesign/subject.cc
@@ -81,7 +81,7 @@ list<SEpisode::SAnnotation>
 SEpisode::
 get_annotations() const
 {
-        list<agh::SEpisode::SAnnotation>
+        list<SEpisode::SAnnotation>
                 ret;
         for ( auto &F : sources ) {
                 auto HH = F().channel_list();
@@ -94,7 +94,7 @@ get_annotations() const
                         ret.emplace_back( F(), -1, A);
         }
         ret.sort();
-        return ret;
+        return move(ret);
 }
 
 
diff --git a/upstream/src/aghermann/expdesign/subject.hh b/upstream/src/aghermann/expdesign/subject.hh
index 6996e28..d2cfa41 100644
--- a/upstream/src/aghermann/expdesign/subject.hh
+++ b/upstream/src/aghermann/expdesign/subject.hh
@@ -32,10 +32,9 @@
 #endif
 
 
-namespace agh {
-
 using namespace std;
 
+namespace agh {
 
 struct SEpisode {
 
@@ -45,11 +44,10 @@ struct SEpisode {
                   const metrics::mc::SPPack&);
 
         time_t start_time() const        { return sources.front()().start_time(); }
-        time_t end_time() const                { return sources.front()().end_time();         }
-        time_t start_time()                { return sources.front()().start_time(); }
-        time_t end_time()                { return sources.front()().end_time();         }
-        time_t        // relative to start_time
-                start_rel,
+        time_t end_time() const          { return sources.front()().end_time();   }
+        time_t start_time()              { return sources.front()().start_time(); }
+        time_t end_time()                { return sources.front()().end_time();   }
+        time_t  start_rel,  // relative to start_time
                 end_rel;
 
         typedef map<sigfile::SChannel, CRecording> TRecordingSet;
@@ -64,10 +62,7 @@ struct SEpisode {
                 { return e == name(); }
         bool
         operator<( const SEpisode& rv) const
-                {
-                        return sources.front()().end_time()
-                                < rv.sources.front()().start_time();
-                }
+                { return sources.front()().end_time() < rv.sources.front()().start_time(); }
 
         struct SAnnotation
           : public sigfile::SAnnotation {
@@ -88,6 +83,7 @@ struct SEpisode {
                 const char*
                 channel() const
                         { return (_h == -1) ? "(embedded)" : _source.channel_by_id(_h).name(); }
+
                 agh::alg::SSpan<float>
                 page_span( size_t pagesize) const
                         { return span / (float)pagesize; }
@@ -104,9 +100,13 @@ struct SEpisode {
 };
 
 
+
+
 struct SEpisodeSequence {
+
         friend class agh::CExpDesign;
         friend class agh::CProfile;
+
     public:
         list<SEpisode> episodes;
         size_t
@@ -122,6 +122,7 @@ struct SEpisodeSequence {
 
         const SEpisode&
         operator[]( const string& e) const;
+
         SEpisode&
         operator[]( const string& e);
 
@@ -132,7 +133,7 @@ struct SEpisodeSequence {
                  const metrics::psd::SPPack&,
                  const metrics::swu::SPPack&,
                  const metrics::mc::SPPack&,
-                 float max_hours_apart = 7*24.);
+                 float max_hours_apart = 7*24.);  // TODO: do this check after all episodes have been added
 
       // simulations rather belong here
         typedef map<SProfileParamSet,
@@ -149,7 +150,6 @@ struct SEpisodeSequence {
 
 typedef size_t sid_t;
 
-
 class CSubject : public SSubjectId {
 
         void operator=( const CSubject&) = delete;
@@ -200,15 +200,13 @@ class CSubject : public SSubjectId {
 
         bool
         have_session( const string& d) const
-                {
-                        return measurements.find(d) != measurements.end();
-                }
+                { return measurements.find(d) != measurements.end(); }
 
     private:
-        int        _status;
-        sid_t        _id; // eventually to allow distinctly identifiable namesakes in different groups
+        int     _status;
+        sid_t   _id; // eventually to allow distinctly identifiable namesakes in different groups
 
-        string        _dir;
+        string  _dir;
 };
 
 } // namespace agh
diff --git a/upstream/src/aghermann/expdesign/tree-scanner.cc b/upstream/src/aghermann/expdesign/tree-scanner.cc
index 058d0f8..c4b2a38 100644
--- a/upstream/src/aghermann/expdesign/tree-scanner.cc
+++ b/upstream/src/aghermann/expdesign/tree-scanner.cc
@@ -15,25 +15,26 @@
 #include <string>
 
 #include "common/alg.hh"
+#include "common/containers.hh"
 #include "libsigfile/all.hh"
 #include "expdesign.hh"
 
 
 using namespace std;
 
-
+using namespace agh;
 
 namespace {
 struct progress_fun_stdout_fo {
-        void operator() ( const string& current, size_t n, size_t i) const
+        void operator()( const string& current, size_t n, size_t i) const
                 {
                         printf( "(%zu of %zu) %s\n", i, n, current.c_str());
                 }
 };
 } // namespace
 
-agh::CExpDesign::TMsmtCollectProgressIndicatorFun
-        agh::CExpDesign::progress_fun_stdout = progress_fun_stdout_fo();
+CExpDesign::TMsmtCollectProgressIndicatorFun
+        CExpDesign::progress_fun_stdout = progress_fun_stdout_fo();
 
 
 // these old farts have been here from 2010 or earlier
@@ -42,7 +43,7 @@ agh::CExpDesign::TMsmtCollectProgressIndicatorFun
 // let them be
 
 int
-agh::SEpisodeSequence::
+SEpisodeSequence::
 add_one( sigfile::CTypedSource&& Fmc,
          const metrics::psd::SPPack& fft_params,
          const metrics::swu::SPPack& swu_params,
@@ -56,7 +57,7 @@ add_one( sigfile::CTypedSource&& Fmc,
               // ensure the newly added episode is well-placed
                 for ( auto &E : episodes )
                       // does not overlap with existing ones
-                        if ( agh::alg::overlap(
+                        if ( alg::overlap(
                                      E.start_time(), E.end_time(),
                                      Fmc().start_time(), Fmc().end_time()) )
                                 return AGH_EPSEQADD_OVERLAP;
@@ -108,7 +109,7 @@ add_one( sigfile::CTypedSource&& Fmc,
         for_each( next( episodes.begin()), episodes.end(),
                   [&shift] ( SEpisode& E )
                   {
-                          E.start_rel        = E.start_time() + shift;
+                          E.start_rel      = E.start_time() + shift;
                           E.end_rel        = E.end_time()   + shift;
                           // printf("E %s: ", E.name());
                           // puts( asctime( localtime(&E.start_time())));
@@ -126,7 +127,7 @@ add_one( sigfile::CTypedSource&& Fmc,
 
 // create new session/episode as necessary
 int
-agh::CExpDesign::
+CExpDesign::
 register_intree_source( sigfile::CTypedSource&& F,
                         const char **reason_if_failed_p)
 {
@@ -137,7 +138,7 @@ register_intree_source( sigfile::CTypedSource&& F,
                 string toparse (F().filename());
                 if ( strncmp( F().filename(), _session_dir.c_str(), _session_dir.size()) == 0 )
                         toparse.erase( 0, _session_dir.size());
-                list<string> broken_path = agh::fs::path_elements( toparse);
+                list<string> broken_path = fs::path_elements( toparse);
                 assert ( broken_path.size() == 5 );
                 list<string>::iterator pe = broken_path.begin();
                 string& g_name = (pe = next(pe), *pe),
@@ -147,10 +148,10 @@ register_intree_source( sigfile::CTypedSource&& F,
                         fs::make_fname_base(
                                 *next(pe),
                                 sigfile::supported_sigfile_extensions,
-                                agh::fs::TMakeFnameOption::normal);
+                                fs::TMakeFnameOption::normal);
                 // take care of the case of episode-2.edf
                 {
-                        auto subf = agh::str::tokens_trimmed(e_name, "-");
+                        auto subf = str::tokens_trimmed(e_name, "-");
                         if ( subf.size() == 2 ) {
                                 try {
                                         stoi(subf.back());
@@ -194,13 +195,14 @@ register_intree_source( sigfile::CTypedSource&& F,
                 }
 
                 CSubject *J;
-                CJGroup& G = groups[g_name];
-                CJGroup::iterator Ji;
-                if ( (Ji = find( G.begin(), G.end(), j_name)) == G.end() ) {
-                        G.emplace_back( _session_dir + '/' + g_name + '/' + j_name, _id_pool++);
-                        J = &G.back();
-                } else
-                        J = &*Ji;
+                {
+                        CJGroup& G = groups[g_name];
+                        CJGroup::iterator Ji = find( G.begin(), G.end(), j_name);
+                        J = (Ji == G.end())
+                                ? (G.emplace_back( _session_dir + '/' + g_name + '/' + j_name, _id_pool++),
+                                   &G.back())
+                                : &*Ji;
+                }
 
               // check/update CSubject::SSubjectId fields against those in the file being added
                 // printf( "Update subject details: [%s, %s, %c, %s] <- [%s, %s, %c, %s]\n",
@@ -250,7 +252,7 @@ register_intree_source( sigfile::CTypedSource&& F,
 
 
 bool
-agh::CExpDesign::
+CExpDesign::
 is_supported_source( sigfile::CTypedSource& F)
 {
         using namespace sigfile;
@@ -258,12 +260,12 @@ is_supported_source( sigfile::CTypedSource& F)
                 CEDFFile::TSubtype e;
                 CTSVFile::TSubtype t;
         } u;
-        return (F.type() == CTypedSource::TType::edf and
+        return (F.type() == CTypedSource::TType::edf &&
                 (u.e = F.obj<CEDFFile>().subtype(),
                  (u.e == CEDFFile::TSubtype::edf ||
                   u.e == CEDFFile::TSubtype::edfplus_c)))
-                or
-                (F.type() == CTypedSource::TType::ascii and
+                ||
+                (F.type() == CTypedSource::TType::ascii &&
                  (u.t = F.obj<CTSVFile>().subtype(),
                   (u.t == CTSVFile::TSubtype::csv ||
                    u.t == CTSVFile::TSubtype::tsv)));
@@ -271,12 +273,12 @@ is_supported_source( sigfile::CTypedSource& F)
 
 namespace {
 
-size_t
-        current_sigfile_source;
-agh::CExpDesign
+size_t  current_sigfile_source;
+
+CExpDesign
         *only_expdesign;
 
-agh::CExpDesign::TMsmtCollectProgressIndicatorFun
+CExpDesign::TMsmtCollectProgressIndicatorFun
         only_progress_fun;
 
 int
@@ -288,7 +290,7 @@ supported_sigfile_processor( const char *fname, const struct stat*, int flag, st
                         return 0;
                 if ( sigfile::is_fname_ext_supported( fname) ) {
                         ++current_sigfile_source;
-                        only_progress_fun( fname, agh::fs::total_supported_sigfiles, current_sigfile_source);
+                        only_progress_fun( fname, fs::total_supported_sigfiles, current_sigfile_source);
                         try {
                                 using namespace sigfile;
                                 CTypedSource F {fname, (size_t)roundf(only_expdesign->fft_params.pagesize)};
@@ -297,8 +299,8 @@ supported_sigfile_processor( const char *fname, const struct stat*, int flag, st
                                         only_expdesign->log_message( "$$%s:", fname);
                                         only_expdesign->log_message( "%s", st.c_str());
                                 }
-                                // we only support edf and edfplus/edf_c
-                                if ( agh::CExpDesign::is_supported_source(F) )
+
+                                if ( CExpDesign::is_supported_source(F) )
                                         only_expdesign -> register_intree_source( move(F));
                                 else
                                         only_expdesign -> log_message( "File %s: unsupported format", fname);
@@ -336,17 +338,17 @@ avg_tm( vector<TTimePair>& tms)
 } // namespace
 
 void
-agh::CExpDesign::
+CExpDesign::
 scan_tree( TMsmtCollectProgressIndicatorFun user_progress_fun)
 {
         groups.clear();
 
       // glob it!
-        agh::fs::total_supported_sigfiles = 0;
-        nftw( "./", agh::fs::supported_sigfile_counter, 20, 0);
+        fs::total_supported_sigfiles = 0;
+        nftw( "./", fs::supported_sigfile_counter, 20, 0);
         printf( "CExpDesign::scan_tree(\"%s\"): %zu edf file(s) found\n",
-                session_dir(), agh::fs::total_supported_sigfiles);
-        if ( agh::fs::total_supported_sigfiles == 0 )
+                session_dir(), fs::total_supported_sigfiles);
+        if ( fs::total_supported_sigfiles == 0 )
                 return;
 
         current_sigfile_source = 0;
@@ -360,7 +362,7 @@ scan_tree( TMsmtCollectProgressIndicatorFun user_progress_fun)
 
       // find any subjects with incomplete episode sets
         list<string> complete_episode_set = enumerate_episodes();
-        size_t        n_episodes = complete_episode_set.size();
+        size_t  n_episodes = complete_episode_set.size();
 
         for ( auto &G : groups )
                 for ( auto &J : G.second )
@@ -394,7 +396,7 @@ scan_tree( TMsmtCollectProgressIndicatorFun user_progress_fun)
 
 
 void
-agh::CExpDesign::
+CExpDesign::
 compute_profiles()
 {
         TRecordingOpFun F =
diff --git a/upstream/src/aghermann/ui/mw/mw_cb.cc b/upstream/src/aghermann/ui/mw/mw_cb.cc
index 77dd7f1..e8c571e 100644
--- a/upstream/src/aghermann/ui/mw/mw_cb.cc
+++ b/upstream/src/aghermann/ui/mw/mw_cb.cc
@@ -201,7 +201,7 @@ eMsmtProfileType_changed_cb(
         vector<agh::CProfile*> redo_profiles;
         for ( auto &G : ED.groups )
                 for ( auto &J : G )
-                        if ( J.cprofile and J.cprofile->need_compute( params) ) {
+                        if ( J.cprofile && J.cprofile->need_compute( params) ) {
                                 if ( !bb )
                                         bb = new SBusyBlock (ED.wMainWindow);
                                 redo_profiles.push_back( J.cprofile);
diff --git a/upstream/src/common/alg.hh b/upstream/src/common/alg.hh
index acf45ec..7a3b422 100644
--- a/upstream/src/common/alg.hh
+++ b/upstream/src/common/alg.hh
@@ -30,9 +30,9 @@ namespace alg {
 // __attribute__ ((pure))
 // pod_swap( T&& a, T&& b)
 // {
-// 	T&& tmp = move(a);
-// 	a = move(b);
-// 	b = move(tmp);
+//         T&& tmp = move(a);
+//         a = move(b);
+//         b = move(tmp);
 // }
 
 
@@ -41,9 +41,9 @@ template <typename T>
 inline bool
 __attribute__ ((pure))
 overlap( const T& a, const T& b,
-	 const T& c, const T& d)
+         const T& c, const T& d)
 {
-	return not ((a < c && b < c) || (a > d && b > d));
+        return not ((a < c && b < c) || (a > d && b > d));
 }
 
 template <typename T>
@@ -51,7 +51,7 @@ inline bool
 __attribute__ ((pure))
 between( const T& a, const T& b, const T&c)
 {
-	return a <= b && b <= c;
+        return a <= b && b <= c;
 }
 
 
@@ -59,59 +59,59 @@ between( const T& a, const T& b, const T&c)
 // using TRegion = class pair<size_t, size_t>;  // come gcc 4.7, come!
 template <typename T>
 struct SSpan {
-	T a, z;
-	typedef T value_type;
-	SSpan (const T& a_, const T& z_)
-	      : a (a_), z (z_)
-		{}
-	bool operator==( const SSpan<T>& rv) const
-		{
-			return a == rv.a && z == rv.z;
-		}
-	bool operator<( const SSpan<T>& rv) const
-		{
-			return a < rv.a;
-		}
-	T
-	size() const
-		{
-			return z - a;
-		}
-	template <typename U>
-	SSpan<U>
-	operator*( const U& f) const
-		{
-			return {(U)(a * f), (U)(z * f)};
-		}
-	template <typename U>
-	SSpan<U>
-	operator/( const U& f) const
-		{
-			return {(U)(a / f), (U)(z / f)};
-		}
-	float
-	dirty( const SSpan<T>& b) const
-		{
-			if ( between(a, b.a, z) && between(b.a, z, b.z) )      // aa .. ba .. az .. bz
-				return (float)(z - b.a) / size();
-			else if ( between(b.a, a, b.z) && between(a, b.z, z) ) // ba .. aa .. bz .. az
-				return (float)(b.z - a) / size();
-			else if ( between(a, b.a, z) && between(a, b.z, z) )   // b entirely inside a
-				return (float)b.size() / size();
-			else if ( between(b.a, a, b.z) && between(b.a, z, b.z) ) // a entirely inside b
-				return 1.f;
-			else
-				return 0.f;
-		}
-
-	float
-	dirty( const list<SSpan<T>>& B) const
-		{
-			float q = 0.;
-			for ( auto& b : B )
-				q += dirty(b);
-			return q;
-		}
+        T a, z;
+        typedef T value_type;
+        SSpan (const T& a_, const T& z_)
+              : a (a_), z (z_)
+                {}
+        bool operator==( const SSpan<T>& rv) const
+                {
+                        return a == rv.a && z == rv.z;
+                }
+        bool operator<( const SSpan<T>& rv) const
+                {
+                        return a < rv.a;
+                }
+        T
+        size() const
+                {
+                        return z - a;
+                }
+        template <typename U>
+        SSpan<U>
+        operator*( const U& f) const
+                {
+                        return {(U)(a * f), (U)(z * f)};
+                }
+        template <typename U>
+        SSpan<U>
+        operator/( const U& f) const
+                {
+                        return {(U)(a / f), (U)(z / f)};
+                }
+        float
+        dirty( const SSpan<T>& b) const
+                {
+                        if ( between(a, b.a, z) && between(b.a, z, b.z) )      // aa .. ba .. az .. bz
+                                return (float)(z - b.a) / size();
+                        else if ( between(b.a, a, b.z) && between(a, b.z, z) ) // ba .. aa .. bz .. az
+                                return (float)(b.z - a) / size();
+                        else if ( between(a, b.a, z) && between(a, b.z, z) )   // b entirely inside a
+                                return (float)b.size() / size();
+                        else if ( between(b.a, a, b.z) && between(b.a, z, b.z) ) // a entirely inside b
+                                return 1.f;
+                        else
+                                return 0.f;
+                }
+
+        float
+        dirty( const list<SSpan<T>>& B) const
+                {
+                        float q = 0.;
+                        for ( auto& b : B )
+                                q += dirty(b);
+                        return q;
+                }
 
 };
 
@@ -122,7 +122,7 @@ int
 __attribute__ ((pure))
 sign( T x)
 {
-	return (x > 0) ? 1 : (x == 0) ? 0 : -1;
+        return (x > 0) ? 1 : (x == 0) ? 0 : -1;
 }
 
 
@@ -131,10 +131,10 @@ void
 __attribute__ ((pure))
 ensure_within( T& v, const T& l, const T& h)
 {
-	if ( v < l )
-		v = l;
-	else if ( v > h )
-		v = h;
+        if ( v < l )
+                v = l;
+        else if ( v > h )
+                v = h;
 }
 
 template <typename T>
@@ -142,12 +142,12 @@ T
 __attribute__ ((pure))
 value_within( const T& v, const T& l, const T& h)
 {
-	T o {v};
-	if ( v < l )
-		o = l;
-	else if ( v > h )
-		o = h;
-	return o;
+        T o {v};
+        if ( v < l )
+                o = l;
+        else if ( v > h )
+                o = h;
+        return o;
 }
 
 
@@ -156,17 +156,17 @@ inline valarray<double>
 __attribute__ ((pure))
 to_vad( valarray<double>&& rv)
 {
-	return move(rv);
+        return move(rv);
 }
 
 inline valarray<double>
 __attribute__ ((pure))
 to_vad( const valarray<float>& rv)
 {
-	valarray<double> ret (rv.size());
-	for ( size_t i = 0; i < rv.size(); ++i )
-		ret[i] = rv[i];
-	return move(ret);
+        valarray<double> ret (rv.size());
+        for ( size_t i = 0; i < rv.size(); ++i )
+                ret[i] = rv[i];
+        return move(ret);
 }
 
 
@@ -175,14 +175,14 @@ to_vad( const valarray<float>& rv)
 inline float
 __attribute__ ((pure))
 calibrate_display_scale( const valarray<TFloat>& signal,
-			 size_t over, float fit)
+                         size_t over, float fit)
 {
-	return fit / (abs(signal[ slice (0, over, 1) ]).sum() / over) / 8;
+        return fit / (abs(signal[ slice (0, over, 1) ]).sum() / over) / 8;
 }
 
 
 double sensible_scale_reduction_factor( double display_scale,
-					double constraint_max, double constraint_min = 8.);  // 8 pixels
+                                        double constraint_max, double constraint_min = 8.);  // 8 pixels
 
 } // namespace alg
 } // namespace agh
diff --git a/upstream/src/common/config-validate.hh b/upstream/src/common/config-validate.hh
index 4de4956..cde3f2c 100644
--- a/upstream/src/common/config-validate.hh
+++ b/upstream/src/common/config-validate.hh
@@ -35,13 +35,13 @@ using namespace std;
 
 template <typename T> libconfig::Setting::Type libconfig_type_id();
 
-template <> libconfig::Setting::Type inline libconfig_type_id<bool>  	   () { return libconfig::Setting::Type::TypeBoolean; }
-template <> libconfig::Setting::Type inline libconfig_type_id<int>   	   () { return libconfig::Setting::Type::TypeInt;     }
-template <> libconfig::Setting::Type inline libconfig_type_id<size_t>	   () { return libconfig::Setting::Type::TypeInt64;   }
+template <> libconfig::Setting::Type inline libconfig_type_id<bool>             () { return libconfig::Setting::Type::TypeBoolean; }
+template <> libconfig::Setting::Type inline libconfig_type_id<int>              () { return libconfig::Setting::Type::TypeInt;     }
+template <> libconfig::Setting::Type inline libconfig_type_id<size_t>           () { return libconfig::Setting::Type::TypeInt64;   }
 template <> libconfig::Setting::Type inline libconfig_type_id<const char*> () { return libconfig::Setting::Type::TypeString;  }
-template <> libconfig::Setting::Type inline libconfig_type_id<string>	   () { return libconfig::Setting::Type::TypeString;  }
-template <> libconfig::Setting::Type inline libconfig_type_id<double>	   () { return libconfig::Setting::Type::TypeFloat;   }
-template <> libconfig::Setting::Type inline libconfig_type_id<float> 	   () { return libconfig::Setting::Type::TypeFloat;   }
+template <> libconfig::Setting::Type inline libconfig_type_id<string>           () { return libconfig::Setting::Type::TypeString;  }
+template <> libconfig::Setting::Type inline libconfig_type_id<double>           () { return libconfig::Setting::Type::TypeFloat;   }
+template <> libconfig::Setting::Type inline libconfig_type_id<float>            () { return libconfig::Setting::Type::TypeFloat;   }
 
 
 
@@ -49,15 +49,15 @@ inline
 libconfig::Setting&
 ensure_path( libconfig::Setting& S, libconfig::Setting::Type type, const string& key)
 {
-	auto pe = agh::str::tokens( key, ".");
-	auto Si = &S;
-	// ensure path
-	for ( auto K = pe.begin(); K != pe.end(); ++K )
-		if ( not Si->exists(*K) ) {
-			Si = &Si->add( *K, (next(K) == pe.end()) ? type : libconfig::Setting::TypeGroup);
-		} else
-			Si = &(*Si)[*K];
-	return *Si;
+        auto pe = agh::str::tokens( key, ".");
+        auto Si = &S;
+        // ensure path
+        for ( auto K = pe.begin(); K != pe.end(); ++K )
+                if ( not Si->exists(*K) ) {
+                        Si = &Si->add( *K, (next(K) == pe.end()) ? type : libconfig::Setting::TypeGroup);
+                } else
+                        Si = &(*Si)[*K];
+        return *Si;
 }
 
 
@@ -65,33 +65,33 @@ template <typename T>
 void
 put( libconfig::Config& C, const string& key, const T& value)
 {
-	ensure_path( C.getRoot(), libconfig_type_id<T>(), key) = value;
+        ensure_path( C.getRoot(), libconfig_type_id<T>(), key) = value;
 }
 template <> // specialise for size_t
 inline void
 put( libconfig::Config& C, const string& key, const size_t& value)
 {
-	if ( value > INT_MAX )
-		fprintf( stderr, "Value being saved is way too long for any practical purpose (unintialized?): %zu\n", value);
-	ensure_path( C.getRoot(), libconfig_type_id<int>(), key) = (int)value;
+        if ( value > INT_MAX )
+                fprintf( stderr, "Value being saved is way too long for any practical purpose (unintialized?): %zu\n", value);
+        ensure_path( C.getRoot(), libconfig_type_id<int>(), key) = (int)value;
 }
 
 template <typename T>
 void
 put( libconfig::Config& C, const string& key, const forward_list<T>& vl)
 {
-	auto& S = ensure_path( C.getRoot(), libconfig::Setting::Type::TypeList, key);
-	for ( auto& V : vl )
-		S.add( libconfig_type_id<T>()) = V;
+        auto& S = ensure_path( C.getRoot(), libconfig::Setting::Type::TypeList, key);
+        for ( auto& V : vl )
+                S.add( libconfig_type_id<T>()) = V;
 }
 
 template <typename T, size_t N>
 void
 put( libconfig::Config& C, const string& key, const array<T, N>& vl)
 {
-	auto& S = ensure_path( C.getRoot(), libconfig::Setting::Type::TypeList, key);
-	for ( auto& V : vl )
-		S.add( libconfig_type_id<T>()) = V;
+        auto& S = ensure_path( C.getRoot(), libconfig::Setting::Type::TypeList, key);
+        for ( auto& V : vl )
+                S.add( libconfig_type_id<T>()) = V;
 }
 
 
@@ -102,47 +102,47 @@ put( libconfig::Config& C, const string& key, const array<T, N>& vl)
 
 template <typename T>
 struct SValidator {
-	string key;
-	T* rcp;
-	struct SVFTrue {
-		bool operator() ( const T&) const { return true; }
-	};
-	struct SVFRangeEx {
-	        T lo, hi;
-		SVFRangeEx( const T& _lo, const T& _hi) : lo(_lo), hi(_hi) {};
-		bool operator() ( const T& v) const { return v > lo && v < hi; }
-	};
-	struct SVFRangeIn {
-	        T lo, hi;
-		SVFRangeIn( const T& _lo, const T& _hi) : lo(_lo), hi(_hi) {};
-		bool operator() ( const T& v) const { return v >= lo && v <= hi; }
-	};
-	function<bool(const T&)> valf;
-
-	template <typename K>
-	SValidator( const K& _key, T* _rcp)
-	      : key (_key), rcp (_rcp), valf {SVFTrue()}
-		{}
-	template <typename K>
-	SValidator( const K& _key, T* _rcp, function<bool (const T&)> _valf)
-	      : key (_key), rcp (_rcp), valf (_valf)
-		{}
-
-	void get( const libconfig::Config& C) const
-		{
-			T tmp;
-			if ( not C.lookupValue( key, tmp) ) {
-				fprintf( stderr, "SValidator::get(): key %s not found\n", key.c_str());
-				return; // leave at default
-			}
-			if ( not valf(tmp) )
-				throw invalid_argument( string("Bad value for \"") + key + "\"");
-			*rcp = tmp;
-		}
-	void put( libconfig::Config& C) const
-		{
-			confval::put( C, key, *rcp);
-		}
+        string key;
+        T* rcp;
+        struct SVFTrue {
+                bool operator() ( const T&) const { return true; }
+        };
+        struct SVFRangeEx {
+                T lo, hi;
+                SVFRangeEx( const T& _lo, const T& _hi) : lo(_lo), hi(_hi) {};
+                bool operator() ( const T& v) const { return v > lo && v < hi; }
+        };
+        struct SVFRangeIn {
+                T lo, hi;
+                SVFRangeIn( const T& _lo, const T& _hi) : lo(_lo), hi(_hi) {};
+                bool operator() ( const T& v) const { return v >= lo && v <= hi; }
+        };
+        function<bool(const T&)> valf;
+
+        template <typename K>
+        SValidator( const K& _key, T* _rcp)
+              : key (_key), rcp (_rcp), valf {SVFTrue()}
+                {}
+        template <typename K>
+        SValidator( const K& _key, T* _rcp, function<bool (const T&)> _valf)
+              : key (_key), rcp (_rcp), valf (_valf)
+                {}
+
+        void get( const libconfig::Config& C) const
+                {
+                        T tmp;
+                        if ( not C.lookupValue( key, tmp) ) {
+                                fprintf( stderr, "SValidator::get(): key %s not found\n", key.c_str());
+                                return; // leave at default
+                        }
+                        if ( not valf(tmp) )
+                                throw invalid_argument( string("Bad value for \"") + key + "\"");
+                        *rcp = tmp;
+                }
+        void put( libconfig::Config& C) const
+                {
+                        confval::put( C, key, *rcp);
+                }
 };
 
 
@@ -169,14 +169,14 @@ template <>
 inline void
 SValidator<size_t>::get( const libconfig::Config& C) const
 {
-	int tmp; // libconfig doesn't deal in unsigned values
-	if ( not C.lookupValue( key, tmp) ) {
-		fprintf( stderr, "SValidator::get(): key %s not found\n", key.c_str());
-		return; // leave at default
-	}
-	if ( not valf(tmp) )
-		throw invalid_argument( string("Bad value for \"") + key + "\"");
-	*rcp = tmp;
+        int tmp; // libconfig doesn't deal in unsigned values
+        if ( not C.lookupValue( key, tmp) ) {
+                fprintf( stderr, "SValidator::get(): key %s not found\n", key.c_str());
+                return; // leave at default
+        }
+        if ( not valf(tmp) )
+                throw invalid_argument( string("Bad value for \"") + key + "\"");
+        *rcp = tmp;
 }
 
 
@@ -186,15 +186,15 @@ get( forward_list<SValidator<T>>& vl,
      libconfig::Config& conf,
      bool nothrow = true)
 {
-	for ( auto& V : vl )
-		if ( nothrow )
-			try {
-				V.get( conf);
-			} catch ( exception& ex) {
-				fprintf( stderr, "confval::get(list): %s\n", ex.what());
-			}
-		else
-			V.get( conf);
+        for ( auto& V : vl )
+                if ( nothrow )
+                        try {
+                                V.get( conf);
+                        } catch ( exception& ex) {
+                                fprintf( stderr, "confval::get(list): %s\n", ex.what());
+                        }
+                else
+                        V.get( conf);
 }
 
 template <typename T>
@@ -202,8 +202,8 @@ void
 put( forward_list<SValidator<T>>& vl,
      libconfig::Config& conf)
 {
-	for ( auto& V : vl )
-		V.put( conf);
+        for ( auto& V : vl )
+                V.put( conf);
 }
 
 
diff --git a/upstream/src/common/containers.hh b/upstream/src/common/containers.hh
index 5f2abee..29ea4e0 100644
--- a/upstream/src/common/containers.hh
+++ b/upstream/src/common/containers.hh
@@ -30,28 +30,28 @@ template <typename T>
 bool
 member( const T& x, const list<T>& v)
 {
-	return any( v.begin(), v.end(), x);
+        return any( v.begin(), v.end(), x);
 }
 
 template <typename T>
 bool
 member( const T& x, const forward_list<T>& v)
 {
-	return any( v.begin(), v.end(), x);
+        return any( v.begin(), v.end(), x);
 }
 
 template <typename T>
 bool
 member( const T& x, const vector<T>& v)
 {
-	return any( v.begin(), v.end(), x);
+        return any( v.begin(), v.end(), x);
 }
 
 template <typename K, typename V>
 bool
 member( const K& x, const map<K, V>& m)
 {
-	return m.find(x) != m.end();
+        return m.find(x) != m.end();
 }
 
 } // namespace alg
diff --git a/upstream/src/common/fs.hh b/upstream/src/common/fs.hh
index ef170fc..85cfea8 100644
--- a/upstream/src/common/fs.hh
+++ b/upstream/src/common/fs.hh
@@ -34,16 +34,16 @@ make_fname_base( const string& fname_, const string& suffices, TMakeFnameOption)
 inline list<string>
 path_elements( const string& _filename)
 {
-	return move(agh::str::tokens( _filename, "/"));
+        return move(agh::str::tokens( _filename, "/"));
 }
 
 inline string
 dirname( const string& _filename)
 {
-	string pre = (_filename[0] == '/') ? "/" : "";
-	auto ee = agh::str::tokens( _filename, "/");
-	ee.pop_back();
-	return move(pre + agh::str::join( ee, "/"));
+        string pre = (_filename[0] == '/') ? "/" : "";
+        auto ee = agh::str::tokens( _filename, "/");
+        ee.pop_back();
+        return move(pre + agh::str::join( ee, "/"));
 }
 
 
@@ -53,22 +53,22 @@ dirname( const string& _filename)
 inline bool
 exists_and_is_writable( const string& dir)
 {
-	struct stat attr;
-	return stat( dir.c_str(), &attr) == 0 &&
-		S_ISDIR (attr.st_mode) &&
-		(attr.st_mode & S_IWUSR) &&
-		(attr.st_uid == getuid());
+        struct stat attr;
+        return stat( dir.c_str(), &attr) == 0 &&
+                S_ISDIR (attr.st_mode) &&
+                (attr.st_mode & S_IWUSR) &&
+                (attr.st_uid == getuid());
 }
 
 
 inline int
 mkdir_with_parents( const string& dir)
 {
-	return system(
-		agh::str::sasprintf(
-			"mkdir -p '%s'",
-			dir.c_str())
-		.c_str());
+        return system(
+                agh::str::sasprintf(
+                        "mkdir -p '%s'",
+                        dir.c_str())
+                .c_str());
 }
 
 
diff --git a/upstream/src/common/lang.hh b/upstream/src/common/lang.hh
index 04d7e5c..a3b6985 100644
--- a/upstream/src/common/lang.hh
+++ b/upstream/src/common/lang.hh
@@ -29,31 +29,31 @@ typedef unsigned long hash_t;
 
 // g++ bits
 
-#define	MAKE_UNIQUE_CHARP(p)				\
-	unique_ptr<void,void(*)(void*)> p##_pp(p,free);
+#define        MAKE_UNIQUE_CHARP(p)                                \
+        unique_ptr<void,void(*)(void*)> p##_pp(p,free);
 
 
-#define DELETE_DEFAULT_METHODS(T)		\
-	T () = delete;				\
-	T (const T&) = delete;			\
-	void operator=( const T&) = delete;
+#define DELETE_DEFAULT_METHODS(T)                \
+        T () = delete;                                \
+        T (const T&) = delete;                        \
+        void operator=( const T&) = delete;
 
 
 
 
 // gcc bits
 
-// # define __pure		__attribute__ ((pure))
-// # define __const		__attribute__ ((const))
-// # define __noreturn		__attribute__ ((noreturn))
-// # define __malloc		__attribute__ ((malloc))
-// # define __must_check	__attribute__ ((warn_unused_result))
-// # define __deprecated	__attribute__ ((deprecated))
-// # define __used		__attribute__ ((used))
-// # define __unused		__attribute__ ((unused))
-// # define __packed		__attribute__ ((packed))
-#define likely(x)	__builtin_expect (!!(x), 1)
-#define unlikely(x)	__builtin_expect (!!(x), 0)
+// # define __pure                __attribute__ ((pure))
+// # define __const                __attribute__ ((const))
+// # define __noreturn                __attribute__ ((noreturn))
+// # define __malloc                __attribute__ ((malloc))
+// # define __must_check        __attribute__ ((warn_unused_result))
+// # define __deprecated        __attribute__ ((deprecated))
+// # define __used                __attribute__ ((used))
+// # define __unused                __attribute__ ((unused))
+// # define __packed                __attribute__ ((packed))
+#define likely(x)        __builtin_expect (!!(x), 1)
+#define unlikely(x)        __builtin_expect (!!(x), 0)
 
 
 #define FABUF printf( __FILE__ ":%d (%s): %s\n", __LINE__, __FUNCTION__, __buf__);
diff --git a/upstream/src/common/libcommon.cc b/upstream/src/common/libcommon.cc
index 2fcb16e..43a3649 100644
--- a/upstream/src/common/libcommon.cc
+++ b/upstream/src/common/libcommon.cc
@@ -38,24 +38,24 @@ string
 agh::str::
 trim( const string& r0)
 {
-	string r (r0);
-	auto rsize = r.size();
-	if ( rsize == 0 )
-		return r;
-	while ( rsize > 0 && r[rsize-1] == ' ' )
-		--rsize;
-	r.resize( rsize);
-	r.erase( 0, r.find_first_not_of(" \t"));
-	return move(r);
+        string r (r0);
+        auto rsize = r.size();
+        if ( rsize == 0 )
+                return r;
+        while ( rsize > 0 && r[rsize-1] == ' ' )
+                --rsize;
+        r.resize( rsize);
+        r.erase( 0, r.find_first_not_of(" \t"));
+        return move(r);
 }
 
 string
 agh::str::
 pad( const string& r0, size_t to)
 {
-	string r (to, ' ');
-	memcpy( (void*)r.data(), (const void*)r0.data(), min( to, r0.size()));
-	return move(r);
+        string r (to, ' ');
+        memcpy( (void*)r.data(), (const void*)r0.data(), min( to, r0.size()));
+        return move(r);
 }
 
 
@@ -65,16 +65,16 @@ string
 agh::str::
 sasprintf( const char* fmt, ...)
 {
-	char *_;
-	va_list ap;
-	va_start (ap, fmt);
-	if (vasprintf( &_, fmt, ap) <= 0)
-		abort();
-	va_end (ap);
-
-	string ret {_};
-	free( (void*)_);
-	return move(ret);
+        char *_;
+        va_list ap;
+        va_start (ap, fmt);
+        if (vasprintf( &_, fmt, ap) <= 0)
+                abort();
+        va_end (ap);
+
+        string ret {_};
+        free( (void*)_);
+        return move(ret);
 }
 
 
@@ -83,30 +83,30 @@ list<string>
 agh::str::
 tokens_trimmed( const string& s_, const char* sep)
 {
-	string s {s_};
-	list<string> acc;
-	char   *pp,
-	       *p = strtok_r( &s[0], sep, &pp);
-	while ( p ) {
-		acc.emplace_back( trim(p));
-		p = strtok_r( NULL, sep, &pp);
-	}
-	return move(acc);
+        string s {s_};
+        list<string> acc;
+        char   *pp,
+               *p = strtok_r( &s[0], sep, &pp);
+        while ( p ) {
+                acc.emplace_back( trim(p));
+                p = strtok_r( NULL, sep, &pp);
+        }
+        return move(acc);
 }
 
 list<string>
 agh::str::
 tokens( const string& s_, const char* sep)
 {
-	string s {s_};
-	list<string> acc;
-	char   *pp,
-	       *p = strtok_r( &s[0], sep, &pp);
-	while ( p ) {
-		acc.emplace_back( p);
-		p = strtok_r( NULL, sep, &pp);
-	}
-	return move(acc);
+        string s {s_};
+        list<string> acc;
+        char   *pp,
+               *p = strtok_r( &s[0], sep, &pp);
+        while ( p ) {
+                acc.emplace_back( p);
+                p = strtok_r( NULL, sep, &pp);
+        }
+        return move(acc);
 }
 
 
@@ -116,10 +116,10 @@ void
 agh::str::
 decompose_double( double value, double *mantissa, int *exponent)
 {
-	char buf[32];
-	snprintf( buf, 31, "%e", value);
-	*strchr( buf, 'e') = '|';
-	sscanf( buf, "%lf|%d", mantissa, exponent);
+        char buf[32];
+        snprintf( buf, 31, "%e", value);
+        *strchr( buf, 'e') = '|';
+        sscanf( buf, "%lf|%d", mantissa, exponent);
 }
 
 
@@ -129,50 +129,50 @@ string&
 agh::str::
 homedir2tilda( string& inplace)
 {
-	const char *home = getenv("HOME");
-	if ( home )
-		if ( inplace.compare( 0, strlen(home), home) == 0 )
-			inplace.replace( 0, strlen(home), "~");
-	return inplace;
+        const char *home = getenv("HOME");
+        if ( home )
+                if ( inplace.compare( 0, strlen(home), home) == 0 )
+                        inplace.replace( 0, strlen(home), "~");
+        return inplace;
 }
 
 string
 agh::str::
 homedir2tilda( const string& v)
 {
-	string inplace (v);
-	const char *home = getenv("HOME");
-	if ( home )
-		if ( inplace.compare( 0, strlen(home), home) == 0 )
-			inplace.replace( 0, strlen(home), "~");
-	return inplace;
+        string inplace (v);
+        const char *home = getenv("HOME");
+        if ( home )
+                if ( inplace.compare( 0, strlen(home), home) == 0 )
+                        inplace.replace( 0, strlen(home), "~");
+        return inplace;
 }
 
 string&
 agh::str::
 tilda2homedir( string& inplace)
 {
-	const char *home = getenv("HOME");
-	if ( home ) {
-		size_t at;
-		while ( (at = inplace.find( '~')) < inplace.size() )
-			inplace.replace( at, 1, home);
-	}
-	return inplace;
+        const char *home = getenv("HOME");
+        if ( home ) {
+                size_t at;
+                while ( (at = inplace.find( '~')) < inplace.size() )
+                        inplace.replace( at, 1, home);
+        }
+        return inplace;
 }
 
 string
 agh::str::
 tilda2homedir( const string& v)
 {
-	string inplace (v);
-	const char *home = getenv("HOME");
-	if ( home ) {
-		size_t at;
-		while ( (at = inplace.find( '~')) < inplace.size() )
-			inplace.replace( at, 1, home);
-	}
-	return inplace;
+        string inplace (v);
+        const char *home = getenv("HOME");
+        if ( home ) {
+                size_t at;
+                while ( (at = inplace.find( '~')) < inplace.size() )
+                        inplace.replace( at, 1, home);
+        }
+        return inplace;
 }
 
 
@@ -181,49 +181,49 @@ string
 agh::str::
 dhms( double seconds, int dd)
 {
-	bool	positive = seconds >= 0.;
-	if ( not positive )
-		seconds = -seconds;
-
-	int	s = (int)seconds % 60,
-		m = (int)seconds/60 % 60,
-		h = (int)seconds/60/60 % (60*60),
-		d = (int)seconds/60/60/24 % (60*60*24);
-	double	f = seconds - floor(seconds);
-
-	using agh::str::sasprintf;
-	string	f_ = ( dd == 0 )
-		? ""
-		: sasprintf( ".%0*d", dd, (int)(f*pow(10, dd)));
-	return ( d > 0 )
-		? sasprintf( "%dd %dh %dm %d%ss", d, h, m, s, f_.c_str())
-		: ( h > 0 )
-		? sasprintf( "%dh %dm %d%ss", h, m, s, f_.c_str())
-		: ( m > 0 )
-		? sasprintf( "%dm %d%ss", m, s, f_.c_str())
-		: sasprintf( "%d%ss", s, f_.c_str());
+        bool        positive = seconds >= 0.;
+        if ( not positive )
+                seconds = -seconds;
+
+        int        s = (int)seconds % 60,
+                m = (int)seconds/60 % 60,
+                h = (int)seconds/60/60 % (60*60),
+                d = (int)seconds/60/60/24 % (60*60*24);
+        double        f = seconds - floor(seconds);
+
+        using agh::str::sasprintf;
+        string        f_ = ( dd == 0 )
+                ? ""
+                : sasprintf( ".%0*d", dd, (int)(f*pow(10, dd)));
+        return ( d > 0 )
+                ? sasprintf( "%dd %dh %dm %d%ss", d, h, m, s, f_.c_str())
+                : ( h > 0 )
+                ? sasprintf( "%dh %dm %d%ss", h, m, s, f_.c_str())
+                : ( m > 0 )
+                ? sasprintf( "%dm %d%ss", m, s, f_.c_str())
+                : sasprintf( "%d%ss", s, f_.c_str());
 }
 
 string
 agh::str::
 dhms_colon( double seconds, int dd)
 {
-	bool	positive = seconds >= 0.;
-	if ( not positive )
-		seconds = -seconds;
-
-	int	s = (int)seconds % 60,
-		m = (int)seconds/60 % 60,
-		h = (int)seconds/60/60 % (60*60),
-		d = (int)seconds/60/60/24 % (60*60*24);
-	double	f = seconds - floor(seconds);
-
-	using agh::str::sasprintf;
-	string	f_ = ( dd == 0 )
-		? ""
-		: sasprintf( ".%0*d", dd, (int)(f*pow(10, dd)));
-
-	return sasprintf( "%dd %02d:%02d:%02d%ss", d, h, m, s, f_.c_str());
+        bool        positive = seconds >= 0.;
+        if ( not positive )
+                seconds = -seconds;
+
+        int        s = (int)seconds % 60,
+                m = (int)seconds/60 % 60,
+                h = (int)seconds/60/60 % (60*60),
+                d = (int)seconds/60/60/24 % (60*60*24);
+        double        f = seconds - floor(seconds);
+
+        using agh::str::sasprintf;
+        string        f_ = ( dd == 0 )
+                ? ""
+                : sasprintf( ".%0*d", dd, (int)(f*pow(10, dd)));
+
+        return sasprintf( "%dd %02d:%02d:%02d%ss", d, h, m, s, f_.c_str());
 }
 
 
@@ -305,40 +305,40 @@ string
 agh::fs::
 make_fname_base( const string& fname_, const string& suffices, const TMakeFnameOption option)
 {
-	string	fname (fname_);
-	for ( const auto& X : agh::str::tokens( suffices, ",; ") )
-		if ( fname.size() > X.size() &&
-		     strcasecmp( &fname[fname.size()-X.size()], X.c_str()) == 0 ) {
-			fname.erase( fname.size()-X.size(), X.size());
-			break;
-		}
-
-	if ( option == TMakeFnameOption::hidden ) {
-		size_t slash_at = fname.rfind('/');
-		if ( slash_at < fname.size() )
-			fname.insert( slash_at+1, ".");
-	}
-	return move(fname);
+        string        fname (fname_);
+        for ( const auto& X : agh::str::tokens( suffices, ",; ") )
+                if ( fname.size() > X.size() &&
+                     strcasecmp( &fname[fname.size()-X.size()], X.c_str()) == 0 ) {
+                        fname.erase( fname.size()-X.size(), X.size());
+                        break;
+                }
+
+        if ( option == TMakeFnameOption::hidden ) {
+                size_t slash_at = fname.rfind('/');
+                if ( slash_at < fname.size() )
+                        fname.insert( slash_at+1, ".");
+        }
+        return move(fname);
 }
 
 
 
 // found to be of use elsewhere
-size_t	agh::fs::total_supported_sigfiles;
+size_t        agh::fs::total_supported_sigfiles;
 
 int
 agh::fs::
 supported_sigfile_counter( const char *fname, const struct stat*, int flag, struct FTW *ftw)
 {
-	if ( flag == FTW_F && ftw->level == 4 ) {
-		int fnlen = strlen(fname); // - ftw->base;
-		if ( fnlen < 5 )
-			return 0;
-		if ( strcasecmp( &fname[fnlen-4], ".edf") == 0 ||
-		     strcasecmp( &fname[fnlen-4], ".tsv") == 0 )
-			++total_supported_sigfiles;
-	}
-	return 0;
+        if ( flag == FTW_F && ftw->level == 4 ) {
+                int fnlen = strlen(fname); // - ftw->base;
+                if ( fnlen < 5 )
+                        return 0;
+                if ( strcasecmp( &fname[fnlen-4], ".edf") == 0 ||
+                     strcasecmp( &fname[fnlen-4], ".tsv") == 0 )
+                        ++total_supported_sigfiles;
+        }
+        return 0;
 }
 
 
@@ -350,19 +350,19 @@ double
 __attribute__ ((pure))
 agh::alg::
 sensible_scale_reduction_factor( double display_scale,
-				 double constraint_max, double constraint_min)
+                                 double constraint_max, double constraint_min)
 {
-	double f = 1.;
-	bool	last_was_two = false;
-	while ( display_scale * f > constraint_max ) {
-		f /= last_was_two ? 5. : 2.;
-		last_was_two = !last_was_two;
-	}
-	while ( display_scale * f < constraint_min ) {
-		f *= last_was_two ? 5. : 2.;
-		last_was_two = !last_was_two;
-	}
-	return f;
+        double f = 1.;
+        bool        last_was_two = false;
+        while ( display_scale * f > constraint_max ) {
+                f /= last_was_two ? 5. : 2.;
+                last_was_two = !last_was_two;
+        }
+        while ( display_scale * f < constraint_min ) {
+                f *= last_was_two ? 5. : 2.;
+                last_was_two = !last_was_two;
+        }
+        return f;
 }
 
 
diff --git a/upstream/src/common/string.hh b/upstream/src/common/string.hh
index a11f82f..475f186 100644
--- a/upstream/src/common/string.hh
+++ b/upstream/src/common/string.hh
@@ -27,7 +27,7 @@ namespace agh {
 namespace str {
 
 enum class TStrCmpCaseOption {
-	sensitive, insensitive
+        sensitive, insensitive
 };
 
 string sasprintf( const char* fmt, ...) __attribute__ ((format (printf, 1, 2)));
@@ -39,14 +39,14 @@ template <typename C>
 string
 join( const C& l, const char* sep)
 {
-	if ( l.empty() )
-		return "";
-	ostringstream recv;
-	auto I = l.begin();
-	for ( ; next(I) != l.end(); ++I )
-		recv << *I << sep;
-	recv << *I;
-	return recv.str();
+        if ( l.empty() )
+                return "";
+        ostringstream recv;
+        auto I = l.begin();
+        for ( ; next(I) != l.end(); ++I )
+                recv << *I << sep;
+        recv << *I;
+        return recv.str();
 }
 
 list<string> tokens( const string&, const char* sep);
@@ -55,8 +55,8 @@ inline
 list<string>
 tokens( const string& s_, char c)
 {
-	char sep[2] = {c, '\0'};
-	return move(tokens( s_, sep));
+        char sep[2] = {c, '\0'};
+        return move(tokens( s_, sep));
 }
 
 list<string> tokens_trimmed( const string& s_, const char* sep);
@@ -65,8 +65,8 @@ inline
 list<string>
 tokens_trimmed( const string& s_, char c)
 {
-	char sep[2] = {c, '\0'};
-	return move(tokens_trimmed( s_, sep));
+        char sep[2] = {c, '\0'};
+        return move(tokens_trimmed( s_, sep));
 }
 
 
@@ -74,11 +74,11 @@ tokens_trimmed( const string& s_, char c)
 inline
 bool
 has_suffix( const string& s, const string& suffix,
-	    TStrCmpCaseOption case_option = TStrCmpCaseOption::sensitive)
+            TStrCmpCaseOption case_option = TStrCmpCaseOption::sensitive)
 {
-	return	suffix.size() <= s.size() and
-		0 == (case_option == TStrCmpCaseOption::sensitive ? strcmp : strcasecmp)(
-			&s[s.size()-suffix.size()], &suffix[0]);
+        return        suffix.size() <= s.size() and
+                0 == (case_option == TStrCmpCaseOption::sensitive ? strcmp : strcasecmp)(
+                        &s[s.size()-suffix.size()], &suffix[0]);
 }
 
 void decompose_double( double value, double *mantissa, int *exponent);
diff --git a/upstream/src/common/subject_id.cc b/upstream/src/common/subject_id.cc
index ce4e22c..2e0b0f2 100644
--- a/upstream/src/common/subject_id.cc
+++ b/upstream/src/common/subject_id.cc
@@ -28,16 +28,16 @@ SSubjectId::TGender
 SSubjectId::
 char_to_gender( char x)
 {
-	switch ( x ) {
-	case 'M':
-	case 'm':
-		return TGender::male;
-	case 'F':
-	case 'f':
-		return TGender::female;
-	default:
-		return TGender::unknown;
-	}
+        switch ( x ) {
+        case 'M':
+        case 'm':
+                return TGender::male;
+        case 'F':
+        case 'f':
+                return TGender::female;
+        default:
+                return TGender::unknown;
+        }
 }
 
 
@@ -46,14 +46,14 @@ __attribute__ ((const))
 SSubjectId::
 gender_sign( TGender g)
 {
-	switch ( g ) {
-	case TGender::male:
-		return 'M';
-	case TGender::female:
-		return 'F';
-	default:
-		return 'X';
-	}
+        switch ( g ) {
+        case TGender::male:
+                return 'M';
+        case TGender::female:
+                return 'F';
+        default:
+                return 'X';
+        }
 }
 
 
@@ -63,52 +63,52 @@ namespace {
 int
 str_to_english_month( const string& s)
 {
-	if ( strcasecmp( s.c_str(), "jan") == 0 )
-		return 0;
-	if ( strcasecmp( s.c_str(), "feb") == 0 )
-		return 1;
-	if ( strcasecmp( s.c_str(), "mar") == 0 )
-		return 2;
-	if ( strcasecmp( s.c_str(), "apr") == 0 )
-		return 3;
-	if ( strcasecmp( s.c_str(), "may") == 0 )
-		return 4;
-	if ( strcasecmp( s.c_str(), "jun") == 0 )
-		return 5;
-	if ( strcasecmp( s.c_str(), "jul") == 0 )
-		return 6;
-	if ( strcasecmp( s.c_str(), "aug") == 0 )
-		return 7;
-	if ( strcasecmp( s.c_str(), "sep") == 0 )
-		return 8;
-	if ( strcasecmp( s.c_str(), "oct") == 0 )
-		return 9;
-	if ( strcasecmp( s.c_str(), "nov") == 0 )
-		return 10;
-	if ( strcasecmp( s.c_str(), "dec") == 0 )
-		return 11;
-	else
-		return -1;
+        if ( strcasecmp( s.c_str(), "jan") == 0 )
+                return 0;
+        if ( strcasecmp( s.c_str(), "feb") == 0 )
+                return 1;
+        if ( strcasecmp( s.c_str(), "mar") == 0 )
+                return 2;
+        if ( strcasecmp( s.c_str(), "apr") == 0 )
+                return 3;
+        if ( strcasecmp( s.c_str(), "may") == 0 )
+                return 4;
+        if ( strcasecmp( s.c_str(), "jun") == 0 )
+                return 5;
+        if ( strcasecmp( s.c_str(), "jul") == 0 )
+                return 6;
+        if ( strcasecmp( s.c_str(), "aug") == 0 )
+                return 7;
+        if ( strcasecmp( s.c_str(), "sep") == 0 )
+                return 8;
+        if ( strcasecmp( s.c_str(), "oct") == 0 )
+                return 9;
+        if ( strcasecmp( s.c_str(), "nov") == 0 )
+                return 10;
+        if ( strcasecmp( s.c_str(), "dec") == 0 )
+                return 11;
+        else
+                return -1;
 }
 
 const char*
 english_month_to_str( int m)
 {
-	switch ( m ) {
-	case  0: return "jan";
-	case  1: return "feb";
-	case  2: return "mar";
-	case  3: return "apr";
-	case  4: return "may";
-	case  5: return "jun";
-	case  6: return "jul";
-	case  7: return "aug";
-	case  8: return "sep";
-	case  9: return "oct";
-	case 10: return "nov";
-	case 11: return "dec";
-	default: return "---";
-	}
+        switch ( m ) {
+        case  0: return "jan";
+        case  1: return "feb";
+        case  2: return "mar";
+        case  3: return "apr";
+        case  4: return "may";
+        case  5: return "jun";
+        case  6: return "jul";
+        case  7: return "aug";
+        case  8: return "sep";
+        case  9: return "oct";
+        case 10: return "nov";
+        case 11: return "dec";
+        default: return "---";
+        }
 }
 }
 
@@ -117,38 +117,38 @@ time_t
 SSubjectId::
 str_to_dob( const string& s)
 {
-	struct tm t;
-	memset( &t, '\0', sizeof (t));
-
-	// strptime( s, "%d-", &t); // will suck in non-US locales, so
-	auto ff = agh::str::tokens(s, "-");
-	if ( ff.size() != 3 )
-		return (time_t)0;
-	auto f = ff.begin();
-	try {
-		t.tm_mday = stoi( *f++);
-		t.tm_mon  = str_to_english_month(*f++);
-		t.tm_year = stoi(*f);
-		if ( t.tm_year > 100 )
-			t.tm_year -= 1900;
-		t.tm_isdst = -1;
-		return mktime( &t);
-	} catch (...) {
-		return (time_t)0;
-	}
+        struct tm t;
+        memset( &t, '\0', sizeof (t));
+
+        // strptime( s, "%d-", &t); // will suck in non-US locales, so
+        auto ff = agh::str::tokens(s, "-");
+        if ( ff.size() != 3 )
+                return (time_t)0;
+        auto f = ff.begin();
+        try {
+                t.tm_mday = stoi( *f++);
+                t.tm_mon  = str_to_english_month(*f++);
+                t.tm_year = stoi(*f);
+                if ( t.tm_year > 100 )
+                        t.tm_year -= 1900;
+                t.tm_isdst = -1;
+                return mktime( &t);
+        } catch (...) {
+                return (time_t)0;
+        }
 }
 
 string
 SSubjectId::
 dob_to_str( const time_t t_)
 {
-	struct tm t;
-	gmtime_r( &t_, &t);
-	return agh::str::sasprintf(
-		"%02d-%s-%02d",
-		t.tm_mday,
-		english_month_to_str(t.tm_mon),
-		t.tm_year % 100);
+        struct tm t;
+        gmtime_r( &t_, &t);
+        return agh::str::sasprintf(
+                "%02d-%s-%02d",
+                t.tm_mday,
+                english_month_to_str(t.tm_mon),
+                t.tm_year % 100);
 }
 
 
@@ -157,28 +157,28 @@ int
 SSubjectId::
 update_from( const SSubjectId& j)
 {
-	int mismatched_fields = 0;
-	if ( id.empty() or id == "X" )
-		id = j.id;
-	else if ( id != j.id )
-		++mismatched_fields;
-
-	if ( name.empty() or name == "X" )
-		name = j.name;
-	else if ( name != j.name )
-		++mismatched_fields;
-
-	if ( gender == TGender::unknown )
-		gender = j.gender;
-	else if ( gender != j.gender )
-		++mismatched_fields;
-
-	if ( dob == (time_t)0 )
-		dob = j.dob;
-	else if ( dob != j.dob )
-		++mismatched_fields;
-
-	return mismatched_fields;
+        int mismatched_fields = 0;
+        if ( id.empty() or id == "X" )
+                id = j.id;
+        else if ( id != j.id )
+                ++mismatched_fields;
+
+        if ( name.empty() or name == "X" )
+                name = j.name;
+        else if ( name != j.name )
+                ++mismatched_fields;
+
+        if ( gender == TGender::unknown )
+                gender = j.gender;
+        else if ( gender != j.gender )
+                ++mismatched_fields;
+
+        if ( dob == (time_t)0 )
+                dob = j.dob;
+        else if ( dob != j.dob )
+                ++mismatched_fields;
+
+        return mismatched_fields;
 }
 
 
diff --git a/upstream/src/common/subject_id.hh b/upstream/src/common/subject_id.hh
index 6a5e33c..a1b7894 100644
--- a/upstream/src/common/subject_id.hh
+++ b/upstream/src/common/subject_id.hh
@@ -28,75 +28,75 @@ namespace agh {
 
 // follow http://www.edfplus.info/specs/edfplus.html#datarecords, section 2.1.3.3
 struct SSubjectId {
-	string	id,
-		name;
-	time_t	dob;
-	enum class TGender : char {
-		unknown = 'X', male = 'M', female = 'F'
-	};
-	TGender	gender;
-
-	SSubjectId (const string& id_ = "", const string& name_ = "",
-		    time_t dob_ = (time_t)0,
-		    TGender gender_ = TGender::unknown)
-	      : id (id_),
-		name (name_),
-		dob (dob_),
-		gender (gender_)
-		{}
-
-	SSubjectId (const SSubjectId& rv)
- 		{
-			id = rv.id;
-			name = rv.name;
-			dob = rv.dob;
-			gender = rv.gender;
-		}
-
-	SSubjectId (SSubjectId&& rv)
- 		{
-			id.swap( rv.id);
-			name.swap( rv.name);
-			dob = rv.dob;
-			gender = rv.gender;
-		}
-
-	void operator=( const SSubjectId& rv)
- 		{
-			id = rv.id;
-			name = rv.name;
-			dob = rv.dob;
-			gender = rv.gender;
-		}
-
-	char gender_sign() const
-		{ return gender_sign(gender); }
-	string dob_to_str() const
-		{ return dob_to_str( dob); }
-
-	bool valid() const
-		{
-			return not id.empty() and not name.empty() and
-				gender != TGender::unknown and
-				dob != 0;
-		}
-	int update_from( const SSubjectId&);
-
-	string make_recording_id_edf_style() const
-		{
-			return agh::str::sasprintf(
-				"%s %c %s %s",
-				id.c_str(), gender_sign(), dob_to_str().c_str(),
-				name.c_str());
-		}
-
-	// flag bits as in CEDFFile::TStatus
-	int parse_recording_id_edf_style( const string&);
-
-	static char gender_sign( TGender);
-	static TGender char_to_gender( char);
-	static time_t str_to_dob( const string&);
-	static string dob_to_str( time_t);
+        string        id,
+                name;
+        time_t        dob;
+        enum class TGender : char {
+                unknown = 'X', male = 'M', female = 'F'
+        };
+        TGender        gender;
+
+        SSubjectId (const string& id_ = "", const string& name_ = "",
+                    time_t dob_ = (time_t)0,
+                    TGender gender_ = TGender::unknown)
+              : id (id_),
+                name (name_),
+                dob (dob_),
+                gender (gender_)
+                {}
+
+        SSubjectId (const SSubjectId& rv)
+                 {
+                        id = rv.id;
+                        name = rv.name;
+                        dob = rv.dob;
+                        gender = rv.gender;
+                }
+
+        SSubjectId (SSubjectId&& rv)
+                 {
+                        id.swap( rv.id);
+                        name.swap( rv.name);
+                        dob = rv.dob;
+                        gender = rv.gender;
+                }
+
+        void operator=( const SSubjectId& rv)
+                 {
+                        id = rv.id;
+                        name = rv.name;
+                        dob = rv.dob;
+                        gender = rv.gender;
+                }
+
+        char gender_sign() const
+                { return gender_sign(gender); }
+        string dob_to_str() const
+                { return dob_to_str( dob); }
+
+        bool valid() const
+                {
+                        return not id.empty() and not name.empty() and
+                                gender != TGender::unknown and
+                                dob != 0;
+                }
+        int update_from( const SSubjectId&);
+
+        string make_recording_id_edf_style() const
+                {
+                        return agh::str::sasprintf(
+                                "%s %c %s %s",
+                                id.c_str(), gender_sign(), dob_to_str().c_str(),
+                                name.c_str());
+                }
+
+        // flag bits as in CEDFFile::TStatus
+        int parse_recording_id_edf_style( const string&);
+
+        static char gender_sign( TGender);
+        static TGender char_to_gender( char);
+        static time_t str_to_dob( const string&);
+        static string dob_to_str( time_t);
 };
 
 } // namespace agh
diff --git a/upstream/src/libmetrics/bands.hh b/upstream/src/libmetrics/bands.hh
index dcb3639..cb80d0c 100644
--- a/upstream/src/libmetrics/bands.hh
+++ b/upstream/src/libmetrics/bands.hh
@@ -23,12 +23,12 @@ using namespace std;
 namespace metrics {
 
 enum TBand {
-	delta,
-	theta,
-	alpha,
-	beta,
-	gamma,
-	TBand_total,
+        delta,
+        theta,
+        alpha,
+        beta,
+        gamma,
+        TBand_total,
 };
 
 } // namespace metrics
diff --git a/upstream/src/libmetrics/mc-artifacts.cc b/upstream/src/libmetrics/mc-artifacts.cc
index 68e8bce..e94e59d 100644
--- a/upstream/src/libmetrics/mc-artifacts.cc
+++ b/upstream/src/libmetrics/mc-artifacts.cc
@@ -32,26 +32,26 @@ namespace mc {
 template <>
 double
 estimate_E( const valarray<double>& sssu_diff,
-	    size_t sssu_hist_size,
-	    double dmin, double dmax)
+            size_t sssu_hist_size,
+            double dmin, double dmax)
 {
-	gsl_histogram *hist = gsl_histogram_alloc( sssu_hist_size);
-	gsl_histogram_set_ranges_uniform( hist, dmin, dmax);
+        gsl_histogram *hist = gsl_histogram_alloc( sssu_hist_size);
+        gsl_histogram_set_ranges_uniform( hist, dmin, dmax);
 
-	for ( size_t i = 0; i < sssu_diff.size(); ++i )
-		gsl_histogram_increment( hist, sssu_diff[i]);
+        for ( size_t i = 0; i < sssu_diff.size(); ++i )
+                gsl_histogram_increment( hist, sssu_diff[i]);
 
-	return dmin + (gsl_histogram_max_bin( hist) + .5)
-		* ((dmax-dmin) / sssu_hist_size);
+        return dmin + (gsl_histogram_max_bin( hist) + .5)
+                * ((dmax-dmin) / sssu_hist_size);
 }
 
 template <>
 double
 estimate_E( const valarray<float>& S,
-	    size_t bins,
-	    double dmin, double dmax)
+            size_t bins,
+            double dmin, double dmax)
 {
-	return estimate_E( agh::alg::to_vad(S), bins, dmin, dmax);
+        return estimate_E( agh::alg::to_vad(S), bins, dmin, dmax);
 }
 
 } // namespace mc
diff --git a/upstream/src/libmetrics/mc-artifacts.hh b/upstream/src/libmetrics/mc-artifacts.hh
index 95ad82b..4d59445 100644
--- a/upstream/src/libmetrics/mc-artifacts.hh
+++ b/upstream/src/libmetrics/mc-artifacts.hh
@@ -27,45 +27,45 @@ namespace metrics {
 namespace mc {
 
 struct SArtifactDetectionPP {
-	double	scope,
-		upper_thr, lower_thr,
-		f0, fc, bandwidth,
-		mc_gain, iir_backpolate;
-	double	E, dmin, dmax;
-	size_t	sssu_hist_size,
-		smooth_side;
-	bool	estimate_E,
-		use_range;
-	SArtifactDetectionPP ()
-		: scope (4.),
-		  upper_thr (9.), lower_thr (-9.),
-		  f0 (1.), fc (1.8), bandwidth (1.5),
-		  mc_gain (10.), iir_backpolate (.5),
-		  E (4.), dmin (-10), dmax (20),
-		  sssu_hist_size (100), smooth_side (0),
-		  estimate_E (true), use_range (false)
-		{}
+        double        scope,
+                upper_thr, lower_thr,
+                f0, fc, bandwidth,
+                mc_gain, iir_backpolate;
+        double        E, dmin, dmax;
+        size_t        sssu_hist_size,
+                smooth_side;
+        bool        estimate_E,
+                use_range;
+        SArtifactDetectionPP ()
+                : scope (4.),
+                  upper_thr (9.), lower_thr (-9.),
+                  f0 (1.), fc (1.8), bandwidth (1.5),
+                  mc_gain (10.), iir_backpolate (.5),
+                  E (4.), dmin (-10), dmax (20),
+                  sssu_hist_size (100), smooth_side (0),
+                  estimate_E (true), use_range (false)
+                {}
 };
 
 template <typename T>
 vector<size_t> // don't estimate, use pi*B*x^2 (E) as provided
 detect_artifacts( const valarray<T>& signal, size_t sr,
-		  const SArtifactDetectionPP& P);
+                  const SArtifactDetectionPP& P);
 
 
 template <typename T>
 double
 estimate_E( const valarray<T>&,
-	    size_t bins,
-	    double dmin, double dmax);
+            size_t bins,
+            double dmin, double dmax);
 
 template <typename T>
 inline double
 estimate_E( const valarray<T>& sssu_diff,
-	    size_t sssu_hist_size)
+            size_t sssu_hist_size)
 {
-	return estimate_E( sssu_diff, sssu_hist_size,
-			   sssu_diff.min(), sssu_diff.max());
+        return estimate_E( sssu_diff, sssu_hist_size,
+                           sssu_diff.min(), sssu_diff.max());
 }
 
 
diff --git a/upstream/src/libmetrics/mc.cc b/upstream/src/libmetrics/mc.cc
index 258e9fc..374404a 100644
--- a/upstream/src/libmetrics/mc.cc
+++ b/upstream/src/libmetrics/mc.cc
@@ -24,14 +24,14 @@ using namespace std;
 
 metrics::mc::CProfile::
 CProfile (const sigfile::CTypedSource& F, const int sig_no,
-	  const SPPack &params)
+          const SPPack &params)
       : metrics::CProfile (F, sig_no,
-			   params.pagesize, params.step,
-			   params.compute_n_bins(F().samplerate(sig_no))),
-	Pp (params)
-	// *_filter's initialized at compute time
+                           params.pagesize, params.step,
+                           params.compute_n_bins(F().samplerate(sig_no))),
+        Pp (params)
+        // *_filter's initialized at compute time
 {
-	Pp.check(); // throw if not ok
+        Pp.check(); // throw if not ok
 }
 
 
@@ -41,58 +41,58 @@ string
 metrics::mc::CProfile::
 fname_base() const
 {
-	return agh::str::sasprintf(
-		  "%s.%s-%lu"
-		  ":%g+%g-%g_%g" "_%g" "_%g_%g",
-		  _using_F().filename(), _using_F().channel_by_id(_using_sig_no).name(),
-		  _using_F().dirty_signature( _using_sig_no),
-		  Pp.pagesize, Pp.step,
-		  Pp.scope, Pp.iir_backpolate,
-		  Pp.mc_gain,
-		  Pp.f0fc, Pp.bandwidth);
+        return agh::str::sasprintf(
+                  "%s.%s-%lu"
+                  ":%g+%g-%g_%g" "_%g" "_%g_%g",
+                  _using_F().filename(), _using_F().channel_by_id(_using_sig_no).name(),
+                  _using_F().dirty_signature( _using_sig_no),
+                  Pp.pagesize, Pp.step,
+                  Pp.scope, Pp.iir_backpolate,
+                  Pp.mc_gain,
+                  Pp.f0fc, Pp.bandwidth);
 }
 
 string
 metrics::mc::CProfile::
 mirror_fname() const
 {
-	return agh::str::sasprintf(
-		  "%s-%s-%lu"
-		  ":%g+%g-%g_%g" "_%g" "_%g_%g" "_%g_%g@%zu"
-		  ".mc",
-		  agh::fs::make_fname_base (_using_F().filename(), "", agh::fs::TMakeFnameOption::hidden).c_str(),
-		  _using_F().channel_by_id(_using_sig_no).name(),
-		  _using_F().dirty_signature( _using_sig_no),
-		  Pp.pagesize, Pp.step,
-		  Pp.scope, Pp.iir_backpolate,
-		  Pp.mc_gain,
-		  Pp.f0fc, Pp.bandwidth,
-		  Pp.freq_from, Pp.freq_inc,
-		  sizeof(TFloat));
+        return agh::str::sasprintf(
+                  "%s-%s-%lu"
+                  ":%g+%g-%g_%g" "_%g" "_%g_%g" "_%g_%g@%zu"
+                  ".mc",
+                  agh::fs::make_fname_base (_using_F().filename(), "", agh::fs::TMakeFnameOption::hidden).c_str(),
+                  _using_F().channel_by_id(_using_sig_no).name(),
+                  _using_F().dirty_signature( _using_sig_no),
+                  Pp.pagesize, Pp.step,
+                  Pp.scope, Pp.iir_backpolate,
+                  Pp.mc_gain,
+                  Pp.f0fc, Pp.bandwidth,
+                  Pp.freq_from, Pp.freq_inc,
+                  sizeof(TFloat));
 }
 
 int
 metrics::mc::CProfile::
 go_compute()
 {
-	_data.resize( steps() * _bins);
-	auto S = _using_F().get_signal_filtered( _using_sig_no);
-	for ( size_t b = 0; b < bins(); ++b ) {
-		auto su_ss = metrics::mc::do_sssu_reduction(
-			S, samplerate(),
-			Pp.scope, Pp.step,
-			Pp.mc_gain, Pp.iir_backpolate,
-			Pp.freq_from + b * Pp.freq_inc,
-			Pp.freq_from + b * Pp.freq_inc + Pp.f0fc,
-			Pp.bandwidth);
-		auto suss = su_ss.first - su_ss.second;  // make it positive
-
-		for ( size_t p = 0; p < steps(); ++p )
-			nmth_bin(p, b) =
-				agh::alg::value_within( suss[p], (TFloat)0., (TFloat)INFINITY);
-	}
-
-	return 0;
+        _data.resize( steps() * _bins);
+        auto S = _using_F().get_signal_filtered( _using_sig_no);
+        for ( size_t b = 0; b < bins(); ++b ) {
+                auto su_ss = metrics::mc::do_sssu_reduction(
+                        S, samplerate(),
+                        Pp.scope, Pp.step,
+                        Pp.mc_gain, Pp.iir_backpolate,
+                        Pp.freq_from + b * Pp.freq_inc,
+                        Pp.freq_from + b * Pp.freq_inc + Pp.f0fc,
+                        Pp.bandwidth);
+                auto suss = su_ss.first - su_ss.second;  // make it positive
+
+                for ( size_t p = 0; p < steps(); ++p )
+                        nmth_bin(p, b) =
+                                agh::alg::value_within( suss[p], (TFloat)0., (TFloat)INFINITY);
+        }
+
+        return 0;
 }
 
 
@@ -109,62 +109,62 @@ int
 metrics::mc::CProfile::
 export_tsv( const string& fname) const
 {
-	FILE *f = fopen( fname.c_str(), "w");
-	if ( !f )
-		return -1;
-
-	size_t bin, p;
-	float bum = 0.;
-
-	auto sttm = _using_F().start_time();
-	char *asctime_ = asctime( localtime( &sttm));
-	fprintf( f, "## Subject: %s;  Session: %s, Episode: %s recorded %.*s;  Channel: %s\n"
-		 "## Total EEG Microcontinuity course (%zu %g-sec pages, step %g sec) from %g up to %g Hz in bins of %g Hz\n"
-		 "#Page\t",
-		 _using_F().subject().name.c_str(), _using_F().session(), _using_F().episode(),
-		 (int)strlen(asctime_)-1, asctime_,
-		 _using_F().channel_by_id(_using_sig_no).name(),
-		 steps(), Pp.pagesize, Pp.step, Pp.freq_from, Pp.freq_from + Pp.bandwidth * bins(), Pp.bandwidth);
-
-	for ( bin = 0; bin < _bins; ++bin, bum += Pp.bandwidth )
-		fprintf( f, "%g%c", bum, bin+1 == _bins ? '\n' : '\t');
-
-	for ( p = 0; p < steps(); ++p ) {
-		fprintf( f, "%zu", p);
-		for ( bin = 0; bin < _bins; ++bin )
-			fprintf( f, "\t%g", nmth_bin( p, bin));
-		fprintf( f, "\n");
-	}
-
-	fclose( f);
-	return 0;
+        FILE *f = fopen( fname.c_str(), "w");
+        if ( !f )
+                return -1;
+
+        size_t bin, p;
+        float bum = 0.;
+
+        auto sttm = _using_F().start_time();
+        char *asctime_ = asctime( localtime( &sttm));
+        fprintf( f, "## Subject: %s;  Session: %s, Episode: %s recorded %.*s;  Channel: %s\n"
+                 "## Total EEG Microcontinuity course (%zu %g-sec pages, step %g sec) from %g up to %g Hz in bins of %g Hz\n"
+                 "#Page\t",
+                 _using_F().subject().name.c_str(), _using_F().session(), _using_F().episode(),
+                 (int)strlen(asctime_)-1, asctime_,
+                 _using_F().channel_by_id(_using_sig_no).name(),
+                 steps(), Pp.pagesize, Pp.step, Pp.freq_from, Pp.freq_from + Pp.bandwidth * bins(), Pp.bandwidth);
+
+        for ( bin = 0; bin < _bins; ++bin, bum += Pp.bandwidth )
+                fprintf( f, "%g%c", bum, bin+1 == _bins ? '\n' : '\t');
+
+        for ( p = 0; p < steps(); ++p ) {
+                fprintf( f, "%zu", p);
+                for ( bin = 0; bin < _bins; ++bin )
+                        fprintf( f, "\t%g", nmth_bin( p, bin));
+                fprintf( f, "\n");
+        }
+
+        fclose( f);
+        return 0;
 }
 
 
 int
 metrics::mc::CProfile::
 export_tsv( size_t bin,
-	    const string& fname) const
+            const string& fname) const
 {
-	FILE *f = fopen( fname.c_str(), "w");
-	if ( !f )
-		return -1;
-
-	auto sttm = _using_F().start_time();
-	char *asctime_ = asctime( localtime( &sttm));
-	fprintf( f, "## Microcontinuity profile of\n"
-		 "## Subject: %s;  Session: %s, Episode: %s recorded %.*s;  Channel: %s\n"
-		 "## Course (%zu %g-sec pages, step %g sec) in range %g-%g Hz\n",
-		 _using_F().subject().name.c_str(), _using_F().session(), _using_F().episode(),
-		 (int)strlen(asctime_)-1, asctime_,
-		 _using_F().channel_by_id(_using_sig_no).name(),
-		 steps(), Pp.pagesize, Pp.step, Pp.freq_from, Pp.freq_from + (bin+1) * Pp.bandwidth);
-
-	for ( size_t p = 0; p < steps(); ++p )
-		fprintf( f, "%zu\t%g\n", p, nmth_bin(p, bin));
-
-	fclose( f);
-	return 0;
+        FILE *f = fopen( fname.c_str(), "w");
+        if ( !f )
+                return -1;
+
+        auto sttm = _using_F().start_time();
+        char *asctime_ = asctime( localtime( &sttm));
+        fprintf( f, "## Microcontinuity profile of\n"
+                 "## Subject: %s;  Session: %s, Episode: %s recorded %.*s;  Channel: %s\n"
+                 "## Course (%zu %g-sec pages, step %g sec) in range %g-%g Hz\n",
+                 _using_F().subject().name.c_str(), _using_F().session(), _using_F().episode(),
+                 (int)strlen(asctime_)-1, asctime_,
+                 _using_F().channel_by_id(_using_sig_no).name(),
+                 steps(), Pp.pagesize, Pp.step, Pp.freq_from, Pp.freq_from + (bin+1) * Pp.bandwidth);
+
+        for ( size_t p = 0; p < steps(); ++p )
+                fprintf( f, "%zu\t%g\n", p, nmth_bin(p, bin));
+
+        fclose( f);
+        return 0;
 }
 
 
@@ -173,8 +173,8 @@ template
 pair<valarray<TFloat>, valarray<TFloat>>
 metrics::mc::
 do_sssu_reduction( const valarray<TFloat>&,
-		   size_t, double, double, double, double,
-		   double, double, double);
+                   size_t, double, double, double, double,
+                   double, double, double);
 
 const size_t sssu_hist_size = 100;
 
diff --git a/upstream/src/libmetrics/mc.hh b/upstream/src/libmetrics/mc.hh
index c866152..ad50683 100644
--- a/upstream/src/libmetrics/mc.hh
+++ b/upstream/src/libmetrics/mc.hh
@@ -29,82 +29,82 @@ namespace mc {
 
 struct SPPack
   : public metrics::SPPack {
-	double	scope,
-		f0fc,
-	        //f0, // = 1.,
-		//fc, // = 1.8;
-		bandwidth,      // = 1.5;
-		iir_backpolate, // = 0.5;	// 0.0 < Backpolate < 1.0 on s: standard 0.5
-		mc_gain;        // = 10.0;	// Gain (DigiRange/PhysiRange) of MicroContinuity
-	size_t	smooth_side;
-	double	freq_from,
-		freq_inc;
-	size_t	n_bins;
-
-	SPPack (const SPPack&) = default;
-	SPPack ()
-		{
-			reset();
-		}
-
-	bool same_as( const SPPack& rv) const
-		{
-			return	metrics::SPPack::same_as(rv) &&
-				scope == rv.scope &&
-				iir_backpolate == rv.iir_backpolate &&
-				mc_gain == rv.mc_gain &&
-				f0fc == rv.f0fc &&
-				bandwidth == rv.bandwidth &&
-				smooth_side == rv.smooth_side &&
-				freq_from == rv.freq_from &&
-				freq_inc == rv.freq_inc &&
-				n_bins == rv.n_bins;
-		}
-	void make_same( const SPPack& rv)
-		{
-			metrics::SPPack::make_same(rv);
-			scope = rv.scope;
-			iir_backpolate = rv.iir_backpolate;
-			mc_gain = rv.mc_gain;
-			f0fc = rv.f0fc;
-			bandwidth = rv.bandwidth;
-			smooth_side = rv.smooth_side;
-			freq_from = rv.freq_from;
-			freq_inc = rv.freq_inc;
-			n_bins = rv.n_bins;
-		}
-
-	void check() const // throws
-		{
+        double        scope,
+                f0fc,
+                //f0, // = 1.,
+                //fc, // = 1.8;
+                bandwidth,      // = 1.5;
+                iir_backpolate, // = 0.5;        // 0.0 < Backpolate < 1.0 on s: standard 0.5
+                mc_gain;        // = 10.0;        // Gain (DigiRange/PhysiRange) of MicroContinuity
+        size_t        smooth_side;
+        double        freq_from,
+                freq_inc;
+        size_t        n_bins;
+
+        SPPack (const SPPack&) = default;
+        SPPack ()
+                {
+                        reset();
+                }
+
+        bool same_as( const SPPack& rv) const
+                {
+                        return        metrics::SPPack::same_as(rv) &&
+                                scope == rv.scope &&
+                                iir_backpolate == rv.iir_backpolate &&
+                                mc_gain == rv.mc_gain &&
+                                f0fc == rv.f0fc &&
+                                bandwidth == rv.bandwidth &&
+                                smooth_side == rv.smooth_side &&
+                                freq_from == rv.freq_from &&
+                                freq_inc == rv.freq_inc &&
+                                n_bins == rv.n_bins;
+                }
+        void make_same( const SPPack& rv)
+                {
+                        metrics::SPPack::make_same(rv);
+                        scope = rv.scope;
+                        iir_backpolate = rv.iir_backpolate;
+                        mc_gain = rv.mc_gain;
+                        f0fc = rv.f0fc;
+                        bandwidth = rv.bandwidth;
+                        smooth_side = rv.smooth_side;
+                        freq_from = rv.freq_from;
+                        freq_inc = rv.freq_inc;
+                        n_bins = rv.n_bins;
+                }
+
+        void check() const // throws
+                {
 #ifdef _OPENMP
 #pragma omp single
 #endif
-			{
-				if ( mc_gain < 1.0 )
-					throw invalid_argument ("mc_gain must be >= 1.0");
-				// if ( (int)(pagesize/scope) != (double)pagesize / (double)scope )
-				// 	throw invalid_argument ("Page size not a multiple of MC scope");
-			}
-		}
-
-	void reset()
-		{
-			scope			=     30 / 6.;  // 5 sec is close to 4 sec ('recommended')
-			f0fc			=      .8;
-			bandwidth		=     1.5;
-			iir_backpolate		=     0.5;	// 0.0 < Backpolate < 1.0 on s: standard 0.5
-			mc_gain			=    10.0;	// Gain (DigiRange/PhysiRange) of MicroContinuity
-			smooth_side		=     0;
-			freq_from		=     0.5;
-			freq_inc		=      .5;
-			n_bins			=     5;
-		}
-
-	size_t
-	compute_n_bins( size_t) const // to match psd::SPPack::compute_n_bins
-		{
-			return n_bins;
-		}
+                        {
+                                if ( mc_gain < 1.0 )
+                                        throw invalid_argument ("mc_gain must be >= 1.0");
+                                // if ( (int)(pagesize/scope) != (double)pagesize / (double)scope )
+                                //         throw invalid_argument ("Page size not a multiple of MC scope");
+                        }
+                }
+
+        void reset()
+                {
+                        scope                        =     30 / 6.;  // 5 sec is close to 4 sec ('recommended')
+                        f0fc                        =      .8;
+                        bandwidth                =     1.5;
+                        iir_backpolate                =     0.5;        // 0.0 < Backpolate < 1.0 on s: standard 0.5
+                        mc_gain                        =    10.0;        // Gain (DigiRange/PhysiRange) of MicroContinuity
+                        smooth_side                =     0;
+                        freq_from                =     0.5;
+                        freq_inc                =      .5;
+                        n_bins                        =     5;
+                }
+
+        size_t
+        compute_n_bins( size_t) const // to match psd::SPPack::compute_n_bins
+                {
+                        return n_bins;
+                }
 };
 
 
@@ -114,36 +114,36 @@ class CProfile
   : public metrics::CProfile {
 
     public:
-	CProfile (const sigfile::CTypedSource&, int sig_no,
-		  const SPPack&);
-
-	SPPack Pp;
-
-	const char* metric_name() const
-		{
-			return metrics::name( TType::mc);
-		}
-
-	valarray<TFloat> course( double binf) const
-		{
-			size_t	bin = agh::alg::value_within(
-				(int)((binf - Pp.freq_from) / Pp.freq_inc),
-				0, (int)bins()-1);
-			return metrics::CProfile::course(bin);
-		}
-
-	int go_compute();
-	string mirror_fname() const;
-
-	string fname_base() const;
-	int export_tsv( const string& fname) const;
-	int export_tsv( size_t bin,
-			const string& fname) const;
-
-	// to enable use as mapped type
-	CProfile (const CProfile& rv)
-	      : metrics::CProfile (rv)
-		{}
+        CProfile (const sigfile::CTypedSource&, int sig_no,
+                  const SPPack&);
+
+        SPPack Pp;
+
+        const char* metric_name() const
+                {
+                        return metrics::name( TType::mc);
+                }
+
+        valarray<TFloat> course( double binf) const
+                {
+                        size_t        bin = agh::alg::value_within(
+                                (int)((binf - Pp.freq_from) / Pp.freq_inc),
+                                0, (int)bins()-1);
+                        return metrics::CProfile::course(bin);
+                }
+
+        int go_compute();
+        string mirror_fname() const;
+
+        string fname_base() const;
+        int export_tsv( const string& fname) const;
+        int export_tsv( size_t bin,
+                        const string& fname) const;
+
+        // to enable use as mapped type
+        CProfile (const CProfile& rv)
+              : metrics::CProfile (rv)
+                {}
 };
 
 
@@ -154,57 +154,57 @@ class CProfile
 template <typename T>
 pair<valarray<T>, valarray<T>>
 do_sssu_reduction( const valarray<T>&,
-		   size_t, double, double, double, double,
-		   double, double, double);
+                   size_t, double, double, double, double,
+                   double, double, double);
 
 extern const size_t sssu_hist_size;
 
 extern template
 pair<valarray<TFloat>, valarray<TFloat>>
 do_sssu_reduction( const valarray<TFloat>&,
-		   size_t, double, double, double, double,
-		   double, double, double);
+                   size_t, double, double, double, double,
+                   double, double, double);
 
 template <typename T>
 pair<valarray<T>, valarray<T>>
 do_sssu_reduction( const valarray<T>& S,
-		   size_t samplerate,
-		   double scope, double inc,
-		   double mc_gain, double iir_backpolate,
-		   double f0, double fc,
-		   double bandwidth)
+                   size_t samplerate,
+                   double scope, double inc,
+                   double mc_gain, double iir_backpolate,
+                   double f0, double fc,
+                   double bandwidth)
 {
-	sigproc::CFilterDUE<T>
-		due_filter (samplerate, sigproc::TFilterDirection::forward,
-			    mc_gain, iir_backpolate,
-			    fc);
-	sigproc::CFilterSE<T>
-		se_filter (samplerate, sigproc::TFilterDirection::forward,
-			   mc_gain, iir_backpolate,
-			   f0, fc,
-			   bandwidth);
-
-	size_t	scope_samples = scope * samplerate,
-		inc_samples = inc * samplerate,
-		lpages = S.size() / inc_samples;
-	valarray<T>
-		due_filtered = due_filter.apply( S, false),
-		se_filtered  =  se_filter.apply( S, false);
-
-	valarray<T>
-		ss (lpages),
-		su (lpages);
-	for ( size_t p = 0; p < lpages; ++p ) {
-		auto range = slice (p * inc_samples, scope_samples, 1);
-		su[p] =
-			(valarray<T> {due_filtered[range]} * valarray<T> {se_filtered[range]})
-			.sum() / scope_samples;
-		ss[p] =
-			pow(valarray<T> {se_filtered[range]}, (T)2.)
-			.sum() / samplerate / scope_samples;
-	}
-
-	return {su, ss};
+        sigproc::CFilterDUE<T>
+                due_filter (samplerate, sigproc::TFilterDirection::forward,
+                            mc_gain, iir_backpolate,
+                            fc);
+        sigproc::CFilterSE<T>
+                se_filter (samplerate, sigproc::TFilterDirection::forward,
+                           mc_gain, iir_backpolate,
+                           f0, fc,
+                           bandwidth);
+
+        size_t        scope_samples = scope * samplerate,
+                inc_samples = inc * samplerate,
+                lpages = S.size() / inc_samples;
+        valarray<T>
+                due_filtered = due_filter.apply( S, false),
+                se_filtered  =  se_filter.apply( S, false);
+
+        valarray<T>
+                ss (lpages),
+                su (lpages);
+        for ( size_t p = 0; p < lpages; ++p ) {
+                auto range = slice (p * inc_samples, scope_samples, 1);
+                su[p] =
+                        (valarray<T> {due_filtered[range]} * valarray<T> {se_filtered[range]})
+                        .sum() / scope_samples;
+                ss[p] =
+                        pow(valarray<T> {se_filtered[range]}, (T)2.)
+                        .sum() / samplerate / scope_samples;
+        }
+
+        return {su, ss};
 }
 
 
diff --git a/upstream/src/libmetrics/page-metrics-base.cc b/upstream/src/libmetrics/page-metrics-base.cc
index fd511de..04cb605 100644
--- a/upstream/src/libmetrics/page-metrics-base.cc
+++ b/upstream/src/libmetrics/page-metrics-base.cc
@@ -30,29 +30,29 @@ using namespace std;
 
 metrics::CProfile::
 CProfile (const sigfile::CTypedSource& F, int sig_no,
-	  double pagesize, double step, size_t bins)
+          double pagesize, double step, size_t bins)
       : _status (0),
-	_bins (bins),
-	_signature_when_mirrored (0),
-	_using_F (F),
-	_using_sig_no (sig_no)
+        _bins (bins),
+        _signature_when_mirrored (0),
+        _using_F (F),
+        _using_sig_no (sig_no)
 {
-	Pp.pagesize = pagesize;
-	Pp.step = step;
+        Pp.pagesize = pagesize;
+        Pp.step = step;
 }
 
 size_t
 metrics::CProfile::
 samplerate() const
 {
-	return _using_F().samplerate( _using_sig_no);
+        return _using_F().samplerate( _using_sig_no);
 }
 
 size_t
 metrics::CProfile::
 steps() const
 {
-	return (_using_F().recording_time() - Pp.pagesize) / Pp.step;
+        return (_using_F().recording_time() - Pp.pagesize) / Pp.step;
 }
 
 
@@ -60,27 +60,27 @@ void
 metrics::SPPack::
 check() const
 {
-	for ( auto c : {4., 20., 30., 60.} )
-		if ( pagesize == c )
-			return;
+        for ( auto c : {4., 20., 30., 60.} )
+                if ( pagesize == c )
+                        return;
 #ifdef _OPENMP
 #pragma omp critical
 #endif
-	throw invalid_argument (string ("Invalid pagesize: ") + to_string(pagesize));
+        throw invalid_argument (string ("Invalid pagesize: ") + to_string(pagesize));
 
-	if ( step <= pagesize )
-		return;
+        if ( step <= pagesize )
+                return;
 #ifdef _OPENMP
 #pragma omp critical
 #endif
-	throw invalid_argument (string ("step > pagesize: ") + to_string(step) + " > "+ to_string(pagesize));
+        throw invalid_argument (string ("step > pagesize: ") + to_string(step) + " > "+ to_string(pagesize));
 }
 
 void
 metrics::SPPack::
 reset()
 {
-	pagesize = step = 30.;
+        pagesize = step = 30.;
 }
 
 
@@ -88,11 +88,11 @@ list<agh::alg::SSpan<size_t>>
 metrics::CProfile::
 artifacts_in_samples() const
 {
-	size_t sr = _using_F().samplerate(_using_sig_no);
-	list<agh::alg::SSpan<size_t>> Q;
-	for ( auto& a : _using_F().artifacts( _using_sig_no)() )
-		Q.emplace_back( a.a * sr, a.z * sr);
-	return Q;
+        size_t sr = _using_F().samplerate(_using_sig_no);
+        list<agh::alg::SSpan<size_t>> Q;
+        for ( auto& a : _using_F().artifacts( _using_sig_no)() )
+                Q.emplace_back( a.a * sr, a.z * sr);
+        return Q;
 }
 
 
@@ -100,7 +100,7 @@ list<agh::alg::SSpan<double>>
 metrics::CProfile::
 artifacts_in_seconds() const
 {
-	return _using_F().artifacts( _using_sig_no)();
+        return _using_F().artifacts( _using_sig_no)();
 }
 
 
@@ -109,59 +109,59 @@ int
 metrics::CProfile::
 compute( const SPPack& req_params)
 {
-	auto req_signature = _using_F().dirty_signature( _using_sig_no);
-	if ( have_data()
-	     and req_signature == _signature_when_mirrored
-	     and Pp.same_as(req_params) )
-		return 0;
+        auto req_signature = _using_F().dirty_signature( _using_sig_no);
+        if ( have_data()
+             and req_signature == _signature_when_mirrored
+             and Pp.same_as(req_params) )
+                return 0;
 
-	auto old_mirror = mirror_fname();
-	Pp.make_same( req_params);
-	_signature_when_mirrored = req_signature;
-	auto new_mirror = mirror_fname();
+        auto old_mirror = mirror_fname();
+        Pp.make_same( req_params);
+        _signature_when_mirrored = req_signature;
+        auto new_mirror = mirror_fname();
 
-	bool got_it = (mirror_back( new_mirror) == 0);
+        bool got_it = (mirror_back( new_mirror) == 0);
 
-	if ( old_mirror != new_mirror )
+        if ( old_mirror != new_mirror )
 #pragma GCC diagnostic ignored "-Wunused-value"
 #pragma GCC diagnostic push
-		unlink( old_mirror.c_str());
+                unlink( old_mirror.c_str());
 #pragma GCC diagnostic pop
 
-	if ( got_it )
-		return 0;
+        if ( got_it )
+                return 0;
 
-	// printf( "CProfile::compute( %s, %s): %g sec (%zu pp @%zu + %zu sec last incomplete page); bins/size/freq_max = %zu/%g/%g",
-	// 	_using_F.filename(), _using_F.channel_by_id(_using_sig_no),
-	// 	_using_F.recording_time(),
-	// 	pages(), _pagesize, (size_t)_using_F.recording_time() - (pages() * _pagesize),
-	// 	_bins, binsize, freq_max);
+        // printf( "CProfile::compute( %s, %s): %g sec (%zu pp @%zu + %zu sec last incomplete page); bins/size/freq_max = %zu/%g/%g",
+        //         _using_F.filename(), _using_F.channel_by_id(_using_sig_no),
+        //         _using_F.recording_time(),
+        //         pages(), _pagesize, (size_t)_using_F.recording_time() - (pages() * _pagesize),
+        //         _bins, binsize, freq_max);
 
-	auto retval = go_compute();
+        auto retval = go_compute();
 
-	mirror_enable( new_mirror) or true;
+        mirror_enable( new_mirror) or true;
 
-	return retval;
+        return retval;
 }
 
 bool
 metrics::CProfile::
 need_compute( const SPPack& req_params)
 {
-	auto req_signature = _using_F().dirty_signature( _using_sig_no);
-	if ( have_data()
-	     and req_signature == _signature_when_mirrored
-	     and Pp.same_as(req_params) )
-		return false;
+        auto req_signature = _using_F().dirty_signature( _using_sig_no);
+        if ( have_data()
+             and req_signature == _signature_when_mirrored
+             and Pp.same_as(req_params) )
+                return false;
 
-	auto old_mirror = mirror_fname();
-	Pp.make_same( req_params);
-	_signature_when_mirrored = req_signature;
-	auto new_mirror = mirror_fname();
+        auto old_mirror = mirror_fname();
+        Pp.make_same( req_params);
+        _signature_when_mirrored = req_signature;
+        auto new_mirror = mirror_fname();
 
-	bool got_it = (mirror_back( new_mirror) == 0);
+        bool got_it = (mirror_back( new_mirror) == 0);
 
-	return not got_it;
+        return not got_it;
 }
 
 
@@ -170,12 +170,12 @@ int
 metrics::CProfile::
 mirror_enable( const string& fname)
 {
-	int fd, retval = 0;
-	if ( (fd = open( fname.c_str(), O_RDWR | O_CREAT | O_TRUNC, 0644)) == -1 ||
-	     write( fd, &_data[0], _data.size() * sizeof(TFloat)) == -1 )
-	     retval = -1;
-	close( fd);
-	return retval;
+        int fd, retval = 0;
+        if ( (fd = open( fname.c_str(), O_RDWR | O_CREAT | O_TRUNC, 0644)) == -1 ||
+             write( fd, &_data[0], _data.size() * sizeof(TFloat)) == -1 )
+             retval = -1;
+        close( fd);
+        return retval;
 }
 
 
@@ -183,26 +183,26 @@ int
 metrics::CProfile::
 mirror_back( const string& fname)
 {
-	int fd = -1;
-	try {
-		if ( (fd = open( fname.c_str(), O_RDONLY)) == -1 )
-			throw -1;
-		_data.resize( steps() * _bins);
-		if ( read( fd, &_data[0], _data.size() * sizeof(TFloat))
-		     != (ssize_t)(_data.size() * sizeof(TFloat)) )
-			throw -2;
-		close(fd);
-		return 0;
-	} catch (int ex) {
-		if ( fd != -1 ) {
-			close( fd);
+        int fd = -1;
+        try {
+                if ( (fd = open( fname.c_str(), O_RDONLY)) == -1 )
+                        throw -1;
+                _data.resize( steps() * _bins);
+                if ( read( fd, &_data[0], _data.size() * sizeof(TFloat))
+                     != (ssize_t)(_data.size() * sizeof(TFloat)) )
+                        throw -2;
+                close(fd);
+                return 0;
+        } catch (int ex) {
+                if ( fd != -1 ) {
+                        close( fd);
 #pragma GCC diagnostic ignored "-Wunused-value"
 #pragma GCC diagnostic push
-			unlink( fname.c_str());
+                        unlink( fname.c_str());
 #pragma GCC diagnostic pop
-		}
-		return ex;
-	}
+                }
+                return ex;
+        }
 }
 
 
@@ -214,32 +214,32 @@ int
 metrics::CProfile::
 export_tsv( const string& fname) const
 {
-	FILE *f = fopen( fname.c_str(), "w");
-	if ( !f )
-		return -1;
-
-	size_t bin, p;
-
-	auto sttm = _using_F().start_time();
-	char *asctime_ = asctime( localtime( &sttm));
-	fprintf( f, "## Subject: %s;  Session: %s, Episode: %s recorded %.*s;  Channel: %s\n"
-		 "#Page\t",
-		 _using_F().subject().name.c_str(), _using_F().session(), _using_F().episode(),
-		 (int)strlen(asctime_)-1, asctime_,
-		 _using_F().channel_by_id(_using_sig_no).name());
-
-	for ( bin = 0; bin < _bins; ++bin )
-		fprintf( f, "%zu%c", bin, bin+1 == _bins ? '\n' : '\t');
-
-	for ( p = 0; p < steps(); ++p ) {
-		fprintf( f, "%zu", p);
-		for ( bin = 0; bin < _bins; ++bin )
-			fprintf( f, "\t%g", nmth_bin( p, bin));
-		fprintf( f, "\n");
-	}
-
-	fclose( f);
-	return 0;
+        FILE *f = fopen( fname.c_str(), "w");
+        if ( !f )
+                return -1;
+
+        size_t bin, p;
+
+        auto sttm = _using_F().start_time();
+        char *asctime_ = asctime( localtime( &sttm));
+        fprintf( f, "## Subject: %s;  Session: %s, Episode: %s recorded %.*s;  Channel: %s\n"
+                 "#Page\t",
+                 _using_F().subject().name.c_str(), _using_F().session(), _using_F().episode(),
+                 (int)strlen(asctime_)-1, asctime_,
+                 _using_F().channel_by_id(_using_sig_no).name());
+
+        for ( bin = 0; bin < _bins; ++bin )
+                fprintf( f, "%zu%c", bin, bin+1 == _bins ? '\n' : '\t');
+
+        for ( p = 0; p < steps(); ++p ) {
+                fprintf( f, "%zu", p);
+                for ( bin = 0; bin < _bins; ++bin )
+                        fprintf( f, "\t%g", nmth_bin( p, bin));
+                fprintf( f, "\n");
+        }
+
+        fclose( f);
+        return 0;
 }
 
 
diff --git a/upstream/src/libmetrics/page-metrics-base.hh b/upstream/src/libmetrics/page-metrics-base.hh
index ccbcda2..6e61284 100644
--- a/upstream/src/libmetrics/page-metrics-base.hh
+++ b/upstream/src/libmetrics/page-metrics-base.hh
@@ -35,41 +35,41 @@ inline const char*
 __attribute__ ((pure))
 name( TType t)
 {
-	switch ( t ) {
-	case TType::psd:
-		return "PSD";
-	case TType::mc:
-		return "Microcontinuity";
-	case TType::swu:
-		return "SW Upswing";
-	default:
-		return "(unknown metric)";
-	}
+        switch ( t ) {
+        case TType::psd:
+                return "PSD";
+        case TType::mc:
+                return "Microcontinuity";
+        case TType::swu:
+                return "SW Upswing";
+        default:
+                return "(unknown metric)";
+        }
 }
 
 
 
 struct SPPack {
-	double	pagesize,
-		step;
-
-	SPPack ()
-		{
-			reset();
-		}
-
-	virtual bool same_as( const SPPack& rv) const
-		{
-			return pagesize == rv.pagesize && step == rv.step;
-		}
-	virtual void make_same( const SPPack& rv)
-		{
-			pagesize = rv.pagesize;
-			step = rv.step;
-		}
-
-	void check() const; // throws
-	void reset();
+        double        pagesize,
+                step;
+
+        SPPack ()
+                {
+                        reset();
+                }
+
+        virtual bool same_as( const SPPack& rv) const
+                {
+                        return pagesize == rv.pagesize && step == rv.step;
+                }
+        virtual void make_same( const SPPack& rv)
+                {
+                        pagesize = rv.pagesize;
+                        step = rv.step;
+                }
+
+        void check() const; // throws
+        void reset();
 };
 
 
@@ -80,113 +80,113 @@ struct SPPack {
 class CProfile {
 
     protected:
-	CProfile (const sigfile::CTypedSource&, int sig_no,
-		  double pagesize, double step, size_t bins);
-	CProfile (const CProfile&) = default;
+        CProfile (const sigfile::CTypedSource&, int sig_no,
+                  double pagesize, double step, size_t bins);
+        CProfile (const CProfile&) = default;
     public:
-	SPPack	Pp;
+        SPPack        Pp;
 
-	virtual const char* metric_name() const = 0;
+        virtual const char* metric_name() const = 0;
 
-	const sigfile::CSource& source() const
-		{
-			return _using_F();
-		}
-	int sig_no() const
-		{
-			return _using_sig_no;
-		}
+        const sigfile::CSource& source() const
+                {
+                        return _using_F();
+                }
+        int sig_no() const
+                {
+                        return _using_sig_no;
+                }
 
-	bool have_data() const
-		{
-			return _status & TFlags::computed;
-		}
+        bool have_data() const
+                {
+                        return _status & TFlags::computed;
+                }
 
-	size_t bins() const
-		{
-			return _bins;
-		}
+        size_t bins() const
+                {
+                        return _bins;
+                }
 
-	size_t steps() const; // overlapping pages
-	size_t samplerate() const;
+        size_t steps() const; // overlapping pages
+        size_t samplerate() const;
 
       // accessors
-	TFloat&
-	nmth_bin( size_t p, size_t b)
-		{
-			// if ( unlikely (b >= n_bins()) )
-			// 	throw out_of_range("CPageMetrics_base::nmth_bin(): bin out of range");
-			// if ( unlikely (p >= n_pages()) )
-			// 	throw out_of_range("CPageMetrics_base::nmth_bin(): page out of range");
-			return _data[p * _bins + b];
-		}
-	const TFloat&
-	nmth_bin( size_t p, size_t b) const
-		{
-			return _data[p * _bins + b];
-		}
+        TFloat&
+        nmth_bin( size_t p, size_t b)
+                {
+                        // if ( unlikely (b >= n_bins()) )
+                        //         throw out_of_range("CPageMetrics_base::nmth_bin(): bin out of range");
+                        // if ( unlikely (p >= n_pages()) )
+                        //         throw out_of_range("CPageMetrics_base::nmth_bin(): page out of range");
+                        return _data[p * _bins + b];
+                }
+        const TFloat&
+        nmth_bin( size_t p, size_t b) const
+                {
+                        return _data[p * _bins + b];
+                }
 
       // power course
-	// full (note the returned array size is length * n_bins)
-	valarray<TFloat> course() const
-		{
-			return _data;
-		}
+        // full (note the returned array size is length * n_bins)
+        valarray<TFloat> course() const
+                {
+                        return _data;
+                }
 
-	// in a bin
-	valarray<TFloat> course( size_t m) const
-		{
-			return _data[ slice(m, steps(), _bins) ];
-		}
+        // in a bin
+        valarray<TFloat> course( size_t m) const
+                {
+                        return _data[ slice(m, steps(), _bins) ];
+                }
 
-	valarray<TFloat> spectrum( size_t p) const
-		{
-			return _data[ slice(p * _bins, _bins, 1) ];
-		}
+        valarray<TFloat> spectrum( size_t p) const
+                {
+                        return _data[ slice(p * _bins, _bins, 1) ];
+                }
 
 
     public:
       // artifacts
-	list<agh::alg::SSpan<size_t>> artifacts_in_samples() const;
-	list<agh::alg::SSpan<double>> artifacts_in_seconds() const;
+        list<agh::alg::SSpan<size_t>> artifacts_in_samples() const;
+        list<agh::alg::SSpan<double>> artifacts_in_seconds() const;
 
-	virtual int export_tsv( const string& fname) const;
+        virtual int export_tsv( const string& fname) const;
 
-	int compute( const SPPack&);
-	int compute()
-		{
-			return compute( Pp);
-		}
-	bool need_compute( const SPPack&);  // not const because it does mirror_back
-	bool need_compute()
-		{
-			return need_compute( Pp);
-		}
+        int compute( const SPPack&);
+        int compute()
+                {
+                        return compute( Pp);
+                }
+        bool need_compute( const SPPack&);  // not const because it does mirror_back
+        bool need_compute()
+                {
+                        return need_compute( Pp);
+                }
 
 
     protected:
-	virtual int go_compute() = 0;
-	virtual string fname_base() const = 0;
-	virtual string mirror_fname() const = 0;
+        virtual int go_compute() = 0;
+        virtual string fname_base() const = 0;
+        virtual string mirror_fname() const = 0;
 
-	enum TFlags : int {
-		computed = (1<<0),
-		computable = (1<<1)
-	};
-	int	_status;
+        enum TFlags : int {
+                computed = (1<<0),
+                computable = (1<<1)
+        };
+        int        _status;
 
-	valarray<TFloat>  // arrays in a given bin extracted by slices
-		_data;    // it is always double because it is saved/loaded in this form
-	size_t	_bins;
+        valarray<TFloat>  // arrays in a given bin extracted by slices
+                _data;    // it is always double because it is saved/loaded in this form
+        size_t        _bins;
 
-	agh::hash_t
-		_signature_when_mirrored;
+        agh::hash_t
+                _signature_when_mirrored;
 
-	const sigfile::CTypedSource& _using_F;
-	int _using_sig_no;
+        const sigfile::CTypedSource& _using_F;
+        int _using_sig_no;
 
-	int mirror_enable( const string&);
-	int mirror_back( const string&);
+        int mirror_enable( const string&);
+        int mirror_back( const string&);
 };
 
 
diff --git a/upstream/src/libmetrics/psd.cc b/upstream/src/libmetrics/psd.cc
index a46b7b7..b4e7f40 100644
--- a/upstream/src/libmetrics/psd.cc
+++ b/upstream/src/libmetrics/psd.cc
@@ -33,9 +33,9 @@ using namespace std;
 
 
 sigproc::TWinType
-	metrics::psd::SPPack::welch_window_type = sigproc::TWinType::hanning;
+        metrics::psd::SPPack::welch_window_type = sigproc::TWinType::hanning;
 metrics::psd::TFFTWPlanType
-	metrics::psd::SPPack::plan_type = metrics::psd::TFFTWPlanType::estimate;
+        metrics::psd::SPPack::plan_type = metrics::psd::TFFTWPlanType::estimate;
 
 
 
@@ -43,13 +43,13 @@ metrics::psd::TFFTWPlanType
 
 metrics::psd::CProfile::
 CProfile (const sigfile::CTypedSource& F, const int sig_no,
-	  const SPPack &params)
+          const SPPack &params)
       : metrics::CProfile (F, sig_no,
-			   params.pagesize, params.step,
-			   params.compute_n_bins( F().samplerate(sig_no))),
-	Pp (params)
+                           params.pagesize, params.step,
+                           params.compute_n_bins( F().samplerate(sig_no))),
+        Pp (params)
 {
-	Pp.check();
+        Pp.check();
 }
 
 
@@ -58,15 +58,15 @@ string
 metrics::psd::CProfile::
 fname_base() const
 {
-	return move(
-		agh::str::sasprintf(
-			"%s.%s-%lu"
-			":%g+%g-%g-%c%c",
-			_using_F().filename(), _using_F().channel_by_id(_using_sig_no).name(),
-			_using_F().dirty_signature( _using_sig_no),
-			Pp.pagesize, Pp.step, Pp.binsize,
-			'a'+(char)Pp.welch_window_type, 'a'+(char)Pp.plan_type)
-		);
+        return move(
+                agh::str::sasprintf(
+                        "%s.%s-%lu"
+                        ":%g+%g-%g-%c%c",
+                        _using_F().filename(), _using_F().channel_by_id(_using_sig_no).name(),
+                        _using_F().dirty_signature( _using_sig_no),
+                        Pp.pagesize, Pp.step, Pp.binsize,
+                        'a'+(char)Pp.welch_window_type, 'a'+(char)Pp.plan_type)
+                );
 }
 
 
@@ -75,18 +75,18 @@ string
 metrics::psd::CProfile::
 mirror_fname() const
 {
-	return move(
-		agh::str::sasprintf(
-			"%s.%s-%lu"
-			":%g+%g-%g-%c%c@%zu"
-			".psd",
-			agh::fs::make_fname_base (_using_F().filename(), "", agh::fs::TMakeFnameOption::hidden).c_str(),
-			_using_F().channel_by_id(_using_sig_no).name(),
-			_using_F().dirty_signature( _using_sig_no),
-			Pp.pagesize, Pp.step, Pp.binsize,
-			'a'+(char)Pp.welch_window_type, 'a'+(char)Pp.plan_type,
-			sizeof(double))
-		);
+        return move(
+                agh::str::sasprintf(
+                        "%s.%s-%lu"
+                        ":%g+%g-%g-%c%c@%zu"
+                        ".psd",
+                        agh::fs::make_fname_base (_using_F().filename(), "", agh::fs::TMakeFnameOption::hidden).c_str(),
+                        _using_F().channel_by_id(_using_sig_no).name(),
+                        _using_F().dirty_signature( _using_sig_no),
+                        Pp.pagesize, Pp.step, Pp.binsize,
+                        'a'+(char)Pp.welch_window_type, 'a'+(char)Pp.plan_type,
+                        sizeof(double))
+                );
 }
 
 
@@ -96,111 +96,111 @@ int
 metrics::psd::CProfile::
 go_compute()
 {
-	_data.resize( steps() * _bins);
+        _data.resize( steps() * _bins);
 
-	size_t	sr = samplerate();
-	size_t	spp = sr * Pp.pagesize,
-		sps = sr * Pp.step;
-//	double	freq_max = (spp+1)/2 / sr;
+        size_t        sr = samplerate();
+        size_t        spp = sr * Pp.pagesize,
+                sps = sr * Pp.step;
+//        double        freq_max = (spp+1)/2 / sr;
 
       // 0. get signal sample; always use double not TFloat
       // so that saved power is usable irrespective of what TFloat is today
-	valarray<double> S = agh::alg::to_vad( _using_F().get_signal_filtered( _using_sig_no));
+        valarray<double> S = agh::alg::to_vad( _using_F().get_signal_filtered( _using_sig_no));
 
       // 1. dampen samples marked as artifacts
-	// already done in get_signal_filtered()
+        // already done in get_signal_filtered()
 
       // 2. zero-mean and detrend
-	// zero-mean already done in CEDFFile::get_signal_filtered()
+        // zero-mean already done in CEDFFile::get_signal_filtered()
 
       // 4. obtain power spectrum
-	// prepare
+        // prepare
 
-	double
-		*fft_Ti = (double*)fftw_malloc( sizeof(double) * spp * 2),
-		*fft_To = (double*)fftw_malloc( sizeof(double) * spp * 2);
-	valarray<double>	// buffer for PSD
-		P (spp+2);
+        double
+                *fft_Ti = (double*)fftw_malloc( sizeof(double) * spp * 2),
+                *fft_To = (double*)fftw_malloc( sizeof(double) * spp * 2);
+        valarray<double>        // buffer for PSD
+                P (spp+2);
 
-	static map<size_t, fftw_plan> plannen;
+        static map<size_t, fftw_plan> plannen;
 #ifdef _OPENMP
 #pragma omp critical
 #endif
-	{
-//		if ( fft_plan == nullptr ) {
+        {
+//                if ( fft_plan == nullptr ) {
 //#if defined(HAVE_LIBFFTW3_OMP) && defined(_OPENMP)
-//			int n_procs = omp_get_max_threads();
-//			fftw_init_threads();
-//			fftw_plan_with_nthreads( n_procs);
-//			fftw_plan();
-//			printf( "Will use %d core(s)\n", n_procs);
+//                        int n_procs = omp_get_max_threads();
+//                        fftw_init_threads();
+//                        fftw_plan_with_nthreads( n_procs);
+//                        fftw_plan();
+//                        printf( "Will use %d core(s)\n", n_procs);
 //#endif
-//		}
-		// use single-threaded fftw; SMP active at a higher level
-		if ( plannen.find( spp) == plannen.end() ) {
-
-			printf( "Preparing fftw plan for %zu samples...", spp);
-
-			//memcpy( fft_Ti, &S[0], spp * sizeof(double));  // not necessary?
-			plannen[spp] = fftw_plan_dft_r2c_1d(
-				spp, fft_Ti, (fftw_complex*)fft_To,
-				plan_flags(Pp.plan_type));
-			printf( "done\n");
-		}
-	}
-
-	// go
-	TFloat	f = 0.;
-	size_t	p, b, k = 1,
-		window = sr;
-	// what about some smooth edges?
-	valarray<double>
-		W (spp);
-	{
-		size_t	t9 = spp - window,   // start of the last window but one
-			t;
-		auto wfun = sigproc::winf[Pp.welch_window_type];
-		for ( t = 0; t < window/2; ++t )
-			W[t] = wfun( t, window);
-		for ( t = window/2; t < window; ++t )
-			W[t9 + t] = wfun( t, window);
-		// AND, connect mid-first to mid-last windows (at lowest value of the window)
-		W[ slice(window/2, spp-window, 1) ] = wfun( window/2, window);
-	}
-
-	for ( p = 0; p < steps(); ++p ) {
-		// assert (p * sps + spp < S.size());
-		memcpy( fft_Ti, &S[p * sps], spp * sizeof(double));
-		for ( size_t s = 0; s < spp; ++s )
-			fft_Ti[s] *= W[s];
-
-		fftw_execute_dft_r2c( plannen[spp], fft_Ti, (fftw_complex*)fft_To);
-
-	      // thanks http://www.fftw.org/fftw2_doc/fftw_2.html
-		P[0] = fft_To[0] * fft_To[0];		/* DC component */
-		for ( k = 1; k < (spp+1)/2; ++k )		/* (k < N/2 rounded up) */
-			P[k] =    fft_To[    k] * fft_To[    k]
-				+ fft_To[spp-k] * fft_To[spp-k];
-		if ( likely (spp % 2 == 0) )			/* N is even */
-			P[spp/2] = fft_To[spp/2] * fft_To[spp/2];	/* Nyquist freq. */
-
-	      // 5. collect power into bins
-		// the frequency resolution in P is (1/samplerate) Hz, right?
-		////memcpy( &_data[p*bins], &P[ThId][0], bins * sizeof(TFloat));
-		///printf( "n_bins = %zu, max_freq = %g\n", n_bins(), max_freq);
-		for ( f = 0., b = 0; b < _bins; (f += Pp.binsize), ++b ) {
-			//printf( "b = %zu, f = %g\n", b, f);
-			nmth_bin(p, b) = (TFloat) // brilliant!
-				valarray<double>
-				(P[ slice( f*sr, (f + Pp.binsize)*sr, 1) ]) . sum();
-		}
-		/// / (bin_size * sr) // don't; power is cumulative
-	}
-
-	fftw_free( fft_Ti);
-	fftw_free( fft_To);
-
-	return 0;
+//                }
+                // use single-threaded fftw; SMP active at a higher level
+                if ( plannen.find( spp) == plannen.end() ) {
+
+                        printf( "Preparing fftw plan for %zu samples...", spp);
+
+                        //memcpy( fft_Ti, &S[0], spp * sizeof(double));  // not necessary?
+                        plannen[spp] = fftw_plan_dft_r2c_1d(
+                                spp, fft_Ti, (fftw_complex*)fft_To,
+                                plan_flags(Pp.plan_type));
+                        printf( "done\n");
+                }
+        }
+
+        // go
+        TFloat        f = 0.;
+        size_t        p, b, k = 1,
+                window = sr;
+        // what about some smooth edges?
+        valarray<double>
+                W (spp);
+        {
+                size_t        t9 = spp - window,   // start of the last window but one
+                        t;
+                auto wfun = sigproc::winf[Pp.welch_window_type];
+                for ( t = 0; t < window/2; ++t )
+                        W[t] = wfun( t, window);
+                for ( t = window/2; t < window; ++t )
+                        W[t9 + t] = wfun( t, window);
+                // AND, connect mid-first to mid-last windows (at lowest value of the window)
+                W[ slice(window/2, spp-window, 1) ] = wfun( window/2, window);
+        }
+
+        for ( p = 0; p < steps(); ++p ) {
+                // assert (p * sps + spp < S.size());
+                memcpy( fft_Ti, &S[p * sps], spp * sizeof(double));
+                for ( size_t s = 0; s < spp; ++s )
+                        fft_Ti[s] *= W[s];
+
+                fftw_execute_dft_r2c( plannen[spp], fft_Ti, (fftw_complex*)fft_To);
+
+              // thanks http://www.fftw.org/fftw2_doc/fftw_2.html
+                P[0] = fft_To[0] * fft_To[0];                /* DC component */
+                for ( k = 1; k < (spp+1)/2; ++k )                /* (k < N/2 rounded up) */
+                        P[k] =    fft_To[    k] * fft_To[    k]
+                                + fft_To[spp-k] * fft_To[spp-k];
+                if ( likely (spp % 2 == 0) )                        /* N is even */
+                        P[spp/2] = fft_To[spp/2] * fft_To[spp/2];        /* Nyquist freq. */
+
+              // 5. collect power into bins
+                // the frequency resolution in P is (1/samplerate) Hz, right?
+                ////memcpy( &_data[p*bins], &P[ThId][0], bins * sizeof(TFloat));
+                ///printf( "n_bins = %zu, max_freq = %g\n", n_bins(), max_freq);
+                for ( f = 0., b = 0; b < _bins; (f += Pp.binsize), ++b ) {
+                        //printf( "b = %zu, f = %g\n", b, f);
+                        nmth_bin(p, b) = (TFloat) // brilliant!
+                                valarray<double>
+                                (P[ slice( f*sr, (f + Pp.binsize)*sr, 1) ]) . sum();
+                }
+                /// / (bin_size * sr) // don't; power is cumulative
+        }
+
+        fftw_free( fft_Ti);
+        fftw_free( fft_To);
+
+        return 0;
 }
 
 
@@ -215,35 +215,35 @@ int
 metrics::psd::CProfile::
 export_tsv( const string& fname) const
 {
-	FILE *f = fopen( fname.c_str(), "w");
-	if ( !f )
-		return -1;
-
-	size_t bin, p;
-	float bum = 0.;
-
-	auto sttm = _using_F().start_time();
-	char *asctime_ = asctime( localtime( &sttm));
-	fprintf( f, "## Subject: %s;  Session: %s, Episode: %s recorded %.*s;  Channel: %s\n"
-		 "## Total spectral power course (%zu %g-sec pages, step %g sec) up to %g Hz in bins of %g Hz\n"
-		 "#Page\t",
-		 _using_F().subject().name.c_str(), _using_F().session(), _using_F().episode(),
-		 (int)strlen(asctime_)-1, asctime_,
-		 _using_F().channel_by_id(_using_sig_no).name(),
-		 steps(), Pp.pagesize, Pp.step, _bins*Pp.binsize, Pp.binsize);
-
-	for ( bin = 0; bin < _bins; ++bin, bum += Pp.binsize )
-		fprintf( f, "%g%c", bum, bin+1 == _bins ? '\n' : '\t');
-
-	for ( p = 0; p < steps(); ++p ) {
-		fprintf( f, "%zu", p);
-		for ( bin = 0; bin < _bins; ++bin )
-			fprintf( f, "\t%g", nmth_bin( p, bin));
-		fprintf( f, "\n");
-	}
-
-	fclose( f);
-	return 0;
+        FILE *f = fopen( fname.c_str(), "w");
+        if ( !f )
+                return -1;
+
+        size_t bin, p;
+        float bum = 0.;
+
+        auto sttm = _using_F().start_time();
+        char *asctime_ = asctime( localtime( &sttm));
+        fprintf( f, "## Subject: %s;  Session: %s, Episode: %s recorded %.*s;  Channel: %s\n"
+                 "## Total spectral power course (%zu %g-sec pages, step %g sec) up to %g Hz in bins of %g Hz\n"
+                 "#Page\t",
+                 _using_F().subject().name.c_str(), _using_F().session(), _using_F().episode(),
+                 (int)strlen(asctime_)-1, asctime_,
+                 _using_F().channel_by_id(_using_sig_no).name(),
+                 steps(), Pp.pagesize, Pp.step, _bins*Pp.binsize, Pp.binsize);
+
+        for ( bin = 0; bin < _bins; ++bin, bum += Pp.binsize )
+                fprintf( f, "%g%c", bum, bin+1 == _bins ? '\n' : '\t');
+
+        for ( p = 0; p < steps(); ++p ) {
+                fprintf( f, "%zu", p);
+                for ( bin = 0; bin < _bins; ++bin )
+                        fprintf( f, "\t%g", nmth_bin( p, bin));
+                fprintf( f, "\n");
+        }
+
+        fclose( f);
+        return 0;
 }
 
 
@@ -252,28 +252,28 @@ export_tsv( const string& fname) const
 int
 metrics::psd::CProfile::
 export_tsv( float from, float upto,
-	    const string& fname) const
+            const string& fname) const
 {
-	FILE *f = fopen( fname.c_str(), "w");
-	if ( !f )
-		return -1;
-
-	auto sttm = _using_F().start_time();
-	char *asctime_ = asctime( localtime( &sttm));
-	fprintf( f, "PSD profile of\n"
-		 "## Subject: %s;  Session: %s, Episode: %s recorded %.*s;  Channel: %s\n"
-		 "## Course (%zu %g-sec pages, step %g) in range %g-%g Hz\n",
-		 _using_F().subject().name.c_str(), _using_F().session(), _using_F().episode(),
-		 (int)strlen(asctime_)-1, asctime_,
-		 _using_F().channel_by_id(_using_sig_no).name(),
-		 steps(), Pp.pagesize, Pp.step, from, upto);
-
-	valarray<TFloat> crs = course( from, upto);
-	for ( size_t p = 0; p < steps(); ++p )
-		fprintf( f, "%zu\t%g\n", p, crs[p]);
-
-	fclose( f);
-	return 0;
+        FILE *f = fopen( fname.c_str(), "w");
+        if ( !f )
+                return -1;
+
+        auto sttm = _using_F().start_time();
+        char *asctime_ = asctime( localtime( &sttm));
+        fprintf( f, "PSD profile of\n"
+                 "## Subject: %s;  Session: %s, Episode: %s recorded %.*s;  Channel: %s\n"
+                 "## Course (%zu %g-sec pages, step %g) in range %g-%g Hz\n",
+                 _using_F().subject().name.c_str(), _using_F().session(), _using_F().episode(),
+                 (int)strlen(asctime_)-1, asctime_,
+                 _using_F().channel_by_id(_using_sig_no).name(),
+                 steps(), Pp.pagesize, Pp.step, from, upto);
+
+        valarray<TFloat> crs = course( from, upto);
+        for ( size_t p = 0; p < steps(); ++p )
+                fprintf( f, "%zu\t%g\n", p, crs[p]);
+
+        fclose( f);
+        return 0;
 }
 
 
diff --git a/upstream/src/libmetrics/psd.hh b/upstream/src/libmetrics/psd.hh
index 5a22619..9331970 100644
--- a/upstream/src/libmetrics/psd.hh
+++ b/upstream/src/libmetrics/psd.hh
@@ -34,95 +34,95 @@ namespace psd {
 
 
 enum TFFTWPlanType {
-	estimate,
-	measure,
-	TFFTWPlanType_total
+        estimate,
+        measure,
+        TFFTWPlanType_total
 };
 
 inline int
 plan_flags( TFFTWPlanType t)
 {
-	switch ( t ) {
-	case TFFTWPlanType::estimate:
-		return 0|FFTW_ESTIMATE;
-	case TFFTWPlanType::measure:
-		return 0|FFTW_MEASURE;
-	default:
-		return 0;
-	}
+        switch ( t ) {
+        case TFFTWPlanType::estimate:
+                return 0|FFTW_ESTIMATE;
+        case TFFTWPlanType::measure:
+                return 0|FFTW_MEASURE;
+        default:
+                return 0;
+        }
 }
 
 inline TFFTWPlanType
 plan_type( int f)
 {
-	// this is oversimplified
-	if ( f & FFTW_MEASURE )
-		return TFFTWPlanType::measure;
-	if ( f & FFTW_ESTIMATE )
-		return TFFTWPlanType::estimate;
-	return (TFFTWPlanType)0;
+        // this is oversimplified
+        if ( f & FFTW_MEASURE )
+                return TFFTWPlanType::measure;
+        if ( f & FFTW_ESTIMATE )
+                return TFFTWPlanType::estimate;
+        return (TFFTWPlanType)0;
 }
 
 struct SPPack
   : public metrics::SPPack {
-	double	binsize;
-	static sigproc::TWinType
-		welch_window_type;
-	static TFFTWPlanType
-		plan_type;
-
-	SPPack ()
-		{
-			reset();
-		}
-
-	bool same_as( const SPPack& rv) const
-		{
-			return metrics::SPPack::same_as(rv);
-		}
-	void make_same( const SPPack& rv)
-		{
-			metrics::SPPack::make_same(rv);
-		}
-
-	size_t
-	compute_n_bins( size_t samplerate) const
-		{
-			return (samplerate * pagesize + 1) / 2 / samplerate / binsize;
-		}
-
-	void check() const
-		{
-			metrics::SPPack::check();
-
-			if ( welch_window_type > sigproc::TWinType::TWinType_total )
+        double        binsize;
+        static sigproc::TWinType
+                welch_window_type;
+        static TFFTWPlanType
+                plan_type;
+
+        SPPack ()
+                {
+                        reset();
+                }
+
+        bool same_as( const SPPack& rv) const
+                {
+                        return metrics::SPPack::same_as(rv);
+                }
+        void make_same( const SPPack& rv)
+                {
+                        metrics::SPPack::make_same(rv);
+                }
+
+        size_t
+        compute_n_bins( size_t samplerate) const
+                {
+                        return (samplerate * pagesize + 1) / 2 / samplerate / binsize;
+                }
+
+        void check() const
+                {
+                        metrics::SPPack::check();
+
+                        if ( welch_window_type > sigproc::TWinType::TWinType_total )
 #ifdef _OPENMP
 #pragma omp single
 #endif
-				throw invalid_argument ("Invalid window type");
+                                throw invalid_argument ("Invalid window type");
 
-			if ( plan_type != metrics::psd::TFFTWPlanType::estimate &&
-			     plan_type != metrics::psd::TFFTWPlanType::measure )
+                        if ( plan_type != metrics::psd::TFFTWPlanType::estimate &&
+                             plan_type != metrics::psd::TFFTWPlanType::measure )
 #ifdef _OPENMP
 #pragma omp single
 #endif
-				throw invalid_argument ("Invalid FFTW plan type");
+                                throw invalid_argument ("Invalid FFTW plan type");
 
-			for ( auto c : {.1, .25, .5} )
-				if ( binsize == c )
-					return;
+                        for ( auto c : {.1, .25, .5} )
+                                if ( binsize == c )
+                                        return;
 
 #ifdef _OPENMP
 #pragma omp single
 #endif
-			throw invalid_argument ("Invalid binsize");
-		}
-
-	void reset()
-		{
-			metrics::SPPack::reset();
-			binsize = .25;
-		}
+                        throw invalid_argument ("Invalid binsize");
+                }
+
+        void reset()
+                {
+                        metrics::SPPack::reset();
+                        binsize = .25;
+                }
 };
 
 
@@ -133,40 +133,40 @@ class CProfile
   : public metrics::CProfile {
 
     public:
-	CProfile (const sigfile::CTypedSource&, int sig_no,
-		  const SPPack&);
-
-	SPPack Pp;
-
-	const char* metric_name() const
-		{
-			return metrics::name( TType::psd);
-		}
-
-	// in a frequency range
-	valarray<TFloat> course( double from, double upto) const
-		{
-			valarray<TFloat> acc (0., steps());
-			size_t	bin_a = min( (size_t)(from / Pp.binsize), _bins),
-				bin_z = min( (size_t)(upto / Pp.binsize), _bins);
-			for ( size_t b = bin_a; b < bin_z; ++b )
-				acc += metrics::CProfile::course(b);
-			return acc;
-		}
-
-	int go_compute();
-	string mirror_fname() const;
-
-	string fname_base() const;
-
-	int export_tsv( const string&) const;
-	int export_tsv( float, float,
-			const string&) const;
-
-	// to enable use as mapped type
-	CProfile (const CProfile& rv)
-	      : metrics::CProfile (rv)
-		{}
+        CProfile (const sigfile::CTypedSource&, int sig_no,
+                  const SPPack&);
+
+        SPPack Pp;
+
+        const char* metric_name() const
+                {
+                        return metrics::name( TType::psd);
+                }
+
+        // in a frequency range
+        valarray<TFloat> course( double from, double upto) const
+                {
+                        valarray<TFloat> acc (0., steps());
+                        size_t        bin_a = min( (size_t)(from / Pp.binsize), _bins),
+                                bin_z = min( (size_t)(upto / Pp.binsize), _bins);
+                        for ( size_t b = bin_a; b < bin_z; ++b )
+                                acc += metrics::CProfile::course(b);
+                        return acc;
+                }
+
+        int go_compute();
+        string mirror_fname() const;
+
+        string fname_base() const;
+
+        int export_tsv( const string&) const;
+        int export_tsv( float, float,
+                        const string&) const;
+
+        // to enable use as mapped type
+        CProfile (const CProfile& rv)
+              : metrics::CProfile (rv)
+                {}
 };
 
 } // namespace psd
diff --git a/upstream/src/libmetrics/swu.cc b/upstream/src/libmetrics/swu.cc
index 6fc10fd..874ffa4 100644
--- a/upstream/src/libmetrics/swu.cc
+++ b/upstream/src/libmetrics/swu.cc
@@ -24,13 +24,13 @@ using namespace std;
 
 metrics::swu::CProfile::
 CProfile (const sigfile::CTypedSource& F, const int sig_no,
-	  const SPPack &params)
+          const SPPack &params)
       : metrics::CProfile (F, sig_no,
-			   params.pagesize, params.step,
-			   params.compute_n_bins(F().samplerate(sig_no))),
-	Pp (params)
+                           params.pagesize, params.step,
+                           params.compute_n_bins(F().samplerate(sig_no))),
+        Pp (params)
 {
-	Pp.check();
+        Pp.check();
 }
 
 
@@ -39,12 +39,12 @@ string
 metrics::swu::CProfile::
 fname_base() const
 {
-	return agh::str::sasprintf(
-		  "%s.%s-%lu"
-		  ":%g+%g-%g",
-		  _using_F().filename(), _using_F().channel_by_id(_using_sig_no).name(),
-		  _using_F().dirty_signature( _using_sig_no),
-		  Pp.pagesize, Pp.step, Pp.min_upswing_duration);
+        return agh::str::sasprintf(
+                  "%s.%s-%lu"
+                  ":%g+%g-%g",
+                  _using_F().filename(), _using_F().channel_by_id(_using_sig_no).name(),
+                  _using_F().dirty_signature( _using_sig_no),
+                  Pp.pagesize, Pp.step, Pp.min_upswing_duration);
 }
 
 
@@ -52,15 +52,15 @@ string
 metrics::swu::CProfile::
 mirror_fname() const
 {
-	return agh::str::sasprintf(
-		  "%s.%s-%lu"
-		  ":%g+%g-%g@%zu"
-		  ".swu",
-		  agh::fs::make_fname_base (_using_F().filename(), "", agh::fs::TMakeFnameOption::hidden).c_str(),
-		  _using_F().channel_by_id(_using_sig_no).name(),
-		  _using_F().dirty_signature( _using_sig_no),
-		  Pp.pagesize, Pp.step, Pp.min_upswing_duration,
-		  sizeof(TFloat));
+        return agh::str::sasprintf(
+                  "%s.%s-%lu"
+                  ":%g+%g-%g@%zu"
+                  ".swu",
+                  agh::fs::make_fname_base (_using_F().filename(), "", agh::fs::TMakeFnameOption::hidden).c_str(),
+                  _using_F().channel_by_id(_using_sig_no).name(),
+                  _using_F().dirty_signature( _using_sig_no),
+                  Pp.pagesize, Pp.step, Pp.min_upswing_duration,
+                  sizeof(TFloat));
 }
 
 
@@ -68,42 +68,42 @@ int
 metrics::swu::CProfile::
 go_compute()
 {
-	_data.resize( steps() * _bins);
-
-	auto dS = sigproc::derivative(
-		_using_F().get_signal_filtered( _using_sig_no));
-
-	for ( size_t p = 0; p < steps(); ++p ) {
-		auto	a = p * (samplerate() * Pp.step),
-			z = a + (samplerate() * Pp.pagesize);
-		auto	la = a, lz = a;
-		double	Q = 0.;
-
-	      // 1. upswing proper
-		// find a stretch of uninterrupted positive values
-		for ( auto i = a; i < z; ++i ) {
-			double q = 0.;
-			auto j = i;
-			while ( dS[j] > 0 ) {
-				q += dS[j];
-				if ( not (j < z) )
-					break;
-				++j;
-			}
-			la = i; lz = j;
-			double upswing_duration = (lz - la) * samplerate();
-			if ( upswing_duration > Pp.min_upswing_duration )
-				Q += q;
-		}
-	      // 2. clean peaks
-		
-
-		nmth_bin(p, 0) =
-			Q / Pp.pagesize;
-	}
-
-
-	return 0;
+        _data.resize( steps() * _bins);
+
+        auto dS = sigproc::derivative(
+                _using_F().get_signal_filtered( _using_sig_no));
+
+        for ( size_t p = 0; p < steps(); ++p ) {
+                auto        a = p * (samplerate() * Pp.step),
+                        z = a + (samplerate() * Pp.pagesize);
+                auto        la = a, lz = a;
+                double        Q = 0.;
+
+              // 1. upswing proper
+                // find a stretch of uninterrupted positive values
+                for ( auto i = a; i < z; ++i ) {
+                        double q = 0.;
+                        auto j = i;
+                        while ( dS[j] > 0 ) {
+                                q += dS[j];
+                                if ( not (j < z) )
+                                        break;
+                                ++j;
+                        }
+                        la = i; lz = j;
+                        double upswing_duration = (lz - la) * samplerate();
+                        if ( upswing_duration > Pp.min_upswing_duration )
+                                Q += q;
+                }
+              // 2. clean peaks
+                
+
+                nmth_bin(p, 0) =
+                        Q / Pp.pagesize;
+        }
+
+
+        return 0;
 }
 
 
@@ -118,25 +118,25 @@ int
 metrics::swu::CProfile::
 export_tsv( const string& fname) const
 {
-	FILE *f = fopen( fname.c_str(), "w");
-	if ( !f )
-		return -1;
-
-	auto sttm = _using_F().start_time();
-	char *asctime_ = asctime( localtime( &sttm));
-	fprintf( f, "## Subject: %s;  Session: %s, Episode: %s recorded %.*s;  Channel: %s\n"
-		 "## SWU course (%zu %g-sec pages, step %g sec)\n"
-		 "#Page\tSWU\n",
-		 _using_F().subject().name.c_str(), _using_F().session(), _using_F().episode(),
-		 (int)strlen(asctime_)-1, asctime_,
-		 _using_F().channel_by_id(_using_sig_no).name(),
-		 steps(), Pp.pagesize, Pp.step);
-
-	for ( size_t p = 0; p < steps(); ++p )
-		fprintf( f, "%zu\t%g\n", p, nmth_bin( p, 0));
-
-	fclose( f);
-	return 0;
+        FILE *f = fopen( fname.c_str(), "w");
+        if ( !f )
+                return -1;
+
+        auto sttm = _using_F().start_time();
+        char *asctime_ = asctime( localtime( &sttm));
+        fprintf( f, "## Subject: %s;  Session: %s, Episode: %s recorded %.*s;  Channel: %s\n"
+                 "## SWU course (%zu %g-sec pages, step %g sec)\n"
+                 "#Page\tSWU\n",
+                 _using_F().subject().name.c_str(), _using_F().session(), _using_F().episode(),
+                 (int)strlen(asctime_)-1, asctime_,
+                 _using_F().channel_by_id(_using_sig_no).name(),
+                 steps(), Pp.pagesize, Pp.step);
+
+        for ( size_t p = 0; p < steps(); ++p )
+                fprintf( f, "%zu\t%g\n", p, nmth_bin( p, 0));
+
+        fclose( f);
+        return 0;
 }
 
 
diff --git a/upstream/src/libmetrics/swu.hh b/upstream/src/libmetrics/swu.hh
index 0570bf7..81713f6 100644
--- a/upstream/src/libmetrics/swu.hh
+++ b/upstream/src/libmetrics/swu.hh
@@ -33,28 +33,28 @@ namespace swu {
 struct SPPack
   : public metrics::SPPack {
 
-	double	min_upswing_duration;
-
-	SPPack ()
-		{
-			reset();
-		}
-	size_t
-	compute_n_bins( size_t) const
-		{
-			return 1;
-		}
-
-	void check() const  // throws if not ok
-		{
-			metrics::SPPack::check();
-		}
-
-	void reset()
-		{
-			metrics::SPPack::reset();
-			min_upswing_duration = .3;
-		}
+        double        min_upswing_duration;
+
+        SPPack ()
+                {
+                        reset();
+                }
+        size_t
+        compute_n_bins( size_t) const
+                {
+                        return 1;
+                }
+
+        void check() const  // throws if not ok
+                {
+                        metrics::SPPack::check();
+                }
+
+        void reset()
+                {
+                        metrics::SPPack::reset();
+                        min_upswing_duration = .3;
+                }
 };
 
 
@@ -63,35 +63,35 @@ class CProfile
   : public metrics::CProfile {
 
     public:
-	CProfile (const sigfile::CTypedSource&, int sig_no,
-		  const SPPack&);
+        CProfile (const sigfile::CTypedSource&, int sig_no,
+                  const SPPack&);
 
-	SPPack Pp;
+        SPPack Pp;
 
-	const char* metric_name() const
-		{
-			return metrics::name( TType::swu);
-		}
+        const char* metric_name() const
+                {
+                        return metrics::name( TType::swu);
+                }
 
-	valarray<TFloat> course( double) const
-		{
-			size_t	bin = 0; // (size_t)(binf - freq_from / Pp.freq_inc);
-			return metrics::CProfile::course(bin);
-		}
+        valarray<TFloat> course( double) const
+                {
+                        size_t        bin = 0; // (size_t)(binf - freq_from / Pp.freq_inc);
+                        return metrics::CProfile::course(bin);
+                }
 
-	int go_compute();
+        int go_compute();
 
-	string fname_base() const;
-	string mirror_fname() const;
+        string fname_base() const;
+        string mirror_fname() const;
 
-	int export_tsv( const string&) const;
-	int export_tsv( float, float,
-			const string&) const;
+        int export_tsv( const string&) const;
+        int export_tsv( float, float,
+                        const string&) const;
 
-	// to enable use as mapped type
-	CProfile (const CProfile& rv)
-	      : metrics::CProfile (rv)
-		{}
+        // to enable use as mapped type
+        CProfile (const CProfile& rv)
+              : metrics::CProfile (rv)
+                {}
 };
 
 } // namespace swu
diff --git a/upstream/src/libsigfile/channel.cc b/upstream/src/libsigfile/channel.cc
index 7e8b21a..d3c853d 100644
--- a/upstream/src/libsigfile/channel.cc
+++ b/upstream/src/libsigfile/channel.cc
@@ -20,55 +20,55 @@ using namespace std;
 using sigfile::SChannel;
 
 const char* sigfile::edf_annotations_label =
-	"EDF Annotations";
+        "EDF Annotations";
 
 
 namespace {
 
 const map<SChannel::TType, vector<const char*>> _CT_ = {
-	{SChannel::TType::eeg,
-	 {"(custom)",	  // counted 'em all!
-	  "Nz",
-	  "Fp1", "Fpz", "Fp2",
-	  "AF7", "AF3", "AFz", "AF4", "AF8",
-	  "F9",  "F7", "F5", "F3", "F1", "Fz", "F2", "F4", "F6", "F8", "F10",
-	  "FT9", "FT7", "FC5", "FC3", "FC1", "FCz", "FC2", "FC4", "FC6", "FCT8", "FT10",
-	  "A1", "T9", "T7", "C5", "C3", "C1", "Cz", "C2", "C4", "C6", "T8", "T10", "A2",
-	  "TP9", "TP7", "CP5", "CP3", "CP1", "CPz", "CP2", "CP4", "CP6", "TP8", "TP10",
-	  "P9", "P7", "P5", "P3", "P1", "Pz", "P2", "P4", "P6", "P8", "P10",
-	  "PO7", "PO3", "POz", "PO4", "PO8",
-	  "O1", "Oz", "O2",
-	  "Iz",}
-	},
-	{SChannel::TType::eog,
-	 {"(invalid)",
-	  "Left", "Right",}
-	},
-	{SChannel::TType::emg,
-	 {"(invalid)",
-	  "Chin",}
-	},
+        {SChannel::TType::eeg,
+         {"(custom)",          // counted 'em all!
+          "Nz",
+          "Fp1", "Fpz", "Fp2",
+          "AF7", "AF3", "AFz", "AF4", "AF8",
+          "F9",  "F7", "F5", "F3", "F1", "Fz", "F2", "F4", "F6", "F8", "F10",
+          "FT9", "FT7", "FC5", "FC3", "FC1", "FCz", "FC2", "FC4", "FC6", "FCT8", "FT10",
+          "A1", "T9", "T7", "C5", "C3", "C1", "Cz", "C2", "C4", "C6", "T8", "T10", "A2",
+          "TP9", "TP7", "CP5", "CP3", "CP1", "CPz", "CP2", "CP4", "CP6", "TP8", "TP10",
+          "P9", "P7", "P5", "P3", "P1", "Pz", "P2", "P4", "P6", "P8", "P10",
+          "PO7", "PO3", "POz", "PO4", "PO8",
+          "O1", "Oz", "O2",
+          "Iz",}
+        },
+        {SChannel::TType::eog,
+         {"(invalid)",
+          "Left", "Right",}
+        },
+        {SChannel::TType::emg,
+         {"(invalid)",
+          "Chin",}
+        },
 };
 
 const map<SChannel::TType, const char*> _ST_ = {
-	{SChannel::TType::embedded_annotation, sigfile::edf_annotations_label},
-	{SChannel::TType::eeg, "EEG"},
-	{SChannel::TType::eog, "EOG"},
-	{SChannel::TType::emg, "EMG"},
-	{SChannel::TType::ecg, "ECG"},
-	{SChannel::TType::erg, "ERG"},
-	{SChannel::TType::nc , "NC" },
-	{SChannel::TType::meg, "MEG"},
-	{SChannel::TType::mcg, "MCG"},
-	{SChannel::TType::ep , "EP" },
-	{SChannel::TType::temp, "Temp"},
-	{SChannel::TType::resp, "Resp"},
-	{SChannel::TType::sao2, "SaO2"},
-	{SChannel::TType::light, "Light"},
-	{SChannel::TType::sound, "Sound"},
-	{SChannel::TType::event, "Event"},
-	{SChannel::TType::freq, "Freq"},
-	{SChannel::TType::other, "(other)"},
+        {SChannel::TType::embedded_annotation, sigfile::edf_annotations_label},
+        {SChannel::TType::eeg, "EEG"},
+        {SChannel::TType::eog, "EOG"},
+        {SChannel::TType::emg, "EMG"},
+        {SChannel::TType::ecg, "ECG"},
+        {SChannel::TType::erg, "ERG"},
+        {SChannel::TType::nc , "NC" },
+        {SChannel::TType::meg, "MEG"},
+        {SChannel::TType::mcg, "MCG"},
+        {SChannel::TType::ep , "EP" },
+        {SChannel::TType::temp, "Temp"},
+        {SChannel::TType::resp, "Resp"},
+        {SChannel::TType::sao2, "SaO2"},
+        {SChannel::TType::light, "Light"},
+        {SChannel::TType::sound, "Sound"},
+        {SChannel::TType::event, "Event"},
+        {SChannel::TType::freq, "Freq"},
+        {SChannel::TType::other, "(other)"},
 };
 
 } // anonymous namespace
@@ -78,7 +78,7 @@ const char*
 SChannel::
 type_s( SChannel::TType t)
 {
-	return _ST_.at(t);
+        return _ST_.at(t);
 }
 
 
@@ -87,7 +87,7 @@ const char*
 SChannel::
 channel_s( int idx)
 {
-	return _CT_.at(t)[idx];
+        return _CT_.at(t)[idx];
 }
 
 namespace sigfile {
@@ -96,7 +96,7 @@ const char*
 SChannel::
 channel_s<SChannel::TType::invalid>(int)
 {
-	return "(invalid)";
+        return "(invalid)";
 }
 }
 
@@ -112,30 +112,30 @@ tuple<SChannel::TType, int>
 SChannel::
 figure_type_and_name( const string& h_)
 {
-	auto tt = agh::str::tokens( h_, "-");
-	if ( tt.size() == 2 ) {
-		for ( auto& T : _CT_ )
-			if ( all_of( tt.begin(), tt.end(),
-				     [&]( const string& t)
-				     {
-					     return any_of( T.second.begin(), T.second.end(),
-							    [&]( const string& h)
-							    {
-								    return 0 == strcasecmp( h.c_str(), t.c_str());
-							    });
-				     }) )
-				return make_tuple(T.first, 0); // always custom, because it's a compound (EEG) channel like Fpz-Oz
-		return make_tuple(TType::other, 0);
-
-	} else if ( tt.size() == 1 ) {
-		for ( auto& T : _CT_ )
-			for ( size_t i = 0; i < T.second.size(); ++i )
-				if ( strcasecmp( T.second[i], h_.c_str()) == 0 ) {
-					return make_tuple(T.first, (int)i);
-				}
-	}
-
-	return make_tuple(TType::other, 0);
+        auto tt = agh::str::tokens( h_, "-");
+        if ( tt.size() == 2 ) {
+                for ( auto& T : _CT_ )
+                        if ( all_of( tt.begin(), tt.end(),
+                                     [&]( const string& t)
+                                     {
+                                             return any_of( T.second.begin(), T.second.end(),
+                                                            [&]( const string& h)
+                                                            {
+                                                                    return 0 == strcasecmp( h.c_str(), t.c_str());
+                                                            });
+                                     }) )
+                                return make_tuple(T.first, 0); // always custom, because it's a compound (EEG) channel like Fpz-Oz
+                return make_tuple(TType::other, 0);
+
+        } else if ( tt.size() == 1 ) {
+                for ( auto& T : _CT_ )
+                        for ( size_t i = 0; i < T.second.size(); ++i )
+                                if ( strcasecmp( T.second[i], h_.c_str()) == 0 ) {
+                                        return make_tuple(T.first, (int)i);
+                                }
+        }
+
+        return make_tuple(TType::other, 0);
 }
 
 
diff --git a/upstream/src/libsigfile/channel.hh b/upstream/src/libsigfile/channel.hh
index 19636e8..1905746 100644
--- a/upstream/src/libsigfile/channel.hh
+++ b/upstream/src/libsigfile/channel.hh
@@ -30,62 +30,62 @@ namespace sigfile {
 // we want scoped enums with basic arith support, so:
 namespace EEG {
 enum E : int {
-	invalid = -1,
-	custom = 0,
-	first,
-
-	Nz = first,
-	Fp1, Fpz, Fp2,
-	AF7, AF3, AFz, AF4, AF8,
-	F9,  F7, F5, F3, F1, Fz, F2, F4, F6, F8, F10,
-	FT9, FT7, FC5, FC3, FC1, FCz, FC2, FC4, FC6, FCT8, FT10,
-	A1, T9, T7, C5, C3, C1, Cz, C2, C4, C6, T8, T10, A2,
-	TP9, TP7, CP5, CP3, CP1, CPz, CP2, CP4, CP6, TP8, TP10,
-	P9, P7, P5, P3, P1, Pz, P2, P4, P6, P8, P10,
-	PO7, PO3, POz, PO4, PO8,
-	O1, Oz, O2,
-	Iz,
-
-	last = Iz,
-	total
+        invalid = -1,
+        custom = 0,
+        first,
+
+        Nz = first,
+        Fp1, Fpz, Fp2,
+        AF7, AF3, AFz, AF4, AF8,
+        F9,  F7, F5, F3, F1, Fz, F2, F4, F6, F8, F10,
+        FT9, FT7, FC5, FC3, FC1, FCz, FC2, FC4, FC6, FCT8, FT10,
+        A1, T9, T7, C5, C3, C1, Cz, C2, C4, C6, T8, T10, A2,
+        TP9, TP7, CP5, CP3, CP1, CPz, CP2, CP4, CP6, TP8, TP10,
+        P9, P7, P5, P3, P1, Pz, P2, P4, P6, P8, P10,
+        PO7, PO3, POz, PO4, PO8,
+        O1, Oz, O2,
+        Iz,
+
+        last = Iz,
+        total
 };
 }
 
 namespace EOG {
 enum E : int {
-	invalid = -1,
-	custom = 0,
-	first,
-	left = first, right,
-	last = right,
-	total
+        invalid = -1,
+        custom = 0,
+        first,
+        left = first, right,
+        last = right,
+        total
 };
 }
 
 namespace EMG {
 enum E : int {
-	invalid = -1,
-	custom = 0,
-	first,
-	chin = first,
-	last = chin,
-	total
+        invalid = -1,
+        custom = 0,
+        first,
+        chin = first,
+        last = chin,
+        total
 };
 }
 
 namespace ECG {
 enum E : int {
-	invalid = -1,
-	custom = 0,
-	total
+        invalid = -1,
+        custom = 0,
+        total
 };
 }
 
 namespace ERG {
 enum E : int {
-	invalid = -1,
-	custom = 0,
-	total
+        invalid = -1,
+        custom = 0,
+        total
 };
 }
 // moar types ...
@@ -96,121 +96,121 @@ extern const char* edf_annotations_label;
 
 struct SChannel {
 
-	enum class TType {
-		invalid,
-		embedded_annotation,
-		eeg, eog, emg, ecg, erg,
-		nc, meg, mcg, ep, temp, resp, sao2, light, sound, event, freq,
-		other
-	};
+        enum class TType {
+                invalid,
+                embedded_annotation,
+                eeg, eog, emg, ecg, erg,
+                nc, meg, mcg, ep, temp, resp, sao2, light, sound, event, freq,
+                other
+        };
 
-	static const char* type_s( TType t);
+        static const char* type_s( TType t);
 
-	template <TType T>
-	static const char* channel_s( int);
+        template <TType T>
+        static const char* channel_s( int);
 
-	static tuple<TType, int> figure_type_and_name( const string&);
+        static tuple<TType, int> figure_type_and_name( const string&);
 
-	static bool is_fftable( TType type)
-		{
-			return type == TType::eeg;
-		}
+        static bool is_fftable( TType type)
+                {
+                        return type == TType::eeg;
+                }
 
       // ctor
-	SChannel (const string& h)
-		{
-			tie(_type, _idx) = figure_type_and_name(h);
-			if ( _idx == 0 )
-				_custom_name = h;
-		}
-
-	SChannel (TType type_, int idx_)
-	      : _type (type_),
-		_idx (idx_)
-		{}
-	SChannel (TType type_, const string& custom_name_)
-	      : _type (type_),
-		_idx (0),
-		_custom_name (custom_name_)
-		{}
-	SChannel () = default;
-
-	TType type() const
-		{ return _type; }
-	const char* type_s() const
-		{ return type_s(_type); }
-
-	const char* name() const
-		{
-			if ( _custom_name.empty() )
-				switch ( _type ) {
-				case TType::eeg: return channel_s<TType::eeg>( _idx);
-				case TType::eog: return channel_s<TType::eog>( _idx);
-				case TType::emg: return channel_s<TType::emg>( _idx);
-				case TType::ecg: return channel_s<TType::ecg>( _idx);
-				case TType::erg: return channel_s<TType::erg>( _idx);
-				default: return "(unknown)";
-				}
-			else
-				return _custom_name.c_str();
-		}
-	const char* c_str() const
-		{ return name(); }
-	int idx() const
-		{ return _idx; }
-
-	bool is_fftable() const
-		{
-			return is_fftable( _type);
-		}
+        SChannel (const string& h)
+                {
+                        tie(_type, _idx) = figure_type_and_name(h);
+                        if ( _idx == 0 )
+                                _custom_name = h;
+                }
+
+        SChannel (TType type_, int idx_)
+              : _type (type_),
+                _idx (idx_)
+                {}
+        SChannel (TType type_, const string& custom_name_)
+              : _type (type_),
+                _idx (0),
+                _custom_name (custom_name_)
+                {}
+        SChannel () = default;
+
+        TType type() const
+                { return _type; }
+        const char* type_s() const
+                { return type_s(_type); }
+
+        const char* name() const
+                {
+                        if ( _custom_name.empty() )
+                                switch ( _type ) {
+                                case TType::eeg: return channel_s<TType::eeg>( _idx);
+                                case TType::eog: return channel_s<TType::eog>( _idx);
+                                case TType::emg: return channel_s<TType::emg>( _idx);
+                                case TType::ecg: return channel_s<TType::ecg>( _idx);
+                                case TType::erg: return channel_s<TType::erg>( _idx);
+                                default: return "(unknown)";
+                                }
+                        else
+                                return _custom_name.c_str();
+                }
+        const char* c_str() const
+                { return name(); }
+        int idx() const
+                { return _idx; }
+
+        bool is_fftable() const
+                {
+                        return is_fftable( _type);
+                }
     private:
-	TType	_type;
-	int	_idx;
-	string	_custom_name;
+        TType        _type;
+        int        _idx;
+        string        _custom_name;
 
     public:
-	// compares by channel actual locations, antero-posteriorly
-	bool operator<( const SChannel& rv) const
-		{
-			if ( _type == rv._type ) {
-				if ( _idx > 0 && rv._idx > 0 )
-					return _idx < rv._idx;
-				else if ( _idx > 0 )
-					return true;
-				else
-					return _custom_name < rv._custom_name;
-			} else
-				return _type < rv._type;
-		}
-	bool operator==( const SChannel& rv) const
-		{
-			return _type == rv._type && _idx == rv._idx;
-		}
-	bool operator==( const char* rv) const
-		{
-			return 0 == strcasecmp( name(), rv);
-		}
-
-	// void operator=( const SChannel& rv)
-	// 	{
-	// 		_type = rv._type;
-	// 		_idx = rv._idx;
-	// 		_custom_name = rv._custom_name;
-	// 	}
+        // compares by channel actual locations, antero-posteriorly
+        bool operator<( const SChannel& rv) const
+                {
+                        if ( _type == rv._type ) {
+                                if ( _idx > 0 && rv._idx > 0 )
+                                        return _idx < rv._idx;
+                                else if ( _idx > 0 )
+                                        return true;
+                                else
+                                        return _custom_name < rv._custom_name;
+                        } else
+                                return _type < rv._type;
+                }
+        bool operator==( const SChannel& rv) const
+                {
+                        return _type == rv._type && _idx == rv._idx;
+                }
+        bool operator==( const char* rv) const
+                {
+                        return 0 == strcasecmp( name(), rv);
+                }
+
+        // void operator=( const SChannel& rv)
+        //         {
+        //                 _type = rv._type;
+        //                 _idx = rv._idx;
+        //                 _custom_name = rv._custom_name;
+        //         }
 };
 
 template <typename C>
 string
 join_channel_names( const C& l, const char* sep)
 {
-	if ( l.empty() )
-		return "";
-	ostringstream recv;
-	auto I = l.begin();
-	for ( ; next(I) != l.end(); ++I )
-		recv << I->name() << sep;
-	recv << I->name();
-	return recv.str();
+        if ( l.empty() )
+                return "";
+        ostringstream recv;
+        auto I = l.begin();
+        for ( ; next(I) != l.end(); ++I )
+                recv << I->name() << sep;
+        recv << I->name();
+        return recv.str();
 }
 
 
diff --git a/upstream/src/libsigfile/edf-io.cc b/upstream/src/libsigfile/edf-io.cc
index 1b0eb19..1d98909 100644
--- a/upstream/src/libsigfile/edf-io.cc
+++ b/upstream/src/libsigfile/edf-io.cc
@@ -18,47 +18,47 @@ using sigfile::CEDFFile;
 valarray<TFloat>
 CEDFFile::
 get_region_original_smpl( const int h,
-			  const size_t sa, const size_t sz) const
+                          const size_t sa, const size_t sz) const
 {
-	if ( unlikely (_status & (CSource::TStatus::bad_header | TStatus::bad_version)) )
-		throw invalid_argument ("CEDFFile::get_region_original(): broken source");
-	if ( unlikely (_mmapping == NULL) )
-		throw invalid_argument ("CEDFFile::get_region_original(): no data");
-	if ( unlikely (sa >= sz || sz > samplerate(h) * recording_time()) )
-		throw range_error (agh::str::sasprintf(
-					   "CEDFFile::get_region_original(%s[%s]): bad region (req %zu:%zu, avail end %zu x %g sec = %g, or %zu x %zu = %zu)",
-					   filename(), operator[](h).ucd.name(),
-					   sa, sz, samplerate(h), recording_time(), samplerate(h) * recording_time(),
-					   n_data_records, operator[](h).samples_per_record, n_data_records * operator[](h).samples_per_record));
+        if ( unlikely (_status & (CSource::TStatus::bad_header | TStatus::bad_version)) )
+                throw invalid_argument ("CEDFFile::get_region_original(): broken source");
+        if ( unlikely (_mmapping == NULL) )
+                throw invalid_argument ("CEDFFile::get_region_original(): no data");
+        if ( unlikely (sa >= sz || sz > samplerate(h) * recording_time()) )
+                throw range_error (agh::str::sasprintf(
+                                           "CEDFFile::get_region_original(%s[%s]): bad region (req %zu:%zu, avail end %zu x %g sec = %g, or %zu x %zu = %zu)",
+                                           filename(), operator[](h).ucd.name(),
+                                           sa, sz, samplerate(h), recording_time(), samplerate(h) * recording_time(),
+                                           n_data_records, operator[](h).samples_per_record, n_data_records * operator[](h).samples_per_record));
 
-	valarray<TFloat> recp;
+        valarray<TFloat> recp;
 
-	const SSignal& H = operator[](h);
-	size_t	r0    =                        (   sa) / H.samples_per_record,
-		r_cnt = (size_t) ceilf( (float)(sz-sa) / H.samples_per_record);
+        const SSignal& H = operator[](h);
+        size_t        r0    =                        (   sa) / H.samples_per_record,
+                r_cnt = (size_t) ceilf( (float)(sz-sa) / H.samples_per_record);
 
-	int16_t* tmp;
-	tmp = (int16_t*)malloc( r_cnt * H.samples_per_record * 2);  // 2 is sizeof(sample) sensu edf
+        int16_t* tmp;
+        tmp = (int16_t*)malloc( r_cnt * H.samples_per_record * 2);  // 2 is sizeof(sample) sensu edf
 
-	while ( r_cnt-- )
-		memcpy( &tmp[ r_cnt * H.samples_per_record ],
+        while ( r_cnt-- )
+                memcpy( &tmp[ r_cnt * H.samples_per_record ],
 
-			(char*)_mmapping + header_length
-			+ (r0 + r_cnt) * _total_samples_per_record * 2	// full records before
-			+ H._at * 2,				// offset to our samples
+                        (char*)_mmapping + header_length
+                        + (r0 + r_cnt) * _total_samples_per_record * 2        // full records before
+                        + H._at * 2,                                // offset to our samples
 
-			H.samples_per_record * 2);	// our precious ones
+                        H.samples_per_record * 2);        // our precious ones
 
-	recp.resize( sz - sa);
+        recp.resize( sz - sa);
 
       // repackage for shipping, and scale
-	size_t sa_off = sa - r0 * H.samples_per_record;
-	for ( size_t s = 0; s < recp.size(); ++s )
-		recp[s] = tmp[sa_off + s] * H.scale;
+        size_t sa_off = sa - r0 * H.samples_per_record;
+        for ( size_t s = 0; s < recp.size(); ++s )
+                recp[s] = tmp[sa_off + s] * H.scale;
 
-	free( tmp);
+        free( tmp);
 
-	return move(recp);
+        return move(recp);
 }
 
 
@@ -68,48 +68,48 @@ get_region_original_smpl( const int h,
 int
 CEDFFile::
 put_region_smpl( const int h,
-		 const valarray<TFloat>& src,
-		 const size_t offset)
+                 const valarray<TFloat>& src,
+                 const size_t offset)
 {
-	if ( unlikely (_status & (CSource::TStatus::bad_header | TStatus::bad_version)) )
-		throw invalid_argument("CEDFFile::put_region_(): broken source");
-	if ( unlikely (offset >= samplerate(h) * recording_time()) )
-		throw range_error("CEDFFile::put_region_(): offset beyond end of file");
-	if ( unlikely (offset + src.size() > samplerate(h) * recording_time()) ) {
-		fprintf( stderr, "CEDFFile::put_region_(): attempt to write past end of file (%zu + %zu > %zu * %g)\n",
-			 offset, src.size(), samplerate(h), recording_time());
-		throw range_error("CEDFFile::put_region_(): attempt to write past end of file");
-	}
-
-	const SSignal& H = operator[](h);
-	size_t	r0    =                            offset  / H.samples_per_record,
-		r_cnt = (size_t) ceilf( (double)src.size() / H.samples_per_record);
-
-	valarray<int16_t> tmp (src.size());
-	for ( size_t i = 0; i < tmp.size(); ++i )
-		tmp[i] = // clamp
-			agh::alg::value_within(
-				(double)src[i] / H.scale, (double)INT16_MIN, (double)INT16_MAX);
-
-	size_t r;
-	for ( r = 0; r < r_cnt - 1; ++r ) // minus one
-		memcpy( (char*)_mmapping + header_length
-			+ (r0 + r) * _total_samples_per_record * 2	// full records before
-			+ H._at * 2,				// offset to our samples
-
-			&tmp[ r * H.samples_per_record ],
-
-			H.samples_per_record * 2);	// our precious ones
-	// last record is underfull
-	memcpy( (char*)_mmapping + header_length
-		+ (r0 + r) * _total_samples_per_record * 2
-		+ H._at * 2,
-
-		&tmp[ r * H.samples_per_record ],
-
-		(tmp.size() - r * H.samples_per_record) * 2);
-
-	return 0;
+        if ( unlikely (_status & (CSource::TStatus::bad_header | TStatus::bad_version)) )
+                throw invalid_argument("CEDFFile::put_region_(): broken source");
+        if ( unlikely (offset >= samplerate(h) * recording_time()) )
+                throw range_error("CEDFFile::put_region_(): offset beyond end of file");
+        if ( unlikely (offset + src.size() > samplerate(h) * recording_time()) ) {
+                fprintf( stderr, "CEDFFile::put_region_(): attempt to write past end of file (%zu + %zu > %zu * %g)\n",
+                         offset, src.size(), samplerate(h), recording_time());
+                throw range_error("CEDFFile::put_region_(): attempt to write past end of file");
+        }
+
+        const SSignal& H = operator[](h);
+        size_t        r0    =                            offset  / H.samples_per_record,
+                r_cnt = (size_t) ceilf( (double)src.size() / H.samples_per_record);
+
+        valarray<int16_t> tmp (src.size());
+        for ( size_t i = 0; i < tmp.size(); ++i )
+                tmp[i] = // clamp
+                        agh::alg::value_within(
+                                (double)src[i] / H.scale, (double)INT16_MIN, (double)INT16_MAX);
+
+        size_t r;
+        for ( r = 0; r < r_cnt - 1; ++r ) // minus one
+                memcpy( (char*)_mmapping + header_length
+                        + (r0 + r) * _total_samples_per_record * 2        // full records before
+                        + H._at * 2,                                // offset to our samples
+
+                        &tmp[ r * H.samples_per_record ],
+
+                        H.samples_per_record * 2);        // our precious ones
+        // last record is underfull
+        memcpy( (char*)_mmapping + header_length
+                + (r0 + r) * _total_samples_per_record * 2
+                + H._at * 2,
+
+                &tmp[ r * H.samples_per_record ],
+
+                (tmp.size() - r * H.samples_per_record) * 2);
+
+        return 0;
 }
 
 
diff --git a/upstream/src/libsigfile/edf.cc b/upstream/src/libsigfile/edf.cc
index e9c701c..1114d2a 100644
--- a/upstream/src/libsigfile/edf.cc
+++ b/upstream/src/libsigfile/edf.cc
@@ -41,61 +41,61 @@ int
 CEDFFile::
 set_patient_id( const string& s)
 {
-	memcpy( header.patient_id, pad( s, 80).c_str(), 80);
-	_patient_id = s;
-	return s.size() > 80;
+        memcpy( header.patient_id, pad( s, 80).c_str(), 80);
+        _patient_id = s;
+        return s.size() > 80;
 }
 
 int
 CEDFFile::
 set_recording_id( const string& s)
 {
-	memcpy( header.recording_id, pad( s, 80).c_str(), 80);
-	_recording_id = s;
-	// maybe let _session and _episode be assigned, too?
-	return s.size() > 80;
+        memcpy( header.recording_id, pad( s, 80).c_str(), 80);
+        _recording_id = s;
+        // maybe let _session and _episode be assigned, too?
+        return s.size() > 80;
 }
 
 int
 CEDFFile::
 set_episode( const string& s)
 {
-	_episode.assign( s);
-	// aha
-	return set_recording_id( (_session + '/' + _episode).c_str());
+        _episode.assign( s);
+        // aha
+        return set_recording_id( (_session + '/' + _episode).c_str());
 }
 
 int
 CEDFFile::
 set_session( const string& s)
 {
-	_session.assign( s);
-	return set_recording_id( (_session + '/' + _episode).c_str());
+        _session.assign( s);
+        return set_recording_id( (_session + '/' + _episode).c_str());
 }
 
 int
 CEDFFile::
 set_reserved( const string& s)
 {
-	fprintf( stderr, "You just voided your warranty: Writing to \"reserved\" field in EDF header:\n%s\n", s.c_str());
-	_recording_id = s;
-	memcpy( header.reserved, pad( s, 44).c_str(), 44);
-	return s.size() > 44;
+        fprintf( stderr, "You just voided your warranty: Writing to \"reserved\" field in EDF header:\n%s\n", s.c_str());
+        _recording_id = s;
+        memcpy( header.reserved, pad( s, 44).c_str(), 44);
+        return s.size() > 44;
 }
 
 int
 CEDFFile::
 set_recording_date( const string& s)
 {
-	memcpy( header.recording_date, s.c_str(), 8);
-	return 0;
+        memcpy( header.recording_date, s.c_str(), 8);
+        return 0;
 }
 int
 CEDFFile::
 set_recording_time( const string& s)
 {
-	memcpy( header.recording_time, s.c_str(), 8);
-	return 0;
+        memcpy( header.recording_time, s.c_str(), 8);
+        return 0;
 }
 
 
@@ -121,64 +121,64 @@ CEDFFile::
 CEDFFile (const string& fname_, const int flags_)
       : CSource (fname_, flags_)
 {
-	{
-		struct stat stat0;
-		int stst = stat( fname_.c_str(), &stat0);
-		if ( stst == -1 )
-			throw invalid_argument (explain_status(_status |= CSource::TStatus::sysfail));
-		_fsize = stat0.st_size;
-	}
-	_fd = open( fname_.c_str(), O_RDWR);
-	if ( _fd == -1 )
-		throw invalid_argument (explain_status(_status |= sysfail));
+        {
+                struct stat stat0;
+                int stst = stat( fname_.c_str(), &stat0);
+                if ( stst == -1 )
+                        throw invalid_argument (explain_status(_status |= CSource::TStatus::sysfail));
+                _fsize = stat0.st_size;
+        }
+        _fd = open( fname_.c_str(), O_RDWR);
+        if ( _fd == -1 )
+                throw invalid_argument (explain_status(_status |= sysfail));
 
       // mmap
-	_mmapping =
-		mmap( NULL,
-		      _fsize,
-		      PROT_READ | PROT_WRITE, MAP_SHARED,
-		      _fd, 0);
-	if ( _mmapping == (void*)-1 ) {
-		close( _fd);
-		throw length_error ("CEDFFile::CEDFFile(): mmap error");
-	}
+        _mmapping =
+                mmap( NULL,
+                      _fsize,
+                      PROT_READ | PROT_WRITE, MAP_SHARED,
+                      _fd, 0);
+        if ( _mmapping == (void*)-1 ) {
+                close( _fd);
+                throw length_error ("CEDFFile::CEDFFile(): mmap error");
+        }
 
       // parse header
-	if ( _parse_header() ) {  // creates channels list
-		if ( not (flags_ & no_field_consistency_check) ) {
-			close( _fd);
-			munmap( _mmapping, _fsize);
-			throw invalid_argument (explain_status(_status));
-		} else
-			fprintf( stderr, "CEDFFile::CEDFFile(\"%s\") Warning: parse header failed, but proceeding anyway\n", fname_.c_str());
-	}
-	// channels now available
-
-	header_length = 256 + (channels.size() * 256);
+        if ( _parse_header() ) {  // creates channels list
+                if ( not (flags_ & no_field_consistency_check) ) {
+                        close( _fd);
+                        munmap( _mmapping, _fsize);
+                        throw invalid_argument (explain_status(_status));
+                } else
+                        fprintf( stderr, "CEDFFile::CEDFFile(\"%s\") Warning: parse header failed, but proceeding anyway\n", fname_.c_str());
+        }
+        // channels now available
+
+        header_length = 256 + (channels.size() * 256);
 
       // lest we ever access past mmapped region
-	{
-		size_t	total_samples_per_record = 0;
-		for ( auto& H : channels )
-			total_samples_per_record += H.samples_per_record;
-		size_t	expected_fsize = header_length + sizeof(int16_t) * total_samples_per_record * n_data_records;
-		if ( _fsize < expected_fsize ) {
-			fprintf( stderr, "CEDFFile::CEDFFile(\"%s\") file size less than declared in header\n", fname_.c_str());
-			close( _fd);
-			munmap( _mmapping, _fsize);
-			_status |= file_truncated;
-			throw invalid_argument (explain_status(_status));
-		} else if ( _fsize > expected_fsize ) {
-			_status |= trailing_junk;
-			fprintf( stderr, "CEDFFile::CEDFFile(\"%s\") Warning: %zu bytes of trailing junk\n",
-				 fname_.c_str(), _fsize - expected_fsize);
-		}
-	}
-
-	_extract_embedded_annotations();
-
-	if ( not (flags_ & CSource::no_ancillary_files) )
-		load_ancillary_files();
+        {
+                size_t        total_samples_per_record = 0;
+                for ( auto& H : channels )
+                        total_samples_per_record += H.samples_per_record;
+                size_t        expected_fsize = header_length + sizeof(int16_t) * total_samples_per_record * n_data_records;
+                if ( _fsize < expected_fsize ) {
+                        fprintf( stderr, "CEDFFile::CEDFFile(\"%s\") file size less than declared in header\n", fname_.c_str());
+                        close( _fd);
+                        munmap( _mmapping, _fsize);
+                        _status |= file_truncated;
+                        throw invalid_argument (explain_status(_status));
+                } else if ( _fsize > expected_fsize ) {
+                        _status |= trailing_junk;
+                        fprintf( stderr, "CEDFFile::CEDFFile(\"%s\") Warning: %zu bytes of trailing junk\n",
+                                 fname_.c_str(), _fsize - expected_fsize);
+                }
+        }
+
+        _extract_embedded_annotations();
+
+        if ( not (flags_ & CSource::no_ancillary_files) )
+                load_ancillary_files();
 }
 
 
@@ -186,87 +186,87 @@ CEDFFile (const string& fname_, const int flags_)
 
 CEDFFile::
 CEDFFile (const string& fname_, const TSubtype subtype_, const int flags_,
-	  const list<pair<SChannel, size_t>>& channels_,
-	  const size_t data_record_size_,
-	  const size_t n_data_records_)
+          const list<pair<SChannel, size_t>>& channels_,
+          const size_t data_record_size_,
+          const size_t n_data_records_)
       : CSource (fname_, flags_),
-	data_record_size (data_record_size_),
-	n_data_records (n_data_records_),
-	_subtype (subtype_)
+        data_record_size (data_record_size_),
+        n_data_records (n_data_records_),
+        _subtype (subtype_)
 {
-	_fd = open( fname_.c_str(), O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP);
-	if ( _fd == -1 )
-		throw invalid_argument (explain_status(_status |= CSource::TStatus::sysfail));
-
-	header_length = 256 + (channels_.size() * 256);
-	size_t total_samplerate = 0;
-	for ( auto& H : channels_ )
-		total_samplerate += H.second; // total samplerate
-
-	_fsize = header_length + 2 * total_samplerate * data_record_size * n_data_records;
-	// extend
-	if ( lseek( _fd, _fsize-1, SEEK_SET) == -1 || write( _fd, "\0", 1) != 1 )
-		throw invalid_argument (explain_status(_status |= sysfail));
-
-//	size_t sys_page_size = (size_t) sysconf( _SC_PAGESIZE);
-	_mmapping =
-		mmap( NULL,
-		      _fsize,
-		      PROT_READ | PROT_WRITE, MAP_SHARED,
-		      _fd,
-		      0);
-	if ( _mmapping == (void*)-1 ) {
-		close( _fd);
-		throw invalid_argument (explain_status(_status |= TStatus::mmap_error));
-	}
+        _fd = open( fname_.c_str(), O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP);
+        if ( _fd == -1 )
+                throw invalid_argument (explain_status(_status |= CSource::TStatus::sysfail));
+
+        header_length = 256 + (channels_.size() * 256);
+        size_t total_samplerate = 0;
+        for ( auto& H : channels_ )
+                total_samplerate += H.second; // total samplerate
+
+        _fsize = header_length + 2 * total_samplerate * data_record_size * n_data_records;
+        // extend
+        if ( lseek( _fd, _fsize-1, SEEK_SET) == -1 || write( _fd, "\0", 1) != 1 )
+                throw invalid_argument (explain_status(_status |= sysfail));
+
+//        size_t sys_page_size = (size_t) sysconf( _SC_PAGESIZE);
+        _mmapping =
+                mmap( NULL,
+                      _fsize,
+                      PROT_READ | PROT_WRITE, MAP_SHARED,
+                      _fd,
+                      0);
+        if ( _mmapping == (void*)-1 ) {
+                close( _fd);
+                throw invalid_argument (explain_status(_status |= TStatus::mmap_error));
+        }
 
       // fill out some essential header fields
-	channels.resize( channels_.size());
-	_lay_out_header();
+        channels.resize( channels_.size());
+        _lay_out_header();
 
-	strncpy( header.version_number, version_string, 8);
+        strncpy( header.version_number, version_string, 8);
 
-	_subject = {"Fafa_1", "Mr. Fafa"};
-	set_patient_id( _subject.make_recording_id_edf_style());
+        _subject = {"Fafa_1", "Mr. Fafa"};
+        set_patient_id( _subject.make_recording_id_edf_style());
 
-	set_recording_id( "Zzz");
-	set_comment( fname_);
-	set_start_time( time(NULL));
+        set_recording_id( "Zzz");
+        set_comment( fname_);
+        set_start_time( time(NULL));
 
-	strncpy( header.header_length,		pad( to_string(header_length),    8).c_str(), 8);
-	strncpy( header.data_record_size,	pad( to_string(data_record_size), 8).c_str(), 8);
-	strncpy( header.n_data_records,		pad( to_string(n_data_records),   8).c_str(), 8);
-	strncpy( header.n_channels,		pad( to_string(channels_.size()), 4).c_str(), 4);
+        strncpy( header.header_length,                pad( to_string(header_length),    8).c_str(), 8);
+        strncpy( header.data_record_size,        pad( to_string(data_record_size), 8).c_str(), 8);
+        strncpy( header.n_data_records,                pad( to_string(n_data_records),   8).c_str(), 8);
+        strncpy( header.n_channels,                pad( to_string(channels_.size()), 4).c_str(), 4);
 
-	_total_samples_per_record = 0;
-	size_t hi = 0;
-	for ( auto& h : channels_ ) {
-		auto& H = channels[hi];
+        _total_samples_per_record = 0;
+        size_t hi = 0;
+        for ( auto& h : channels_ ) {
+                auto& H = channels[hi];
 
-		H.ucd = h.first;
-		strncpy( H.header.label,
-			 pad( H.ucd.name(), 16).c_str(), 16);
+                H.ucd = h.first;
+                strncpy( H.header.label,
+                         pad( H.ucd.name(), 16).c_str(), 16);
 
-		strncpy( H.header.transducer_type,
-			 pad( H.transducer_type = "no transducer info", 80).c_str(), 80);
-		strncpy( H.header.physical_dim,
-			 pad( H.physical_dim = "mV", 8).c_str(), 8);
+                strncpy( H.header.transducer_type,
+                         pad( H.transducer_type = "no transducer info", 80).c_str(), 80);
+                strncpy( H.header.physical_dim,
+                         pad( H.physical_dim = "mV", 8).c_str(), 8);
 
-		H.set_physical_range( -20, 20); // expecting these to be reset before put_signal
-		H.set_digital_range( INT16_MIN, INT16_MAX);
-		H.scale = (H.physical_max - H.physical_min) /
-			(H.digital_max - H.digital_min );
+                H.set_physical_range( -20, 20); // expecting these to be reset before put_signal
+                H.set_digital_range( INT16_MIN, INT16_MAX);
+                H.scale = (H.physical_max - H.physical_min) /
+                        (H.digital_max - H.digital_min );
 
-		strncpy( H.header.filtering_info,
-			 pad( H.filtering_info = "raw", 80).c_str(), 80);
-		strncpy( H.header.samples_per_record,
-			 pad( to_string( H.samples_per_record = h.second * data_record_size), 8).c_str(), 8);
+                strncpy( H.header.filtering_info,
+                         pad( H.filtering_info = "raw", 80).c_str(), 80);
+                strncpy( H.header.samples_per_record,
+                         pad( to_string( H.samples_per_record = h.second * data_record_size), 8).c_str(), 8);
 
-		H._at = _total_samples_per_record;
-		_total_samples_per_record += H.samples_per_record;
+                H._at = _total_samples_per_record;
+                _total_samples_per_record += H.samples_per_record;
 
-		++hi;
-	}
+                ++hi;
+        }
 }
 
 
@@ -274,8 +274,8 @@ void
 CEDFFile::SSignal::
 set_physical_range( const double m, const double M)
 {
-	strncpy( header.physical_min, pad( to_string( physical_min = m), 8).c_str(), 8);
-	strncpy( header.physical_max, pad( to_string( physical_max = M), 8).c_str(), 8);
+        strncpy( header.physical_min, pad( to_string( physical_min = m), 8).c_str(), 8);
+        strncpy( header.physical_max, pad( to_string( physical_max = M), 8).c_str(), 8);
 }
 
 
@@ -283,8 +283,8 @@ void
 CEDFFile::SSignal::
 set_digital_range( const int16_t m, const int16_t M)
 {
-	strncpy( header.digital_min, pad( to_string( digital_min = m), 8).c_str(), 8);
-	strncpy( header.digital_max, pad( to_string( digital_max = M), 8).c_str(), 8);
+        strncpy( header.digital_min, pad( to_string( digital_min = m), 8).c_str(), 8);
+        strncpy( header.digital_max, pad( to_string( digital_max = M), 8).c_str(), 8);
 }
 
 
@@ -296,39 +296,39 @@ size_t
 CEDFFile::
 resize_records( const size_t new_records)
 {
-	size_t total_samples_per_record = 0;
-	for ( auto& H : channels )
-		total_samples_per_record += H.samples_per_record; // total samplerate
-	size_t old_records
-		= n_data_records;
-	auto new_fsize
-		= header_length + 2 * total_samples_per_record * (n_data_records = new_records);
+        size_t total_samples_per_record = 0;
+        for ( auto& H : channels )
+                total_samples_per_record += H.samples_per_record; // total samplerate
+        size_t old_records
+                = n_data_records;
+        auto new_fsize
+                = header_length + 2 * total_samples_per_record * (n_data_records = new_records);
 
 #if !HAVE_MREMAP
-	_mmapping =
-		mremap( _mmapping,
-			_fsize,
-			new_fsize,
-			0|MREMAP_MAYMOVE);
+        _mmapping =
+                mremap( _mmapping,
+                        _fsize,
+                        new_fsize,
+                        0|MREMAP_MAYMOVE);
 #else
-	void *_m2 =
-		mmap( NULL,
-		      new_fsize,
-		      PROT_READ | PROT_WRITE, MAP_SHARED,
-		      _fd,
-		      0);
-	memmove( _m2, _mmapping, _fsize);
-	munmap( _mmapping, _fsize);
-	_mmapping = _m2;
+        void *_m2 =
+                mmap( NULL,
+                      new_fsize,
+                      PROT_READ | PROT_WRITE, MAP_SHARED,
+                      _fd,
+                      0);
+        memmove( _m2, _mmapping, _fsize);
+        munmap( _mmapping, _fsize);
+        _mmapping = _m2;
 #endif
 
-	if ( _mmapping == (void*)-1 ) {
-		close( _fd);
-		throw length_error ("CEDFFile::resize(): mmap error");
-	}
+        if ( _mmapping == (void*)-1 ) {
+                close( _fd);
+                throw length_error ("CEDFFile::resize(): mmap error");
+        }
 
-	_fsize = new_fsize;
-	return old_records;
+        _fsize = new_fsize;
+        return old_records;
 }
 
 */
@@ -337,45 +337,45 @@ CEDFFile::
 CEDFFile (CEDFFile&& rv)
       : CSource (move(rv))
 {
-	header = rv.header; // no need to re-layout as we don't mremap
-	n_data_records   = rv.n_data_records;
-	data_record_size = rv.data_record_size;
+        header = rv.header; // no need to re-layout as we don't mremap
+        n_data_records   = rv.n_data_records;
+        data_record_size = rv.data_record_size;
 
-	_subtype    = rv._subtype;
+        _subtype    = rv._subtype;
 
-	swap( _patient_id,   rv._patient_id);
-	swap( _recording_id, rv._recording_id);
-	swap( _reserved,     rv._reserved);
+        swap( _patient_id,   rv._patient_id);
+        swap( _recording_id, rv._recording_id);
+        swap( _reserved,     rv._reserved);
 
-	swap( _episode,    rv._episode);
-	swap( _session,    rv._session);
+        swap( _episode,    rv._episode);
+        swap( _session,    rv._session);
 
-	swap( channels, rv.channels);
-	swap( common_annotations, rv.common_annotations);
+        swap( channels, rv.channels);
+        swap( common_annotations, rv.common_annotations);
 
-	header_length = rv.header_length;
-	_fsize        = rv._fsize;
-	_fld_pos      = rv._fld_pos;
-	_total_samples_per_record =
-		       rv._total_samples_per_record;
-	_mmapping     = rv._mmapping;
-	_fd           = rv._fd;
+        header_length = rv.header_length;
+        _fsize        = rv._fsize;
+        _fld_pos      = rv._fld_pos;
+        _total_samples_per_record =
+                       rv._total_samples_per_record;
+        _mmapping     = rv._mmapping;
+        _fd           = rv._fd;
 
-	rv._fd = -1; // for propriety's sake
-	rv._mmapping = (void*)-1;  // will prevent munmap in ~CEDFFile()
+        rv._fd = -1; // for propriety's sake
+        rv._mmapping = (void*)-1;  // will prevent munmap in ~CEDFFile()
 }
 
 
 CEDFFile::
 ~CEDFFile ()
 {
-	if ( not (_flags & no_ancillary_files) )
-		save_ancillary_files();
+        if ( not (_flags & no_ancillary_files) )
+                save_ancillary_files();
 
-	if ( _mmapping != (void*)-1 ) {
-		munmap( _mmapping, _fsize);
-		close( _fd);
-	}
+        if ( _mmapping != (void*)-1 ) {
+                munmap( _mmapping, _fsize);
+                close( _fd);
+        }
 }
 
 
@@ -393,33 +393,33 @@ void
 CEDFFile::
 _lay_out_header()
 {
-	header.version_number 	 = (char*)_mmapping;               //[ 8],
-	header.patient_id     	 = header.version_number   +  8;   //[80],
-	header.recording_id   	 = header.patient_id       + 80;   //[80],
-	header.recording_date 	 = header.recording_id     + 80;   //[ 8],
-	header.recording_time 	 = header.recording_date   +  8;   //[ 8],
-	header.header_length  	 = header.recording_time   +  8;   //[ 8],
-	header.reserved       	 = header.header_length    +  8;   //[44],
-	header.n_data_records 	 = header.reserved         + 44;   //[ 8],
-	header.data_record_size  = header.n_data_records   +  8;   //[ 8],
-	header.n_channels        = header.data_record_size +  8;   //[ 4];
-
-	char *p = (char*)_mmapping + 256;
-	size_t h;
-	vector<SSignal>::iterator H;
-#define FOR(A, C)							\
-		for ( h = 0, H = channels.begin(); H != channels.end(); ++h, ++H, p += C ) H->A = p;
-
-	FOR (header.label,			16);
-	FOR (header.transducer_type,		80);
-	FOR (header.physical_dim,		 8);
-	FOR (header.physical_min,		 8);
-	FOR (header.physical_max,		 8);
-	FOR (header.digital_min,		 8);
-	FOR (header.digital_max,		 8);
-	FOR (header.filtering_info,		80);
-	FOR (header.samples_per_record,		 8);
-	FOR (header.reserved,			32);
+        header.version_number          = (char*)_mmapping;               //[ 8],
+        header.patient_id              = header.version_number   +  8;   //[80],
+        header.recording_id            = header.patient_id       + 80;   //[80],
+        header.recording_date          = header.recording_id     + 80;   //[ 8],
+        header.recording_time          = header.recording_date   +  8;   //[ 8],
+        header.header_length           = header.recording_time   +  8;   //[ 8],
+        header.reserved                = header.header_length    +  8;   //[44],
+        header.n_data_records          = header.reserved         + 44;   //[ 8],
+        header.data_record_size  = header.n_data_records   +  8;   //[ 8],
+        header.n_channels        = header.data_record_size +  8;   //[ 4];
+
+        char *p = (char*)_mmapping + 256;
+        size_t h;
+        vector<SSignal>::iterator H;
+#define FOR(A, C)                                                        \
+                for ( h = 0, H = channels.begin(); H != channels.end(); ++h, ++H, p += C ) H->A = p;
+
+        FOR (header.label,                        16);
+        FOR (header.transducer_type,                80);
+        FOR (header.physical_dim,                 8);
+        FOR (header.physical_min,                 8);
+        FOR (header.physical_max,                 8);
+        FOR (header.digital_min,                 8);
+        FOR (header.digital_max,                 8);
+        FOR (header.filtering_info,                80);
+        FOR (header.samples_per_record,                 8);
+        FOR (header.reserved,                        32);
 #undef FOR
 }
 
@@ -430,235 +430,235 @@ char*
 CEDFFile::
 _get_next_field( char *&field, const size_t fld_size) throw (TStatus)
 {
-	if ( _fld_pos + fld_size > _fsize ) {
-		_status |= bad_header;
-		throw bad_header;
-	}
+        if ( _fld_pos + fld_size > _fsize ) {
+                _status |= bad_header;
+                throw bad_header;
+        }
 
-	field = (char*)_mmapping + _fld_pos;
-	_fld_pos += fld_size;
+        field = (char*)_mmapping + _fld_pos;
+        _fld_pos += fld_size;
 
-	return field;
+        return field;
 }
 
 int
 CEDFFile::
 _parse_header()
 {
-	size_t	n_channels;
-	try {
-		_fld_pos = 0;
-		_get_next_field( header.version_number,   8);
-		_get_next_field( header.patient_id,      80);
-		_get_next_field( header.recording_id,    80);
-		_get_next_field( header.recording_date,   8);
-		_get_next_field( header.recording_time,   8);
-		_get_next_field( header.header_length,    8);
-		_get_next_field( header.reserved,        44);
-		_get_next_field( header.n_data_records,   8);
-		_get_next_field( header.data_record_size, 8);
-		_get_next_field( header.n_channels,       4);
-
-		if ( strncmp( header.version_number, version_string, 8) ) {
-			_status |= (bad_version | inoperable);
-			return -2;
-		}
-
-		_subtype =
-			(strncasecmp( header.reserved, "edf+c", 5) == 0)
-			? TSubtype::edfplus_c
-			: (strncasecmp( header.reserved, "edf+d", 5) == 0)
-			? TSubtype::edfplus_d
-			: TSubtype::edf;
-
-		size_t	header_length;
-
-		header_length = n_data_records = data_record_size = n_channels = 0;
-		sscanf( header.header_length,    "%8zu", &header_length);
-		sscanf( header.n_data_records,   "%8zu", &n_data_records);
-		sscanf( header.data_record_size, "%8lg", &data_record_size); // edf+ supports fractions
-		sscanf( header.n_channels,       "%4zu", &n_channels);
-
-		if ( !header_length || !n_data_records || !data_record_size || !n_channels ) {
-			_status |= bad_numfld;
-			if ( not (_flags & sigfile::CSource::no_field_consistency_check) )
-				return -2;
-		}
-		if ( n_channels == 0 )  {
-			_status |= inoperable;
-			return -2;
-		}
-
-		_patient_id = trim( string (header.patient_id, 80));
-		_recording_id = trim( string (header.recording_id, 80));
-
-	      // sub-parse patient_id into SSubjectId struct
-		if ( unlikely (_patient_id.empty()) )
-			_status |= missing_patient_id;
-		_status |=
-			_subject.parse_recording_id_edf_style( _patient_id);
-
-	      // times
-		figure_times(
-			string (header.recording_date, 8),
-			string (header.recording_time, 8),
-			TAcceptTimeFormat::edf_strict);
-		if ( _status & bad_datetime && !(_flags & CSource::TFlags::no_field_consistency_check) )
-			return -2;
-		_end_time = _start_time + (time_t)recording_time();
-
-	      // deal with episode and session
-		tie (_session, _episode) =
-			figure_session_and_episode();
-
-	      // assign "reserved"
-		_reserved = trim( string (header.reserved, 44));
-
-		if ( n_channels > max_channels ) {
-			_status |= bad_numfld;
-			if ( not (_flags & sigfile::CSource::no_field_consistency_check) )
-				return -2;
-		} else {
-			channels.resize( n_channels);
-
-		      // determine & validate signal types
-			for ( auto &H : channels ) {
-				_get_next_field( H.header.label, 16);
-				string isolated_label = trim( string (H.header.label, 16));
-
-				if ( isolated_label == sigfile::edf_annotations_label )
-					H.ucd = {sigfile::SChannel::TType::embedded_annotation, 0};
-				else {
-					auto tt = agh::str::tokens( isolated_label, " ");
-					// parse legacy pre 0.9 specs ("EEG F3" etc)
-					if ( tt.size() > 1 ) {
-						string suggested_type = tt.front();
-						H.ucd = {(tt.pop_front(), agh::str::join( tt, " "))};
-						if ( suggested_type != H.ucd.type_s() )
-							_status |= conflicting_channel_type;
-					} else {
-						H.ucd = sigfile::SChannel (isolated_label);
-
-						if ( H.ucd.type() == sigfile::SChannel::TType::eeg &&
-						     H.ucd.idx()  == sigfile::EEG::custom )
-							_status |= non1020_channel;
-						if ( H.ucd.type() == SChannel::SChannel::TType::other )
-							_status |= nonkemp_signaltype;
-					}
-				}
-			}
-			for ( auto &H : channels )
-				H.transducer_type =
-					trim( string (_get_next_field( H.header.transducer_type, 80), 80));
-
-			for ( auto &H : channels )
-				H.physical_dim =
-					trim( string (_get_next_field( H.header.physical_dim, 8), 8));
-
-			for ( auto &H : channels ) {
-				_get_next_field( H.header.physical_min, 8);
-				if ( H.ucd.type() == sigfile::SChannel::TType::embedded_annotation )
-					continue;
-				if ( sscanf( H.header.physical_min, "%8lg",
-					     &H.physical_min) != 1 ) {
-					_status |= bad_numfld;
-					if ( not (_flags & sigfile::CSource::no_field_consistency_check) )
-						return -2;
-				}
-			}
-			for ( auto &H : channels ) {
-				_get_next_field( H.header.physical_max, 8);
-				if ( H.ucd.type() == sigfile::SChannel::TType::embedded_annotation )
-					continue;
-				if ( sscanf( H.header.physical_max, "%8lg",
-					     &H.physical_max) != 1 ) {
-					_status |= bad_numfld;
-					if ( not (_flags & sigfile::CSource::no_field_consistency_check) )
-						return -2;
-				}
-			}
-
-			for ( auto &H : channels ) {
-				_get_next_field( H.header.digital_min, 8);
-				if ( H.ucd.type() == sigfile::SChannel::TType::embedded_annotation )
-					continue;
-				if ( sscanf( H.header.digital_min, "%8d",
-					     &H.digital_min) != 1 ) {
-					_status |= bad_numfld;
-					if ( not (_flags & sigfile::CSource::no_field_consistency_check) )
-						return -2;
-				}
-			}
-			for ( auto &H : channels ) {
-				_get_next_field( H.header.digital_max, 8);
-				if ( H.ucd.type() == sigfile::SChannel::TType::embedded_annotation )
-					continue;
-				if ( sscanf( H.header.digital_max, "%8d",
-					     &H.digital_max) != 1 ) {
-					_status |= bad_numfld;
-					if ( not (_flags & sigfile::CSource::no_field_consistency_check) )
-						return -2;
-				}
-			}
-
-			for ( auto &H : channels )
-				H.filtering_info.assign(
-					trim( string (_get_next_field( H.header.filtering_info, 80), 80)));
-
-			for ( auto &H : channels ) {
-				char *tail;
-				string t {trim( string (_get_next_field( H.header.samples_per_record, 8), 8))};
-				H.samples_per_record =
-					strtoul( t.c_str(), &tail, 10);
-				if ( tail == NULL || *tail != '\0' ) {
-					_status |= bad_numfld;
-					if ( not (_flags & sigfile::CSource::no_field_consistency_check) )
-						return -2;
-				}
-			}
-
-			for ( auto &H : channels )
-				H.reserved.assign(
-					trim( string (_get_next_field( H.header.reserved, 32), 32)));
-		}
-	} catch (TStatus ex) {
-		return -1;
-	} catch (invalid_argument ex) {
-		_status |= bad_numfld;
-		if ( not (_flags & sigfile::CSource::no_field_consistency_check) )
-			return -3;
-	}
+        size_t        n_channels;
+        try {
+                _fld_pos = 0;
+                _get_next_field( header.version_number,   8);
+                _get_next_field( header.patient_id,      80);
+                _get_next_field( header.recording_id,    80);
+                _get_next_field( header.recording_date,   8);
+                _get_next_field( header.recording_time,   8);
+                _get_next_field( header.header_length,    8);
+                _get_next_field( header.reserved,        44);
+                _get_next_field( header.n_data_records,   8);
+                _get_next_field( header.data_record_size, 8);
+                _get_next_field( header.n_channels,       4);
+
+                if ( strncmp( header.version_number, version_string, 8) ) {
+                        _status |= (bad_version | inoperable);
+                        return -2;
+                }
+
+                _subtype =
+                        (strncasecmp( header.reserved, "edf+c", 5) == 0)
+                        ? TSubtype::edfplus_c
+                        : (strncasecmp( header.reserved, "edf+d", 5) == 0)
+                        ? TSubtype::edfplus_d
+                        : TSubtype::edf;
+
+                size_t        header_length;
+
+                header_length = n_data_records = data_record_size = n_channels = 0;
+                sscanf( header.header_length,    "%8zu", &header_length);
+                sscanf( header.n_data_records,   "%8zu", &n_data_records);
+                sscanf( header.data_record_size, "%8lg", &data_record_size); // edf+ supports fractions
+                sscanf( header.n_channels,       "%4zu", &n_channels);
+
+                if ( !header_length || !n_data_records || !data_record_size || !n_channels ) {
+                        _status |= bad_numfld;
+                        if ( not (_flags & sigfile::CSource::no_field_consistency_check) )
+                                return -2;
+                }
+                if ( n_channels == 0 )  {
+                        _status |= inoperable;
+                        return -2;
+                }
+
+                _patient_id = trim( string (header.patient_id, 80));
+                _recording_id = trim( string (header.recording_id, 80));
+
+              // sub-parse patient_id into SSubjectId struct
+                if ( unlikely (_patient_id.empty()) )
+                        _status |= missing_patient_id;
+                _status |=
+                        _subject.parse_recording_id_edf_style( _patient_id);
+
+              // times
+                figure_times(
+                        string (header.recording_date, 8),
+                        string (header.recording_time, 8),
+                        TAcceptTimeFormat::edf_strict);
+                if ( _status & bad_datetime && !(_flags & CSource::TFlags::no_field_consistency_check) )
+                        return -2;
+                _end_time = _start_time + (time_t)recording_time();
+
+              // deal with episode and session
+                tie (_session, _episode) =
+                        figure_session_and_episode();
+
+              // assign "reserved"
+                _reserved = trim( string (header.reserved, 44));
+
+                if ( n_channels > max_channels ) {
+                        _status |= bad_numfld;
+                        if ( not (_flags & sigfile::CSource::no_field_consistency_check) )
+                                return -2;
+                } else {
+                        channels.resize( n_channels);
+
+                      // determine & validate signal types
+                        for ( auto &H : channels ) {
+                                _get_next_field( H.header.label, 16);
+                                string isolated_label = trim( string (H.header.label, 16));
+
+                                if ( isolated_label == sigfile::edf_annotations_label )
+                                        H.ucd = {sigfile::SChannel::TType::embedded_annotation, 0};
+                                else {
+                                        auto tt = agh::str::tokens( isolated_label, " ");
+                                        // parse legacy pre 0.9 specs ("EEG F3" etc)
+                                        if ( tt.size() > 1 ) {
+                                                string suggested_type = tt.front();
+                                                H.ucd = {(tt.pop_front(), agh::str::join( tt, " "))};
+                                                if ( suggested_type != H.ucd.type_s() )
+                                                        _status |= conflicting_channel_type;
+                                        } else {
+                                                H.ucd = sigfile::SChannel (isolated_label);
+
+                                                if ( H.ucd.type() == sigfile::SChannel::TType::eeg &&
+                                                     H.ucd.idx()  == sigfile::EEG::custom )
+                                                        _status |= non1020_channel;
+                                                if ( H.ucd.type() == SChannel::SChannel::TType::other )
+                                                        _status |= nonkemp_signaltype;
+                                        }
+                                }
+                        }
+                        for ( auto &H : channels )
+                                H.transducer_type =
+                                        trim( string (_get_next_field( H.header.transducer_type, 80), 80));
+
+                        for ( auto &H : channels )
+                                H.physical_dim =
+                                        trim( string (_get_next_field( H.header.physical_dim, 8), 8));
+
+                        for ( auto &H : channels ) {
+                                _get_next_field( H.header.physical_min, 8);
+                                if ( H.ucd.type() == sigfile::SChannel::TType::embedded_annotation )
+                                        continue;
+                                if ( sscanf( H.header.physical_min, "%8lg",
+                                             &H.physical_min) != 1 ) {
+                                        _status |= bad_numfld;
+                                        if ( not (_flags & sigfile::CSource::no_field_consistency_check) )
+                                                return -2;
+                                }
+                        }
+                        for ( auto &H : channels ) {
+                                _get_next_field( H.header.physical_max, 8);
+                                if ( H.ucd.type() == sigfile::SChannel::TType::embedded_annotation )
+                                        continue;
+                                if ( sscanf( H.header.physical_max, "%8lg",
+                                             &H.physical_max) != 1 ) {
+                                        _status |= bad_numfld;
+                                        if ( not (_flags & sigfile::CSource::no_field_consistency_check) )
+                                                return -2;
+                                }
+                        }
+
+                        for ( auto &H : channels ) {
+                                _get_next_field( H.header.digital_min, 8);
+                                if ( H.ucd.type() == sigfile::SChannel::TType::embedded_annotation )
+                                        continue;
+                                if ( sscanf( H.header.digital_min, "%8d",
+                                             &H.digital_min) != 1 ) {
+                                        _status |= bad_numfld;
+                                        if ( not (_flags & sigfile::CSource::no_field_consistency_check) )
+                                                return -2;
+                                }
+                        }
+                        for ( auto &H : channels ) {
+                                _get_next_field( H.header.digital_max, 8);
+                                if ( H.ucd.type() == sigfile::SChannel::TType::embedded_annotation )
+                                        continue;
+                                if ( sscanf( H.header.digital_max, "%8d",
+                                             &H.digital_max) != 1 ) {
+                                        _status |= bad_numfld;
+                                        if ( not (_flags & sigfile::CSource::no_field_consistency_check) )
+                                                return -2;
+                                }
+                        }
+
+                        for ( auto &H : channels )
+                                H.filtering_info.assign(
+                                        trim( string (_get_next_field( H.header.filtering_info, 80), 80)));
+
+                        for ( auto &H : channels ) {
+                                char *tail;
+                                string t {trim( string (_get_next_field( H.header.samples_per_record, 8), 8))};
+                                H.samples_per_record =
+                                        strtoul( t.c_str(), &tail, 10);
+                                if ( tail == NULL || *tail != '\0' ) {
+                                        _status |= bad_numfld;
+                                        if ( not (_flags & sigfile::CSource::no_field_consistency_check) )
+                                                return -2;
+                                }
+                        }
+
+                        for ( auto &H : channels )
+                                H.reserved.assign(
+                                        trim( string (_get_next_field( H.header.reserved, 32), 32)));
+                }
+        } catch (TStatus ex) {
+                return -1;
+        } catch (invalid_argument ex) {
+                _status |= bad_numfld;
+                if ( not (_flags & sigfile::CSource::no_field_consistency_check) )
+                        return -3;
+        }
 
       // calculate gain
-	for ( auto &H : channels )
-		if ( H.ucd.type() != sigfile::SChannel::TType::embedded_annotation ) {
-			if ( H.physical_max <= H.physical_min ||
-			     H.digital_max  <= H.digital_min  )
-				_status |= nogain;
-			H.scale =
-				(H.physical_max - H.physical_min) /
-				(H.digital_max  - H.digital_min );
-		}
+        for ( auto &H : channels )
+                if ( H.ucd.type() != sigfile::SChannel::TType::embedded_annotation ) {
+                        if ( H.physical_max <= H.physical_min ||
+                             H.digital_max  <= H.digital_min  )
+                                _status |= nogain;
+                        H.scale =
+                                (H.physical_max - H.physical_min) /
+                                (H.digital_max  - H.digital_min );
+                }
 
 
       // convenience field
-	_total_samples_per_record = 0;
-	for ( auto &H : channels ) {
-		H._at = _total_samples_per_record;
-		_total_samples_per_record += H.samples_per_record;
-	}
+        _total_samples_per_record = 0;
+        for ( auto &H : channels ) {
+                H._at = _total_samples_per_record;
+                _total_samples_per_record += H.samples_per_record;
+        }
 
       // are channels unique?
-	for ( auto &H : channels )
-		for ( auto &J : channels ) {
-			if ( &J != &H && J.ucd == H.ucd ) {
-				_status |= dup_channels;
-				goto outer_break;
-			}
-		}
+        for ( auto &H : channels )
+                for ( auto &J : channels ) {
+                        if ( &J != &H && J.ucd == H.ucd ) {
+                                _status |= dup_channels;
+                                goto outer_break;
+                        }
+                }
 outer_break:
 
-	return 0;
+        return 0;
 }
 
 
@@ -672,68 +672,68 @@ int
 CEDFFile::
 _extract_embedded_annotations()
 {
-	auto S = find( channels.begin(), channels.end(), sigfile::edf_annotations_label);
-	if ( S == channels.end() )
-		return 0;
-	auto& AH = *S;
-
-	size_t alen = AH.samples_per_record * 2;
-
-	for ( size_t r = 0; r < n_data_records; ++r ) {
-		char   *this_a =
-			(char*)_mmapping + header_length
-			+ r * _total_samples_per_record * 2	// full records before
-			+ AH._at * 2;				// offset to our samples
-
-		if ( (this_a[0] == '+'   || this_a[0] == '-') &&
-		     (isdigit(this_a[1]) || this_a[1] == '.') ) {
-
-			string	abuf (this_a, alen); // NULL-terminated, possibly at pos <alen
-
-			float	offset,
-				duration;
-			const char
-				*offset_p = abuf.c_str(),
-				*duration_p,
-				*tals_p;
-
-			while ( (tals_p = strchr( offset_p, 20)) ) {
-				// determine if we have duration
-				try {
-					if ( (duration = 0.,
-					      (duration_p = strchr( offset_p, 21))) &&
-					     duration_p < tals_p ) {
-						offset = stof( string (offset_p, duration_p - offset_p));
-						if ( *duration_p != 20 )
-							duration = stof( string (duration_p, tals_p - duration_p));
-					} else {
-						offset = stof( string (offset_p, tals_p - offset_p));
-					}
-				} catch (...) {
-					break;
-				}
-
-				if ( offset_p == this_a && *tals_p == 20 ) // no TALs, it's an explicit record timestamp, not an annotation
-					_record_offsets.push_back( offset);
-
-				else {
-					auto tals = tokens_trimmed( tals_p, (char)20);
-					for ( auto& t : tals )
-						if ( not t.empty() ) {
-							common_annotations.emplace_back(
-								offset,
-								offset + duration,
-								t,
-								SAnnotation::TType::plain);
-						}
-				}
-
-				offset_p = tals_p + strlen(tals_p) + 1;
-			}
-		}
-	}
-
-	return 0;
+        auto S = find( channels.begin(), channels.end(), sigfile::edf_annotations_label);
+        if ( S == channels.end() )
+                return 0;
+        auto& AH = *S;
+
+        size_t alen = AH.samples_per_record * 2;
+
+        for ( size_t r = 0; r < n_data_records; ++r ) {
+                char   *this_a =
+                        (char*)_mmapping + header_length
+                        + r * _total_samples_per_record * 2        // full records before
+                        + AH._at * 2;                                // offset to our samples
+
+                if ( (this_a[0] == '+'   || this_a[0] == '-') &&
+                     (isdigit(this_a[1]) || this_a[1] == '.') ) {
+
+                        string        abuf (this_a, alen); // NULL-terminated, possibly at pos <alen
+
+                        float        offset,
+                                duration;
+                        const char
+                                *offset_p = abuf.c_str(),
+                                *duration_p,
+                                *tals_p;
+
+                        while ( (tals_p = strchr( offset_p, 20)) ) {
+                                // determine if we have duration
+                                try {
+                                        if ( (duration = 0.,
+                                              (duration_p = strchr( offset_p, 21))) &&
+                                             duration_p < tals_p ) {
+                                                offset = stof( string (offset_p, duration_p - offset_p));
+                                                if ( *duration_p != 20 )
+                                                        duration = stof( string (duration_p, tals_p - duration_p));
+                                        } else {
+                                                offset = stof( string (offset_p, tals_p - offset_p));
+                                        }
+                                } catch (...) {
+                                        break;
+                                }
+
+                                if ( offset_p == this_a && *tals_p == 20 ) // no TALs, it's an explicit record timestamp, not an annotation
+                                        _record_offsets.push_back( offset);
+
+                                else {
+                                        auto tals = tokens_trimmed( tals_p, (char)20);
+                                        for ( auto& t : tals )
+                                                if ( not t.empty() ) {
+                                                        common_annotations.emplace_back(
+                                                                offset,
+                                                                offset + duration,
+                                                                t,
+                                                                SAnnotation::TType::plain);
+                                                }
+                                }
+
+                                offset_p = tals_p + strlen(tals_p) + 1;
+                        }
+                }
+        }
+
+        return 0;
 }
 
 
@@ -746,84 +746,84 @@ string
 CEDFFile::
 details( const int which) const
 {
-	ostringstream recv;
-	if ( _status & bad_header )
-		recv << "Bad header, or no file\n";
-	else {
-		size_t	n_dicontinuities = 0;
-		double	prev_offset = NAN, cur_offset;
-		for ( size_t r = 1; r < _record_offsets.size(); ++r ) {
-			cur_offset = _record_offsets[r] - _record_offsets[r-1];
-			if ( isfinite(prev_offset) and cur_offset != prev_offset )
-				++n_dicontinuities;
-			prev_offset = cur_offset;
-		}
-		recv << agh::str::sasprintf(
-			"File\t: %s\n"
-			" subtype\t: %s\n"
-			" PatientID\t: %s\n"
-			" RecordingID\t: %s\n"
-			" Date\t: %s\n"
-			" Time\t: %s\n"
-			" # of channels\t: %zu\n"
-			" # of records\t: %zu\n"
-			" Record size\t: %g sec\n"
-			" # of discontinuities\t: %zu\n"
-			" # of embedded annotations\t: %zu\n",
-			agh::str::homedir2tilda( filename()).c_str(),
-			subtype_s(),
-			patient_id(),
-			trim( string (header.recording_id, 80)).c_str(),
-			trim( string (header.recording_date, 8)).c_str(),
-			trim( string (header.recording_time, 8)).c_str(),
-			channels.size(),
-			n_data_records,
-			data_record_size,
-			n_dicontinuities,
-			common_annotations.size());
-
-		if ( which & with_channels ) {
-			size_t i = 0;
-			for ( auto &H : channels ) {
-				recv << agh::str::sasprintf(
-					" Channel %zu:\n"
-					"  Label\t: %s\n"
-					"  Transducer type\t: %s\n"
-					"  Physical dimension\t: %s\n"
-					"  Physical min\t: % g\n"
-					"  Physical max\t: % g\n"
-					"  Digital min\t: % d\n"
-					"  Digital max\t: % d\n"
-					"  Filtering info\t: %s\n"
-					"  Samples/rec\t: %zu\n"
-					"  Scale\t: %g\n"
-					"  (reserved)\t: %s\n",
-					++i,
-					trim( string (H.header.label, 16)).c_str(),
-					H.transducer_type.c_str(),
-					H.physical_dim.c_str(),
-					H.physical_min,
-					H.physical_max,
-					H.digital_min,
-					H.digital_max,
-					H.filtering_info.c_str(),
-					H.samples_per_record,
-					H.scale,
-					H.reserved.c_str());
-			}
-		}
-
-		if ( which & with_annotations ) {
-			recv << "Embedded annotations (" << common_annotations.size() << "):\n";
-			for ( auto &A : common_annotations )
-				recv << ' '
-				     << A.span.a << '\t'
-				     << A.span.z << '\t'
-				     << A.label << endl;
-		}
-	}
-
-	return recv.str();
+        ostringstream recv;
+        if ( _status & bad_header )
+                recv << "Bad header, or no file\n";
+        else {
+                size_t        n_dicontinuities = 0;
+                double        prev_offset = NAN, cur_offset;
+                for ( size_t r = 1; r < _record_offsets.size(); ++r ) {
+                        cur_offset = _record_offsets[r] - _record_offsets[r-1];
+                        if ( isfinite(prev_offset) and cur_offset != prev_offset )
+                                ++n_dicontinuities;
+                        prev_offset = cur_offset;
+                }
+                recv << agh::str::sasprintf(
+                        "File\t: %s\n"
+                        " subtype\t: %s\n"
+                        " PatientID\t: %s\n"
+                        " RecordingID\t: %s\n"
+                        " Date\t: %s\n"
+                        " Time\t: %s\n"
+                        " # of channels\t: %zu\n"
+                        " # of records\t: %zu\n"
+                        " Record size\t: %g sec\n"
+                        " # of discontinuities\t: %zu\n"
+                        " # of embedded annotations\t: %zu\n",
+                        agh::str::homedir2tilda( filename()).c_str(),
+                        subtype_s(),
+                        patient_id(),
+                        trim( string (header.recording_id, 80)).c_str(),
+                        trim( string (header.recording_date, 8)).c_str(),
+                        trim( string (header.recording_time, 8)).c_str(),
+                        channels.size(),
+                        n_data_records,
+                        data_record_size,
+                        n_dicontinuities,
+                        common_annotations.size());
+
+                if ( which & with_channels ) {
+                        size_t i = 0;
+                        for ( auto &H : channels ) {
+                                recv << agh::str::sasprintf(
+                                        " Channel %zu:\n"
+                                        "  Label\t: %s\n"
+                                        "  Transducer type\t: %s\n"
+                                        "  Physical dimension\t: %s\n"
+                                        "  Physical min\t: % g\n"
+                                        "  Physical max\t: % g\n"
+                                        "  Digital min\t: % d\n"
+                                        "  Digital max\t: % d\n"
+                                        "  Filtering info\t: %s\n"
+                                        "  Samples/rec\t: %zu\n"
+                                        "  Scale\t: %g\n"
+                                        "  (reserved)\t: %s\n",
+                                        ++i,
+                                        trim( string (H.header.label, 16)).c_str(),
+                                        H.transducer_type.c_str(),
+                                        H.physical_dim.c_str(),
+                                        H.physical_min,
+                                        H.physical_max,
+                                        H.digital_min,
+                                        H.digital_max,
+                                        H.filtering_info.c_str(),
+                                        H.samples_per_record,
+                                        H.scale,
+                                        H.reserved.c_str());
+                        }
+                }
+
+                if ( which & with_annotations ) {
+                        recv << "Embedded annotations (" << common_annotations.size() << "):\n";
+                        for ( auto &A : common_annotations )
+                                recv << ' '
+                                     << A.span.a << '\t'
+                                     << A.span.z << '\t'
+                                     << A.label << endl;
+                }
+        }
+
+        return recv.str();
 }
 
 
@@ -836,21 +836,21 @@ string
 CEDFFile::
 explain_status( const int status)
 {
-	list<string> recv;
-	if ( status & bad_version )
-		recv.emplace_back( "Bad Version signature (i.e., not an EDF file)");
-	if ( status & nonconforming_patient_id )
-		recv.emplace_back( "PatientId not conforming to section 2.1.3.3 of EDF spec");
-	if ( status & file_truncated )
-		recv.emplace_back( "File truncated");
-	if ( status & trailing_junk )
-		recv.emplace_back( "File has trailing junk");
-	if ( status & extra_patientid_subfields )
-		recv.emplace_back( "Extra subfields in PatientId");
-	if ( status & mmap_error )
-		recv.emplace_back( "mmap error");
-
-	return CSource::explain_status(status) + (recv.empty() ? "" : (join(recv, "\n") + '\n'));
+        list<string> recv;
+        if ( status & bad_version )
+                recv.emplace_back( "Bad Version signature (i.e., not an EDF file)");
+        if ( status & nonconforming_patient_id )
+                recv.emplace_back( "PatientId not conforming to section 2.1.3.3 of EDF spec");
+        if ( status & file_truncated )
+                recv.emplace_back( "File truncated");
+        if ( status & trailing_junk )
+                recv.emplace_back( "File has trailing junk");
+        if ( status & extra_patientid_subfields )
+                recv.emplace_back( "Extra subfields in PatientId");
+        if ( status & mmap_error )
+                recv.emplace_back( "mmap error");
+
+        return CSource::explain_status(status) + (recv.empty() ? "" : (join(recv, "\n") + '\n'));
 }
 
 
@@ -861,24 +861,24 @@ int
 agh::SSubjectId::
 parse_recording_id_edf_style( const string& s)
 {
-	using namespace agh::str;
-	int_least32_t status = 0;
-	auto subfields = tokens( s, " ");
-	if ( subfields.size() < 4 ) {
-		id = subfields.front();
-		status |= sigfile::CEDFFile::nonconforming_patient_id;
-	} else {
-		if ( subfields.size() > 4 )
-			status |= sigfile::CEDFFile::extra_patientid_subfields;
-		auto i = subfields.begin();
-		id = *i++;
-		gender = agh::SSubjectId::char_to_gender((*i++)[0]);
-		dob = agh::SSubjectId::str_to_dob(*i++);
-		name = join( tokens(*i++, "_"), " ");
-		if ( not valid() )
-			status |= sigfile::CSource::invalid_subject_details;
-	}
-	return status;
+        using namespace agh::str;
+        int_least32_t status = 0;
+        auto subfields = tokens( s, " ");
+        if ( subfields.size() < 4 ) {
+                id = subfields.front();
+                status |= sigfile::CEDFFile::nonconforming_patient_id;
+        } else {
+                if ( subfields.size() > 4 )
+                        status |= sigfile::CEDFFile::extra_patientid_subfields;
+                auto i = subfields.begin();
+                id = *i++;
+                gender = agh::SSubjectId::char_to_gender((*i++)[0]);
+                dob = agh::SSubjectId::str_to_dob(*i++);
+                name = join( tokens(*i++, "_"), " ");
+                if ( not valid() )
+                        status |= sigfile::CSource::invalid_subject_details;
+        }
+        return status;
 }
 
 
diff --git a/upstream/src/libsigfile/edf.hh b/upstream/src/libsigfile/edf.hh
index 1fec315..7f40b26 100644
--- a/upstream/src/libsigfile/edf.hh
+++ b/upstream/src/libsigfile/edf.hh
@@ -40,369 +40,369 @@ class CEDFFile
   : public CSource {
 
       // deleted
-	bool operator==( const CEDFFile&) const = delete;
-	CEDFFile() = delete;
+        bool operator==( const CEDFFile&) const = delete;
+        CEDFFile() = delete;
 
     public:
-	// subtype
-	enum class TSubtype {
-		invalid,
-		edf,
-		edfplus_c,  // continuous
-		edfplus_d   // discontinuous
-	};
-	TSubtype subtype() const
-		{ return _subtype; }
-	static const char*
-	subtype_s( TSubtype t)
-		{
-			switch (t) {
-			case TSubtype::edf:       return "edf";
-			case TSubtype::edfplus_c: return "edf+c";
-			case TSubtype::edfplus_d: return "edf+d";
-			default:        return "(invalid)";
-			}
-		}
-	const char*
-	subtype_s() const
-		{ return subtype_s( _subtype); }
+        // subtype
+        enum class TSubtype {
+                invalid,
+                edf,
+                edfplus_c,  // continuous
+                edfplus_d   // discontinuous
+        };
+        TSubtype subtype() const
+                { return _subtype; }
+        static const char*
+        subtype_s( TSubtype t)
+                {
+                        switch (t) {
+                        case TSubtype::edf:       return "edf";
+                        case TSubtype::edfplus_c: return "edf+c";
+                        case TSubtype::edfplus_d: return "edf+d";
+                        default:        return "(invalid)";
+                        }
+                }
+        const char*
+        subtype_s() const
+                { return subtype_s( _subtype); }
 
       // ctor
-	CEDFFile( const CEDFFile&)
-	      : CSource("")
-		{
-			throw invalid_argument("nono");
-		}
-	enum TFlags {
-		no_mmap				= 1<<3,
-		no_cache			= 1<<4, // just considering
-	};
-	// open existing
-	CEDFFile (const string& fname, int flags = 0);
-	// create new
-	CEDFFile (const string& fname, TSubtype, int flags,
-		  const list<pair<SChannel, size_t>>&,
-		  size_t data_record_size = 1,
-		  size_t n_data_records = 0);
-	CEDFFile (CEDFFile&&);
+        CEDFFile( const CEDFFile&)
+              : CSource("")
+                {
+                        throw invalid_argument("nono");
+                }
+        enum TFlags {
+                no_mmap                                = 1<<3,
+                no_cache                        = 1<<4, // just considering
+        };
+        // open existing
+        CEDFFile (const string& fname, int flags = 0);
+        // create new
+        CEDFFile (const string& fname, TSubtype, int flags,
+                  const list<pair<SChannel, size_t>>&,
+                  size_t data_record_size = 1,
+                  size_t n_data_records = 0);
+        CEDFFile (CEDFFile&&);
       // dtor
        ~CEDFFile ();
 
       // interface
-	// status
-	string explain_status() const
-		{ return move(explain_status( _status)); }
-	static string explain_status( int);
-
-	// identification
-	const char* patient_id() const
-		{ return _patient_id.c_str(); }
-	const char* recording_id() const
-		{ return _recording_id.c_str(); }
-	const char* episode() const
-		{ return _episode.c_str(); }
-	const char* session() const
-		{ return _session.c_str(); }
-	const char* comment() const
-		{ return _reserved.c_str(); }
-
-	// times
-	double recording_time() const // in seconds
-		{ return n_data_records * data_record_size; }
-
-	// setters
-	int set_patient_id( const string&);
-	int set_recording_id( const string&);
-	int set_episode( const string&);
-	int set_session( const string&);
-	int set_comment( const string&) // note that there's no room in EDF header to store anything useful
-		{ return 1; }
-	int set_reserved( const string&); // but you can clobber "reserved" field if you must
-
-	int set_recording_date( const string&);
-	int set_recording_time( const string&);
-
-	// channels
-	size_t n_channels() const
-		{ return channels.size(); }
-	list<SChannel>
-	channel_list() const
-		{
-			list<SChannel> ret;
-			for ( auto &H : channels )
-				ret.push_back( H.ucd);
-			return ret;
-		}
-	bool
-	have_channel( const SChannel& h) const
-		{ return find( channels.cbegin(), channels.cend(), h) != channels.cend(); }
-	int
-	channel_id( const SChannel& h) const
-		{
-			for ( size_t i = 0; i < channels.size(); ++i )
-				if ( channels[i].ucd == h )
-					return i;
-			return -1;
-		}
-	const SChannel&
-	channel_by_id( const int h) const
-		{ return channels[h].ucd; }
-
-	SChannel::TType
-	signal_type( const int h) const
-		{ return operator[](h).ucd.type(); }
-
-	size_t
-	samplerate( const int h) const
-		{ return operator[](h).samples_per_record / data_record_size; }
-
-	list<SAnnotation>&
-	annotations( const int h)
-		{ return operator[](h).annotations; }
-	const list<SAnnotation>&
-	annotations( const int h) const
-		{ return operator[](h).annotations; }
-
-	list<SAnnotation>&
-	annotations()
-		{ return common_annotations; }
-	const list<SAnnotation>&
-	annotations() const
-		{ return common_annotations; }
-
-	// artifacts
-	SArtifacts&
-	artifacts( int h)
-		{ return operator[](h).artifacts; }
-	const SArtifacts&
-	artifacts( int h) const
-		{ return operator[](h).artifacts; }
-
-	// filters
-	SFilterPack&
-	filters( const int h)
-		{ return operator[](h).filters; }
-	const SFilterPack&
-	filters( const int h) const
-		{ return operator[](h).filters; }
+        // status
+        string explain_status() const
+                { return move(explain_status( _status)); }
+        static string explain_status( int);
+
+        // identification
+        const char* patient_id() const
+                { return _patient_id.c_str(); }
+        const char* recording_id() const
+                { return _recording_id.c_str(); }
+        const char* episode() const
+                { return _episode.c_str(); }
+        const char* session() const
+                { return _session.c_str(); }
+        const char* comment() const
+                { return _reserved.c_str(); }
+
+        // times
+        double recording_time() const // in seconds
+                { return n_data_records * data_record_size; }
+
+        // setters
+        int set_patient_id( const string&);
+        int set_recording_id( const string&);
+        int set_episode( const string&);
+        int set_session( const string&);
+        int set_comment( const string&) // note that there's no room in EDF header to store anything useful
+                { return 1; }
+        int set_reserved( const string&); // but you can clobber "reserved" field if you must
+
+        int set_recording_date( const string&);
+        int set_recording_time( const string&);
+
+        // channels
+        size_t n_channels() const
+                { return channels.size(); }
+        list<SChannel>
+        channel_list() const
+                {
+                        list<SChannel> ret;
+                        for ( auto &H : channels )
+                                ret.push_back( H.ucd);
+                        return ret;
+                }
+        bool
+        have_channel( const SChannel& h) const
+                { return find( channels.cbegin(), channels.cend(), h) != channels.cend(); }
+        int
+        channel_id( const SChannel& h) const
+                {
+                        for ( size_t i = 0; i < channels.size(); ++i )
+                                if ( channels[i].ucd == h )
+                                        return i;
+                        return -1;
+                }
+        const SChannel&
+        channel_by_id( const int h) const
+                { return channels[h].ucd; }
+
+        SChannel::TType
+        signal_type( const int h) const
+                { return operator[](h).ucd.type(); }
+
+        size_t
+        samplerate( const int h) const
+                { return operator[](h).samples_per_record / data_record_size; }
+
+        list<SAnnotation>&
+        annotations( const int h)
+                { return operator[](h).annotations; }
+        const list<SAnnotation>&
+        annotations( const int h) const
+                { return operator[](h).annotations; }
+
+        list<SAnnotation>&
+        annotations()
+                { return common_annotations; }
+        const list<SAnnotation>&
+        annotations() const
+                { return common_annotations; }
+
+        // artifacts
+        SArtifacts&
+        artifacts( int h)
+                { return operator[](h).artifacts; }
+        const SArtifacts&
+        artifacts( int h) const
+                { return operator[](h).artifacts; }
+
+        // filters
+        SFilterPack&
+        filters( const int h)
+                { return operator[](h).filters; }
+        const SFilterPack&
+        filters( const int h) const
+                { return operator[](h).filters; }
 
 
       // signal data extractors
-	valarray<TFloat>
-	get_region_original_smpl( int, size_t, size_t) const;
+        valarray<TFloat>
+        get_region_original_smpl( int, size_t, size_t) const;
 
-	valarray<TFloat>
-	get_signal_original( const int h) const // there is a CSource::get_signal_original already, but this one is a little better
-		{ return get_region_original_smpl(
-				h, 0, n_data_records * operator[](h).samples_per_record - 1); }
+        valarray<TFloat>
+        get_signal_original( const int h) const // there is a CSource::get_signal_original already, but this one is a little better
+                { return get_region_original_smpl(
+                                h, 0, n_data_records * operator[](h).samples_per_record - 1); }
 
-	valarray<TFloat>
-	get_signal_filtered( const int h) const
-		{ return get_region_filtered_smpl(
-				h, 0, n_data_records * operator[](h).samples_per_record - 1); }
+        valarray<TFloat>
+        get_signal_filtered( const int h) const
+                { return get_region_filtered_smpl(
+                                h, 0, n_data_records * operator[](h).samples_per_record - 1); }
 
       // put signal
-	int
-	put_region_smpl( int, const valarray<TFloat>&, size_t);
-	int
-	put_region_sec( const int h, const valarray<TFloat>& src, const float offset)
-		{ return put_region_smpl( h, src, (size_t)(offset * samplerate(h))); }
+        int
+        put_region_smpl( int, const valarray<TFloat>&, size_t);
+        int
+        put_region_sec( const int h, const valarray<TFloat>& src, const float offset)
+                { return put_region_smpl( h, src, (size_t)(offset * samplerate(h))); }
 
-	int
-	put_signal( const int h, const valarray<TFloat>& src)
-		{ return put_region_smpl( h, src, 0); }
+        int
+        put_signal( const int h, const valarray<TFloat>& src)
+                { return put_region_smpl( h, src, 0); }
 
       // signal data info
-	pair<TFloat, TFloat>
-	get_real_original_signal_range( const int h) const
-		{
-			auto x = get_signal_original( h);
-			return {x.min(), x.max()};
-		}
-
-	pair<TFloat, TFloat>
-	get_max_original_signal_range( const int h) const
-		{ return {(TFloat)channels[h].digital_min, (TFloat)channels[h].digital_max}; }
-
-
-	pair<TFloat, TFloat>
-	get_real_filtered_signal_range( const int h) const
-		{
-			auto x = get_signal_filtered( h);
-			return {x.min(), x.max()};
-		}
-
-	pair<TFloat, TFloat>
-	get_max_filtered_signal_range( const int h) const
-		{
-			auto x = get_signal_filtered( h);
-			return {x.min(), x.max()};   // an approximate
-		}
+        pair<TFloat, TFloat>
+        get_real_original_signal_range( const int h) const
+                {
+                        auto x = get_signal_original( h);
+                        return {x.min(), x.max()};
+                }
+
+        pair<TFloat, TFloat>
+        get_max_original_signal_range( const int h) const
+                { return {(TFloat)channels[h].digital_min, (TFloat)channels[h].digital_max}; }
+
+
+        pair<TFloat, TFloat>
+        get_real_filtered_signal_range( const int h) const
+                {
+                        auto x = get_signal_filtered( h);
+                        return {x.min(), x.max()};
+                }
+
+        pair<TFloat, TFloat>
+        get_max_filtered_signal_range( const int h) const
+                {
+                        auto x = get_signal_filtered( h);
+                        return {x.min(), x.max()};   // an approximate
+                }
 
       // adjust capacity
-	size_t
-	resize_records( size_t new_records);
-	// unused, undefined
+        size_t
+        resize_records( size_t new_records);
+        // unused, undefined
 
       // reporting & misc
-	string details( int which) const;
+        string details( int which) const;
 
-	sigproc::TWinType af_dampen_window_type; // master copy
+        sigproc::TWinType af_dampen_window_type; // master copy
 
       // static fields (mmapped)
-	struct SEDFHeader {
-		char	*version_number	 ,   //[ 8],
-			*patient_id    	 ,   //[80],  // maps to subject name
-			*recording_id  	 ,   //[80],  // maps to episode_name (session_name)
-			*recording_date	 ,   //[ 8],
-			*recording_time	 ,   //[ 8],
-			*header_length 	 ,   //[ 8],
-			*reserved      	 ,   //[44],
-			*n_data_records	 ,   //[ 8],
-			*data_record_size,   //[ 8],
-			*n_channels      ;   //[ 4];
-	};
-	SEDFHeader header;
+        struct SEDFHeader {
+                char        *version_number         ,   //[ 8],
+                        *patient_id             ,   //[80],  // maps to subject name
+                        *recording_id           ,   //[80],  // maps to episode_name (session_name)
+                        *recording_date         ,   //[ 8],
+                        *recording_time         ,   //[ 8],
+                        *header_length          ,   //[ 8],
+                        *reserved               ,   //[44],
+                        *n_data_records         ,   //[ 8],
+                        *data_record_size,   //[ 8],
+                        *n_channels      ;   //[ 4];
+        };
+        SEDFHeader header;
 
       // relevant converted integers
-	double	data_record_size;
-	size_t	n_data_records;
+        double        data_record_size;
+        size_t        n_data_records;
 
       // channels
-	struct SSignal {
-		static const char* edf_annotations_label;
-		struct SEDFSignalHeader {
-			char	*label             ,//  [16],
-				*transducer_type   ,//  [80],
-				*physical_dim      ,//  [ 8],
-				*physical_min      ,//  [ 8],
-				*physical_max      ,//  [ 8],
-				*digital_min       ,//  [ 8],
-				*digital_max       ,//  [ 8],
-				*filtering_info    ,//  [80],
-				*samples_per_record,//  [ 8],
-				*reserved          ;//  [32];
-		};
-		SEDFSignalHeader
-	    		header;
-		SChannel
-			ucd; // Universal Channel Designation, епта
-		string	transducer_type,
-			physical_dim,
-			filtering_info,
-			reserved;
-
-		int	digital_min,
-			digital_max;
-		double	physical_min,
-			physical_max,
-			scale;
-		void set_physical_range( double, double);
-		void set_digital_range( int16_t, int16_t);
-		size_t	samples_per_record;
-
-		bool operator==( const SChannel& h) const
-			{
-				return ucd == h;
-			}
-		bool operator==( const string& h) const
-			{
-				return ucd.name() == h;
-			}
-
-		list<SAnnotation>
-			annotations;
-		SArtifacts
-			artifacts;
-		SFilterPack
-			filters;
-	    private:
-		friend class CEDFFile;
-		size_t	_at;  // offset of our chunk within record, in samples
-	};
-	vector<SSignal>
-		channels;
-
-	list<SAnnotation> // timepoints in seconds
-		common_annotations;
+        struct SSignal {
+                static const char* edf_annotations_label;
+                struct SEDFSignalHeader {
+                        char        *label             ,//  [16],
+                                *transducer_type   ,//  [80],
+                                *physical_dim      ,//  [ 8],
+                                *physical_min      ,//  [ 8],
+                                *physical_max      ,//  [ 8],
+                                *digital_min       ,//  [ 8],
+                                *digital_max       ,//  [ 8],
+                                *filtering_info    ,//  [80],
+                                *samples_per_record,//  [ 8],
+                                *reserved          ;//  [32];
+                };
+                SEDFSignalHeader
+                            header;
+                SChannel
+                        ucd; // Universal Channel Designation, епта
+                string        transducer_type,
+                        physical_dim,
+                        filtering_info,
+                        reserved;
+
+                int        digital_min,
+                        digital_max;
+                double        physical_min,
+                        physical_max,
+                        scale;
+                void set_physical_range( double, double);
+                void set_digital_range( int16_t, int16_t);
+                size_t        samples_per_record;
+
+                bool operator==( const SChannel& h) const
+                        {
+                                return ucd == h;
+                        }
+                bool operator==( const string& h) const
+                        {
+                                return ucd.name() == h;
+                        }
+
+                list<SAnnotation>
+                        annotations;
+                SArtifacts
+                        artifacts;
+                SFilterPack
+                        filters;
+            private:
+                friend class CEDFFile;
+                size_t        _at;  // offset of our chunk within record, in samples
+        };
+        vector<SSignal>
+                channels;
+
+        list<SAnnotation> // timepoints in seconds
+                common_annotations;
 
       // signal accessors
-	SSignal& operator[]( size_t i)
-		{
-			if ( unlikely (i >= channels.size()) )
-				throw out_of_range ("Signal index out of range");
-			return channels[i];
-		}
-	const SSignal& operator[]( size_t i) const
-		{
-			if ( unlikely( i >= channels.size()) )
-				throw out_of_range ("Signal index out of range");
-			return channels[i];
-		}
-
-	SSignal& operator[]( const SChannel& h)
-		{
-			auto S = find( channels.begin(), channels.end(), h);
-			if ( S == channels.end() )
-				throw out_of_range (string ("Unknown channel ") + h.name());
-			return *S;
-		}
-	const SSignal& operator[]( const SChannel& h) const
-		{
-			auto S = find( channels.begin(), channels.end(), h);
-			if ( S == channels.end() )
-				throw out_of_range (string ("Unknown channel ") + h.name());
-			return *S;
-		}
-
-
-	enum TStatus : int_least32_t {
-		bad_version		  = (1 << (COMMON_STATUS_BITS + 1)),
-		file_truncated            = (1 << (COMMON_STATUS_BITS + 2)),
-		trailing_junk             = (1 << (COMMON_STATUS_BITS + 3)),
-		mmap_error		  = (1 << (COMMON_STATUS_BITS + 4)),
-		nogain			  = (1 << (COMMON_STATUS_BITS + 5)),
-		nonconforming_patient_id  = (1 << (COMMON_STATUS_BITS + 6)),
-		extra_patientid_subfields = (1 << (COMMON_STATUS_BITS + 7)),
-
-		inoperable		 = (bad_header
-					   | bad_version
-					   | bad_numfld
-					   | bad_datetime
-					   | dup_channels
-					   | nogain
-					   | sysfail
-					   | too_many_channels
-					   | file_truncated
-					   | mmap_error)
-	};
+        SSignal& operator[]( size_t i)
+                {
+                        if ( unlikely (i >= channels.size()) )
+                                throw out_of_range ("Signal index out of range");
+                        return channels[i];
+                }
+        const SSignal& operator[]( size_t i) const
+                {
+                        if ( unlikely( i >= channels.size()) )
+                                throw out_of_range ("Signal index out of range");
+                        return channels[i];
+                }
+
+        SSignal& operator[]( const SChannel& h)
+                {
+                        auto S = find( channels.begin(), channels.end(), h);
+                        if ( S == channels.end() )
+                                throw out_of_range (string ("Unknown channel ") + h.name());
+                        return *S;
+                }
+        const SSignal& operator[]( const SChannel& h) const
+                {
+                        auto S = find( channels.begin(), channels.end(), h);
+                        if ( S == channels.end() )
+                                throw out_of_range (string ("Unknown channel ") + h.name());
+                        return *S;
+                }
+
+
+        enum TStatus : int_least32_t {
+                bad_version                  = (1 << (COMMON_STATUS_BITS + 1)),
+                file_truncated            = (1 << (COMMON_STATUS_BITS + 2)),
+                trailing_junk             = (1 << (COMMON_STATUS_BITS + 3)),
+                mmap_error                  = (1 << (COMMON_STATUS_BITS + 4)),
+                nogain                          = (1 << (COMMON_STATUS_BITS + 5)),
+                nonconforming_patient_id  = (1 << (COMMON_STATUS_BITS + 6)),
+                extra_patientid_subfields = (1 << (COMMON_STATUS_BITS + 7)),
+
+                inoperable                 = (bad_header
+                                           | bad_version
+                                           | bad_numfld
+                                           | bad_datetime
+                                           | dup_channels
+                                           | nogain
+                                           | sysfail
+                                           | too_many_channels
+                                           | file_truncated
+                                           | mmap_error)
+        };
 
     private:
-	TSubtype _subtype;
+        TSubtype _subtype;
 
-	string	_patient_id, // this is trimmed, raw; parsed into SSubjectId fields
-		_recording_id,
+        string        _patient_id, // this is trimmed, raw; parsed into SSubjectId fields
+                _recording_id,
        // take care of file being named 'episode-1.edf'
-		_episode,
+                _episode,
        // loosely/possibly also use RecordingID as session
-		_session,
-		_reserved;
+                _session,
+                _reserved;
 
-	void _lay_out_header();
-	int _parse_header();
-	int _extract_embedded_annotations();
+        void _lay_out_header();
+        int _parse_header();
+        int _extract_embedded_annotations();
 
-	size_t	header_length,
-		_fsize,
-		_fld_pos,
-		_total_samples_per_record;
-	char* _get_next_field( char*&, size_t) throw (TStatus);
+        size_t        header_length,
+                _fsize,
+                _fld_pos,
+                _total_samples_per_record;
+        char* _get_next_field( char*&, size_t) throw (TStatus);
 
-	void	*_mmapping;
-	int	_fd;
+        void        *_mmapping;
+        int        _fd;
 
-	vector<double>
-		_record_offsets;
+        vector<double>
+                _record_offsets;
 };
 
 
diff --git a/upstream/src/libsigfile/page.cc b/upstream/src/libsigfile/page.cc
index f30f629..da1fb73 100644
--- a/upstream/src/libsigfile/page.cc
+++ b/upstream/src/libsigfile/page.cc
@@ -24,15 +24,15 @@ using namespace std;
 
 
 const char sigfile::SPage::score_codes[] = {
-	' ', '1', '2', '3', '4', 'R', 'W',
+        ' ', '1', '2', '3', '4', 'R', 'W',
 };
 
 
 const char* const sigfile::SPage::score_names[TScore::TScore_total] = {
-	"blank",
-	"NREM1", "NREM2", "NREM3", "NREM4",
-	"REM",
-	"Wake"
+        "blank",
+        "NREM1", "NREM2", "NREM3", "NREM4",
+        "REM",
+        "Wake"
 };
 
 
@@ -40,18 +40,18 @@ float
 sigfile::CHypnogram::
 percent_scored( float *nrem_p, float *rem_p, float *wake_p) const
 {
-	if ( nrem_p )
-		*nrem_p = (float)count_if( _pages.begin(), _pages.end(),
-					   mem_fun_ref (&SPage::is_nrem)) / _pages.size() * 100;
-	if ( rem_p )
-		*rem_p = (float)count_if( _pages.begin(), _pages.end(),
-					  mem_fun_ref (&SPage::is_rem)) / _pages.size() * 100;
-	if ( wake_p )
-		*wake_p = (float)count_if( _pages.begin(), _pages.end(),
-					   mem_fun_ref (&SPage::is_wake)) / _pages.size() * 100;
-
-	return (float)count_if( _pages.begin(), _pages.end(),
-				mem_fun_ref (&SPage::is_scored)) / _pages.size() * 100;
+        if ( nrem_p )
+                *nrem_p = (float)count_if( _pages.begin(), _pages.end(),
+                                           mem_fun_ref (&SPage::is_nrem)) / _pages.size() * 100;
+        if ( rem_p )
+                *rem_p = (float)count_if( _pages.begin(), _pages.end(),
+                                          mem_fun_ref (&SPage::is_rem)) / _pages.size() * 100;
+        if ( wake_p )
+                *wake_p = (float)count_if( _pages.begin(), _pages.end(),
+                                           mem_fun_ref (&SPage::is_wake)) / _pages.size() * 100;
+
+        return (float)count_if( _pages.begin(), _pages.end(),
+                                mem_fun_ref (&SPage::is_scored)) / _pages.size() * 100;
 }
 
 
@@ -60,15 +60,15 @@ sigfile::CHypnogram::TError
 sigfile::CHypnogram::
 save( const char* fname) const
 {
-	ofstream of (fname, ios_base::trunc);
-	if ( not of.good() )
-		return CHypnogram::TError::nofile;
+        ofstream of (fname, ios_base::trunc);
+        if ( not of.good() )
+                return CHypnogram::TError::nofile;
 
-	of << _pagesize << endl;
-	for ( size_t p = 0; p < _pages.size(); ++p )
-		of << operator[](p).NREM << '\t' << operator[](p).REM << '\t' << operator[](p).Wake << endl;
+        of << _pagesize << endl;
+        for ( size_t p = 0; p < _pages.size(); ++p )
+                of << operator[](p).NREM << '\t' << operator[](p).REM << '\t' << operator[](p).Wake << endl;
 
-	return CHypnogram::TError::ok;
+        return CHypnogram::TError::ok;
 }
 
 
@@ -76,28 +76,28 @@ sigfile::CHypnogram::TError
 sigfile::CHypnogram::
 load( const char* fname)
 {
-	ifstream f (fname);
-	if ( not f.good() )
-		return CHypnogram::TError::nofile;
+        ifstream f (fname);
+        if ( not f.good() )
+                return CHypnogram::TError::nofile;
 
-	SPage	P;
+        SPage        P;
 
-	size_t saved_pagesize;
-	f >> saved_pagesize;
-	if ( not f.good() )
-		return CHypnogram::TError::baddata;
+        size_t saved_pagesize;
+        f >> saved_pagesize;
+        if ( not f.good() )
+                return CHypnogram::TError::baddata;
 
-	if ( saved_pagesize != _pagesize ) {
-		fprintf( stderr, "CHypnogram::load(\"%s\"): read pagesize (%zu) different from that specified at construct (%zu)\n",
-			 fname, saved_pagesize, _pagesize);
-		_pagesize = saved_pagesize;
-		return CHypnogram::TError::wrongpagesize;
-	}
+        if ( saved_pagesize != _pagesize ) {
+                fprintf( stderr, "CHypnogram::load(\"%s\"): read pagesize (%zu) different from that specified at construct (%zu)\n",
+                         fname, saved_pagesize, _pagesize);
+                _pagesize = saved_pagesize;
+                return CHypnogram::TError::wrongpagesize;
+        }
 
-	while ( not (f >> P.NREM >> P.REM >> P.Wake).eof() )
-		_pages.emplace_back( P);
+        while ( not (f >> P.NREM >> P.REM >> P.Wake).eof() )
+                _pages.emplace_back( P);
 
-	return CHypnogram::TError::ok;
+        return CHypnogram::TError::ok;
 }
 
 
@@ -109,26 +109,26 @@ int
 sigfile::CHypnogram::
 save_canonical( const char *fname) const
 {
-	FILE *f = fopen( fname, "w");
-	if ( !f )
-		return -1;
-
-	for ( size_t p = 0; p < pages(); ++p ) {
-		float	N = operator[](p).NREM,
-			R = operator[](p).REM,
-			W = operator[](p).Wake;
-		fprintf( f, "%s\n",
-			 N > .7 ?"NREM4"
-			 : N > .4 ?"NREM3"
-			 : R > .5 ?"REM"
-			 : W > .5 ?"Wake"
-			 : N > .2 ?"NREM2"
-			 : N > .01 ?"NREM1"
-			 : "unscored");
-	}
-	fclose( f);
-
-	return 0;
+        FILE *f = fopen( fname, "w");
+        if ( !f )
+                return -1;
+
+        for ( size_t p = 0; p < pages(); ++p ) {
+                float        N = operator[](p).NREM,
+                        R = operator[](p).REM,
+                        W = operator[](p).Wake;
+                fprintf( f, "%s\n",
+                         N > .7 ?"NREM4"
+                         : N > .4 ?"NREM3"
+                         : R > .5 ?"REM"
+                         : W > .5 ?"Wake"
+                         : N > .2 ?"NREM2"
+                         : N > .01 ?"NREM1"
+                         : "unscored");
+        }
+        fclose( f);
+
+        return 0;
 }
 
 
@@ -142,51 +142,51 @@ save_canonical( const char *fname) const
 int
 sigfile::CHypnogram::
 load_canonical( const char *fname,
-		const TCustomScoreCodes& custom_score_codes)
+                const TCustomScoreCodes& custom_score_codes)
 {
-	ifstream f (fname);
-	if ( !f.good() )
-		return -1;
-
-	size_t	p = 0;
-	string token;
-	while ( p < _pages.size() ) {
-		if ( f.eof() )
-			return 2; // short
-		SPage	P = { 0., 0., 0. };
-		getline( f, token);
-		int c = (int)token[0];
-		if ( c == '#' )
-			continue;
-		if ( !strcasecmp( token.c_str(), "Wake") ||
-		     (strchr( custom_score_codes[SPage::TScore::wake].c_str(), c) != NULL) )
-			P.Wake = 1.;
-		else if ( !strcasecmp( token.c_str(), "NREM1") ||
-			  (strchr( custom_score_codes[SPage::TScore::nrem1].c_str(), c) != NULL) )
-			P.NREM = .25;
-		else if ( !strcasecmp( token.c_str(), "NREM2") ||
-			  (strchr( custom_score_codes[SPage::TScore::nrem2].c_str(), c) != NULL) )
-			P.NREM = .5;
-		else if ( !strcasecmp( token.c_str(), "NREM3") ||
-			  (strchr( custom_score_codes[SPage::TScore::nrem3].c_str(), c) != NULL) )
-			P.NREM = .75;
-		else if ( !strcasecmp( token.c_str(), "NREM4") ||
-			  (strchr( custom_score_codes[SPage::TScore::nrem4].c_str(), c) != NULL) )
-			P.NREM = 1.;
-		else if ( !strcasecmp( token.c_str(), "REM") ||
-			  (strchr( custom_score_codes[SPage::TScore::rem].c_str(), c) != NULL) )
-			P.REM = 1.;
-		else if ( !strcasecmp( token.c_str(), "unscored") ||
-			  (strchr( custom_score_codes[SPage::TScore::none].c_str(), c) != NULL) )
-			;
-		else {
-			;
-		}
-
-		operator[](p++) = P;
-	}
-
-	return f.eof() ? 0 : 1;
+        ifstream f (fname);
+        if ( !f.good() )
+                return -1;
+
+        size_t        p = 0;
+        string token;
+        while ( p < _pages.size() ) {
+                if ( f.eof() )
+                        return 2; // short
+                SPage        P = { 0., 0., 0. };
+                getline( f, token);
+                int c = (int)token[0];
+                if ( c == '#' )
+                        continue;
+                if ( !strcasecmp( token.c_str(), "Wake") ||
+                     (strchr( custom_score_codes[SPage::TScore::wake].c_str(), c) != NULL) )
+                        P.Wake = 1.;
+                else if ( !strcasecmp( token.c_str(), "NREM1") ||
+                          (strchr( custom_score_codes[SPage::TScore::nrem1].c_str(), c) != NULL) )
+                        P.NREM = .25;
+                else if ( !strcasecmp( token.c_str(), "NREM2") ||
+                          (strchr( custom_score_codes[SPage::TScore::nrem2].c_str(), c) != NULL) )
+                        P.NREM = .5;
+                else if ( !strcasecmp( token.c_str(), "NREM3") ||
+                          (strchr( custom_score_codes[SPage::TScore::nrem3].c_str(), c) != NULL) )
+                        P.NREM = .75;
+                else if ( !strcasecmp( token.c_str(), "NREM4") ||
+                          (strchr( custom_score_codes[SPage::TScore::nrem4].c_str(), c) != NULL) )
+                        P.NREM = 1.;
+                else if ( !strcasecmp( token.c_str(), "REM") ||
+                          (strchr( custom_score_codes[SPage::TScore::rem].c_str(), c) != NULL) )
+                        P.REM = 1.;
+                else if ( !strcasecmp( token.c_str(), "unscored") ||
+                          (strchr( custom_score_codes[SPage::TScore::none].c_str(), c) != NULL) )
+                        ;
+                else {
+                        ;
+                }
+
+                operator[](p++) = P;
+        }
+
+        return f.eof() ? 0 : 1;
 }
 
 // Local Variables:
diff --git a/upstream/src/libsigfile/page.hh b/upstream/src/libsigfile/page.hh
index 6cb3b0f..ebcdb12 100644
--- a/upstream/src/libsigfile/page.hh
+++ b/upstream/src/libsigfile/page.hh
@@ -29,132 +29,132 @@ namespace sigfile {
 
 
 struct SPage {
-	enum TScore : unsigned short {
-		none,
-		nrem1,	nrem2,	nrem3,	nrem4,
-		rem,	wake,
-		TScore_total
-	};
-	static const char score_codes[TScore::TScore_total];
-	static char score_code( TScore i)
-		{
-			if ( i >= TScore::TScore_total )
-				return '?';
-			return score_codes[i];
-		}
-	static const char* const score_names[TScore::TScore_total];
-	static const char* score_name( TScore i)
-		{
-			if ( i >= TScore::TScore_total )
-				return "(invalid)";
-			return score_names[i];
-		}
-
-	static TScore
-	__attribute__ ((const))
-	char2score( char c)
-		{
-			size_t i = TScore::none;
-			while ( i != TScore::TScore_total && c != score_codes[i] )
-				++i;
-			return (TScore)i;
-		}
-	static char score2char( TScore i)
-		{
-			if ( i >= TScore::TScore_total )
-				return '?';
-			return score_codes[i];
-		}
+        enum TScore : unsigned short {
+                none,
+                nrem1,        nrem2,        nrem3,        nrem4,
+                rem,        wake,
+                TScore_total
+        };
+        static const char score_codes[TScore::TScore_total];
+        static char score_code( TScore i)
+                {
+                        if ( i >= TScore::TScore_total )
+                                return '?';
+                        return score_codes[i];
+                }
+        static const char* const score_names[TScore::TScore_total];
+        static const char* score_name( TScore i)
+                {
+                        if ( i >= TScore::TScore_total )
+                                return "(invalid)";
+                        return score_names[i];
+                }
+
+        static TScore
+        __attribute__ ((const))
+        char2score( char c)
+                {
+                        size_t i = TScore::none;
+                        while ( i != TScore::TScore_total && c != score_codes[i] )
+                                ++i;
+                        return (TScore)i;
+                }
+        static char score2char( TScore i)
+                {
+                        if ( i >= TScore::TScore_total )
+                                return '?';
+                        return score_codes[i];
+                }
 
       // class proper
-	float	NREM, REM, Wake;
-	TScore score() const
-		{
-			return	 (NREM >  3./4) ? TScore::nrem4
-				:(NREM >  1./2) ? TScore::nrem3
-				:(REM  >= 1./3) ? TScore::rem
-				:(Wake >= 1./3) ? TScore::wake
-				:(NREM >  1./4) ? TScore::nrem2
-				:(NREM >   .1 ) ? TScore::nrem1
-				: TScore::none;
-		}
-	char score_code() const
-		{
-			return score_codes[score()];
-		}
-
-	bool has_swa() const
-		{
-			return (NREM + REM > .2);
-		}  // excludes NREM1, in fact
-	bool is_nrem() const
-		{
-			return NREM >= .1;
-		}
-	bool is_rem() const
-		{
-			return REM >= 1./3;
-		}
-	bool is_wake() const
-		{
-			return Wake >= 1./3;
-		}
-	bool is_scored() const
-		{
-			return score() != TScore::none;
-		}
-
-	void mark( TScore as)
-		{
-			switch ( as ) {
-			case TScore::nrem1:  NREM = .2, REM = 0., Wake = 0.; break;
-			case TScore::nrem2:  NREM = .4, REM = 0., Wake = 0.; break;
-			case TScore::nrem3:  NREM = .6, REM = 0., Wake = 0.; break;
-			case TScore::nrem4:  NREM = .9, REM = 0., Wake = 0.; break;
-			case TScore::rem:    NREM = 0., REM = 1., Wake = 0.; break;
-			case TScore::wake:   NREM = 0., REM = 0., Wake = 1.; break;
-			case TScore::none:
-			default:             NREM = 0., REM = 0., Wake = 0.; break;
-			}
-		}
-	void mark( char as)
-		{
-			mark( char2score(as));
-		}
-
-
-	SPage( float nrem = 0., float rem = 0., float wake = 0.)
-	      : NREM (nrem), REM (rem), Wake (wake)
-		{}
+        float        NREM, REM, Wake;
+        TScore score() const
+                {
+                        return         (NREM >  3./4) ? TScore::nrem4
+                                :(NREM >  1./2) ? TScore::nrem3
+                                :(REM  >= 1./3) ? TScore::rem
+                                :(Wake >= 1./3) ? TScore::wake
+                                :(NREM >  1./4) ? TScore::nrem2
+                                :(NREM >   .1 ) ? TScore::nrem1
+                                : TScore::none;
+                }
+        char score_code() const
+                {
+                        return score_codes[score()];
+                }
+
+        bool has_swa() const
+                {
+                        return (NREM + REM > .2);
+                }  // excludes NREM1, in fact
+        bool is_nrem() const
+                {
+                        return NREM >= .1;
+                }
+        bool is_rem() const
+                {
+                        return REM >= 1./3;
+                }
+        bool is_wake() const
+                {
+                        return Wake >= 1./3;
+                }
+        bool is_scored() const
+                {
+                        return score() != TScore::none;
+                }
+
+        void mark( TScore as)
+                {
+                        switch ( as ) {
+                        case TScore::nrem1:  NREM = .2, REM = 0., Wake = 0.; break;
+                        case TScore::nrem2:  NREM = .4, REM = 0., Wake = 0.; break;
+                        case TScore::nrem3:  NREM = .6, REM = 0., Wake = 0.; break;
+                        case TScore::nrem4:  NREM = .9, REM = 0., Wake = 0.; break;
+                        case TScore::rem:    NREM = 0., REM = 1., Wake = 0.; break;
+                        case TScore::wake:   NREM = 0., REM = 0., Wake = 1.; break;
+                        case TScore::none:
+                        default:             NREM = 0., REM = 0., Wake = 0.; break;
+                        }
+                }
+        void mark( char as)
+                {
+                        mark( char2score(as));
+                }
+
+
+        SPage( float nrem = 0., float rem = 0., float wake = 0.)
+              : NREM (nrem), REM (rem), Wake (wake)
+                {}
 };
 
 
 struct SPageWithMetric : public SPage {
-	TFloat	metric;
-	SPageWithMetric( float nrem = 0., float rem = 0., float wake = 0., TFloat metric_ = 0.)
-	      : SPage (nrem, rem, wake),
-		metric (metric_)
-		{}
-	SPageWithMetric( const SPage& p,
-			 TFloat metric_ = 0.)
-	      : SPage (p),
-		metric (metric_)
-		{}
+        TFloat        metric;
+        SPageWithMetric( float nrem = 0., float rem = 0., float wake = 0., TFloat metric_ = 0.)
+              : SPage (nrem, rem, wake),
+                metric (metric_)
+                {}
+        SPageWithMetric( const SPage& p,
+                         TFloat metric_ = 0.)
+              : SPage (p),
+                metric (metric_)
+                {}
 };
 
 struct SPageSimulated : public SPageWithMetric {
-	TFloat	S,
-		metric_sim;
-	SPageSimulated( float nrem = 0., float rem = 0., float wake = 0.,
-			TFloat metric_ = 0.)
-	      : SPageWithMetric (nrem, rem, wake, metric_),
-		S (0), metric_sim (metric_)
-		{}
-	SPageSimulated( const SPageWithMetric& p,
-			TFloat metric_ = 0.)
-	      : SPageWithMetric (p),
-		S (0), metric_sim (metric_)
-		{}
+        TFloat        S,
+                metric_sim;
+        SPageSimulated( float nrem = 0., float rem = 0., float wake = 0.,
+                        TFloat metric_ = 0.)
+              : SPageWithMetric (nrem, rem, wake, metric_),
+                S (0), metric_sim (metric_)
+                {}
+        SPageSimulated( const SPageWithMetric& p,
+                        TFloat metric_ = 0.)
+              : SPageWithMetric (p),
+                S (0), metric_sim (metric_)
+                {}
 };
 
 
@@ -169,67 +169,67 @@ struct SPageSimulated : public SPageWithMetric {
 class CHypnogram {
 
     protected:
-	size_t	_pagesize;
-	vector<SPage>
-		_pages;
+        size_t        _pagesize;
+        vector<SPage>
+                _pages;
     public:
-	CHypnogram() = delete;
-
-	CHypnogram( size_t psize)
-	      : _pagesize (psize)
-		{}
-	CHypnogram( CHypnogram&& rv)
-		{
-			_pagesize = rv._pagesize;
-			swap( _pages, rv._pages);
-		}
-
-	SPage& operator[]( size_t i)
-		{
-			if ( unlikely (i >= _pages.size()) )
-				throw out_of_range ("page index out of range");
-			return _pages[i];
-		}
-	const SPage& operator[]( size_t i) const
-		{
-			if ( unlikely (i >= _pages.size()) )
-				throw out_of_range ("page index out of range");
-			return _pages[i];
-		}
-
-	size_t pagesize() const		 { return _pagesize; }
-	size_t pages() const		 { return _pages.size(); }
-	size_t length_in_seconds() const { return pages() * pagesize(); }
-
-	float percent_scored( float *nrem_p = NULL, float *rem_p = NULL, float *wake_p = NULL) const;
-
-	enum TError : int {
-		ok            = 0,
-		nofile        = -1,
-		baddata       = -2,
-		wrongpagesize = -3,
-		shortread     = -4
-	};
-	TError save( const char*) const;
-	TError load( const char*);
-	TError save( const string& s) const
-		{
-			return save(s.c_str());
-		}
-	TError load( const string& s)
-		{
-			return load(s.c_str());
-		}
-
-	int save_canonical( const char* fname) const;
-	typedef array<string, (size_t)SPage::TScore::TScore_total> TCustomScoreCodes;
-	int load_canonical( const char* fname)
-		{
-			return load_canonical( fname,
-					       TCustomScoreCodes {{" -0", "1", "2", "3", "4", "6Rr8", "Ww5"}});
-		}
-	int load_canonical( const char* fname,
-			    const TCustomScoreCodes&);
+        CHypnogram() = delete;
+
+        CHypnogram( size_t psize)
+              : _pagesize (psize)
+                {}
+        CHypnogram( CHypnogram&& rv)
+                {
+                        _pagesize = rv._pagesize;
+                        swap( _pages, rv._pages);
+                }
+
+        SPage& operator[]( size_t i)
+                {
+                        if ( unlikely (i >= _pages.size()) )
+                                throw out_of_range ("page index out of range");
+                        return _pages[i];
+                }
+        const SPage& operator[]( size_t i) const
+                {
+                        if ( unlikely (i >= _pages.size()) )
+                                throw out_of_range ("page index out of range");
+                        return _pages[i];
+                }
+
+        size_t pagesize() const                 { return _pagesize; }
+        size_t pages() const                 { return _pages.size(); }
+        size_t length_in_seconds() const { return pages() * pagesize(); }
+
+        float percent_scored( float *nrem_p = NULL, float *rem_p = NULL, float *wake_p = NULL) const;
+
+        enum TError : int {
+                ok            = 0,
+                nofile        = -1,
+                baddata       = -2,
+                wrongpagesize = -3,
+                shortread     = -4
+        };
+        TError save( const char*) const;
+        TError load( const char*);
+        TError save( const string& s) const
+                {
+                        return save(s.c_str());
+                }
+        TError load( const string& s)
+                {
+                        return load(s.c_str());
+                }
+
+        int save_canonical( const char* fname) const;
+        typedef array<string, (size_t)SPage::TScore::TScore_total> TCustomScoreCodes;
+        int load_canonical( const char* fname)
+                {
+                        return load_canonical( fname,
+                                               TCustomScoreCodes {{" -0", "1", "2", "3", "4", "6Rr8", "Ww5"}});
+                }
+        int load_canonical( const char* fname,
+                            const TCustomScoreCodes&);
 };
 
 
diff --git a/upstream/src/libsigfile/source-base.cc b/upstream/src/libsigfile/source-base.cc
index a7a4658..7d373fb 100644
--- a/upstream/src/libsigfile/source-base.cc
+++ b/upstream/src/libsigfile/source-base.cc
@@ -19,19 +19,19 @@ using namespace std;
 using namespace sigfile;
 
 const char*
-	sigfile::supported_sigfile_extensions = ".edf .tsv .csv";
+        sigfile::supported_sigfile_extensions = ".edf .tsv .csv";
 
 bool
 sigfile::
 is_fname_ext_supported( const string& fname)
 {
-	for ( const auto& X : agh::str::tokens( supported_sigfile_extensions, " ") )
-		if ( fname.size() < X.size() )
-			continue;
-		else
-			if ( strcasecmp( &fname[fname.size()-4], X.c_str()) == 0 )
-				return true;
-	return false;
+        for ( const auto& X : agh::str::tokens( supported_sigfile_extensions, " ") )
+                if ( fname.size() < X.size() )
+                        continue;
+                else
+                        if ( strcasecmp( &fname[fname.size()-4], X.c_str()) == 0 )
+                                return true;
+        return false;
 }
 
 
@@ -41,19 +41,19 @@ void
 SArtifacts::
 mark_artifact( const double aa, const double az)
 {
-	if ( aa >= az )
-		return;
-	obj.emplace_back( aa, az);
-	obj.sort();
-	auto A = obj.begin();
-	while ( next(A) != obj.end() ) {
-		if ( agh::alg::overlap(A->a, A->z, next(A)->a, next(A)->z) ) {
-			A->z = max( A->z, next(A)->z);
-			obj.erase( next(A));
-			continue;
-		}
-		++A;
-	}
+        if ( aa >= az )
+                return;
+        obj.emplace_back( aa, az);
+        obj.sort();
+        auto A = obj.begin();
+        while ( next(A) != obj.end() ) {
+                if ( agh::alg::overlap(A->a, A->z, next(A)->a, next(A)->z) ) {
+                        A->z = max( A->z, next(A)->z);
+                        obj.erase( next(A));
+                        continue;
+                }
+                ++A;
+        }
 }
 
 
@@ -62,23 +62,23 @@ void
 SArtifacts::
 clear_artifact( const double aa, const double az)
 {
-	auto A = obj.begin();
-	while ( A != obj.end() ) {
-		if ( aa <= A->a && A->z <= az ) {
-			obj.erase( A++);
-			continue;
-		}
-		if ( A->a < aa && az < A->z ) {
-			obj.emplace( next(A), az, A->z);
-			A->z = aa;
-			break;
-		}
-		if ( A->a < aa && aa < A->z )
-			A->z = aa;
-		if ( A->a < az && az < A->z )
-			A->a = az;
-		++A;
-	}
+        auto A = obj.begin();
+        while ( A != obj.end() ) {
+                if ( aa <= A->a && A->z <= az ) {
+                        obj.erase( A++);
+                        continue;
+                }
+                if ( A->a < aa && az < A->z ) {
+                        obj.emplace( next(A), az, A->z);
+                        A->z = aa;
+                        break;
+                }
+                if ( A->a < aa && aa < A->z )
+                        A->z = aa;
+                if ( A->a < az && az < A->z )
+                        A->a = az;
+                ++A;
+        }
 }
 
 
@@ -90,28 +90,28 @@ __attribute__ ((pure))
 SArtifacts::
 region_dirty_fraction( const double ra, const double rz) const
 {
-	size_t	dirty = 0;
-	for ( auto& A : obj ) {
-		if ( ra > A.z )
-			continue;
-		if ( rz < A.a )
-			break;
-
-		if ( A.a < ra && A.z > rz )
-			return 1.;
-		if ( A.a > ra && A.z < rz ) {
-			dirty += (A.z - A.a);
-			continue;
-		}
-
-		if ( A.a < ra )
-			dirty = (A.z - ra);
-		else {
-			dirty += (A.z - rz);
-			break;
-		}
-	}
-	return dirty / (rz - ra);
+        size_t        dirty = 0;
+        for ( auto& A : obj ) {
+                if ( ra > A.z )
+                        continue;
+                if ( rz < A.a )
+                        break;
+
+                if ( A.a < ra && A.z > rz )
+                        return 1.;
+                if ( A.a > ra && A.z < rz ) {
+                        dirty += (A.z - A.a);
+                        continue;
+                }
+
+                if ( A.a < ra )
+                        dirty = (A.z - ra);
+                else {
+                        dirty += (A.z - rz);
+                        break;
+                }
+        }
+        return dirty / (rz - ra);
 }
 
 
@@ -119,11 +119,11 @@ unsigned long
 SArtifacts::
 dirty_signature() const
 {
-	string sig ("a");
-	for ( auto &A : obj )
-		sig += (to_string((long long int)A.a) + ':' + to_string((long long int)A.z));
-	sig += to_string(factor) + to_string( (long long int)dampen_window_type);
-	return hash<std::string>() (sig);
+        string sig ("a");
+        for ( auto &A : obj )
+                sig += (to_string((long long int)A.a) + ':' + to_string((long long int)A.z));
+        sig += to_string(factor) + to_string( (long long int)dampen_window_type);
+        return hash<std::string>() (sig);
 }
 
 
@@ -131,10 +131,10 @@ unsigned long
 SFilterPack::
 dirty_signature() const
 {
-	return hash<string>() (
-		agh::str::sasprintf(
-			"%g%d%g%d%d",
-			low_pass_cutoff, low_pass_order, high_pass_cutoff, high_pass_order, (int)notch_filter));
+        return hash<string>() (
+                agh::str::sasprintf(
+                        "%g%d%g%d%d",
+                        low_pass_cutoff, low_pass_order, high_pass_cutoff, high_pass_order, (int)notch_filter));
 }
 
 
@@ -145,79 +145,79 @@ int
 CSource::
 load_ancillary_files()
 {
-	int retval = 0;
-
-	for ( int h = 0; h < (int)n_channels(); ++h ) {
-		auto& H = channel_by_id(h);
-
-	      // 1. artifacts
-		{
-			ifstream thomas (make_fname_artifacts( H));
-			if ( not thomas.good() )
-				goto step2;
-
-			auto& AA = artifacts(h);
-			while ( !thomas.eof() ) {
-				double aa = NAN, az = NAN;
-				thomas >> aa >> az;
-				if ( not isfinite(aa) || not isfinite(az) ) {
-					retval = -1;
-					break;
-				}
-				AA.mark_artifact( aa, az);
-			}
-		}
-
-	step2:
-	      // 2. annotations
-		{
-			ifstream fd (make_fname_annotations( H));
-			if ( not fd.good() )
-				goto step3;
-
-			auto& AA = annotations(h);
-			while ( fd.good() and not fd.eof() ) {
-				int type = -1;
-				double aa = NAN, az = NAN;
-				string an;
-				fd >> type >> aa >> az;
-				getline( fd, an, SAnnotation::EOA);
-				if ( isfinite(aa) and isfinite(az) and
-				     aa < az and az <= recording_time()
-				     and type < SAnnotation::TType_total and type >= 0 )
-					AA.emplace_back(
-						aa, az,
-						agh::str::trim(an),
-						(SAnnotation::TType)type);
-				else {
-					retval = -1;
-					break;
-				}
-			}
-			AA.sort();
-		}
-	step3:
-		;
-	}
+        int retval = 0;
+
+        for ( int h = 0; h < (int)n_channels(); ++h ) {
+                auto& H = channel_by_id(h);
+
+              // 1. artifacts
+                {
+                        ifstream thomas (make_fname_artifacts( H));
+                        if ( not thomas.good() )
+                                goto step2;
+
+                        auto& AA = artifacts(h);
+                        while ( !thomas.eof() ) {
+                                double aa = NAN, az = NAN;
+                                thomas >> aa >> az;
+                                if ( not isfinite(aa) || not isfinite(az) ) {
+                                        retval = -1;
+                                        break;
+                                }
+                                AA.mark_artifact( aa, az);
+                        }
+                }
+
+        step2:
+              // 2. annotations
+                {
+                        ifstream fd (make_fname_annotations( H));
+                        if ( not fd.good() )
+                                goto step3;
+
+                        auto& AA = annotations(h);
+                        while ( fd.good() and not fd.eof() ) {
+                                int type = -1;
+                                double aa = NAN, az = NAN;
+                                string an;
+                                fd >> type >> aa >> az;
+                                getline( fd, an, SAnnotation::EOA);
+                                if ( isfinite(aa) and isfinite(az) and
+                                     aa < az and az <= recording_time()
+                                     and type < SAnnotation::TType_total and type >= 0 )
+                                        AA.emplace_back(
+                                                aa, az,
+                                                agh::str::trim(an),
+                                                (SAnnotation::TType)type);
+                                else {
+                                        retval = -1;
+                                        break;
+                                }
+                        }
+                        AA.sort();
+                }
+        step3:
+                ;
+        }
 
       // 3. filters
-	{
-		ifstream thomas (make_fname_filters(_filename));
-		if ( !thomas.good() )
-			for ( int h = 0; h < (int)n_channels(); ++h ) {
-				auto& AA = filters(h);
-
-				unsigned lpo = -1, hpo = -1, nf = -1;
-				double lpc = 0., hpc = 0.;
-				thomas >> lpc >> lpo
-				       >> hpc >> hpo >> nf;
-				AA = {lpc, lpo, hpc, hpo, (SFilterPack::TNotchFilter)nf};
-				if ( not AA.is_valid() )
-					AA.reset();
-			}
-	}
-
-	return retval;
+        {
+                ifstream thomas (make_fname_filters(_filename));
+                if ( !thomas.good() )
+                        for ( int h = 0; h < (int)n_channels(); ++h ) {
+                                auto& AA = filters(h);
+
+                                unsigned lpo = -1, hpo = -1, nf = -1;
+                                double lpc = 0., hpc = 0.;
+                                thomas >> lpc >> lpo
+                                       >> hpc >> hpo >> nf;
+                                AA = {lpc, lpo, hpc, hpo, (SFilterPack::TNotchFilter)nf};
+                                if ( not AA.is_valid() )
+                                        AA.reset();
+                        }
+        }
+
+        return retval;
 }
 
 
@@ -228,52 +228,52 @@ int
 CSource::
 save_ancillary_files()
 {
-	int retval = 0;
-	for ( int h = 0; h < (int)n_channels(); ++h ) {
-		auto& H = channel_by_id(h);
-		{
-			auto& AA = artifacts(h);
-			if ( not AA.empty() ) {
-				ofstream thomas (make_fname_artifacts( H), ios_base::trunc);
-				for ( auto &A : AA() )
-					thomas << A.a << ' ' << A.z << endl;
-				if ( not thomas.good() )
-					retval = -1;
-			} else
-				if ( unlink( make_fname_artifacts( H).c_str()) ) {}
-		}
-
-		{
-			auto& AA = annotations(h);
-
-			auto fname = make_fname_annotations( H);
-
-			if ( not AA.empty() ) {
-				ofstream thomas (fname, ios_base::trunc);
-				for ( auto &A : AA ) {
-					thomas << (int)A.type << ' '
-					       << A.span.a << ' ' << A.span.z << ' '
-					       << A.label << SAnnotation::EOA << endl;
-					if ( not thomas.good() )
-						retval = -1;
-				}
-
-			} else
-				if ( unlink( fname.c_str()) ) {}
-		}
-	}
-	ofstream thomas (make_fname_filters( filename()), ios_base::trunc);
-	if ( thomas.good() )
-		for ( int h = 0; h < (int)n_channels(); ++h ) {
-			auto& AA = filters(h);
-			thomas << AA.low_pass_cutoff << ' ' << AA.low_pass_order << ' '
-			       << AA.high_pass_cutoff << ' ' << AA.high_pass_order << ' '
-			       << (int)AA.notch_filter << endl;
-			if ( not thomas.good() )
-				retval = -1;
-		}
-
-	return retval;
+        int retval = 0;
+        for ( int h = 0; h < (int)n_channels(); ++h ) {
+                auto& H = channel_by_id(h);
+                {
+                        auto& AA = artifacts(h);
+                        if ( not AA.empty() ) {
+                                ofstream thomas (make_fname_artifacts( H), ios_base::trunc);
+                                for ( auto &A : AA() )
+                                        thomas << A.a << ' ' << A.z << endl;
+                                if ( not thomas.good() )
+                                        retval = -1;
+                        } else
+                                if ( unlink( make_fname_artifacts( H).c_str()) ) {}
+                }
+
+                {
+                        auto& AA = annotations(h);
+
+                        auto fname = make_fname_annotations( H);
+
+                        if ( not AA.empty() ) {
+                                ofstream thomas (fname, ios_base::trunc);
+                                for ( auto &A : AA ) {
+                                        thomas << (int)A.type << ' '
+                                               << A.span.a << ' ' << A.span.z << ' '
+                                               << A.label << SAnnotation::EOA << endl;
+                                        if ( not thomas.good() )
+                                                retval = -1;
+                                }
+
+                        } else
+                                if ( unlink( fname.c_str()) ) {}
+                }
+        }
+        ofstream thomas (make_fname_filters( filename()), ios_base::trunc);
+        if ( thomas.good() )
+                for ( int h = 0; h < (int)n_channels(); ++h ) {
+                        auto& AA = filters(h);
+                        thomas << AA.low_pass_cutoff << ' ' << AA.low_pass_order << ' '
+                               << AA.high_pass_cutoff << ' ' << AA.high_pass_order << ' '
+                               << (int)AA.notch_filter << endl;
+                        if ( not thomas.good() )
+                                retval = -1;
+                }
+
+        return retval;
 }
 
 
@@ -285,12 +285,12 @@ sigfile::CSource::
 CSource (CSource&& rv)
       : _subject (move(rv._subject))
 {
-	swap( _filename, rv._filename);
-	_status     = rv._status;
-	_flags      = rv._flags;
+        swap( _filename, rv._filename);
+        _status     = rv._status;
+        _flags      = rv._flags;
 
-	_start_time = rv._start_time;
-	_end_time   = rv._end_time;
+        _start_time = rv._start_time;
+        _end_time   = rv._end_time;
 }
 
 
@@ -300,16 +300,16 @@ int
 CSource::
 set_start_time( time_t s)
 {
-	_end_time = (_start_time = s)
-		+ (time_t)recording_time();
+        _end_time = (_start_time = s)
+                + (time_t)recording_time();
 
-	char b[9];
-	strftime( b, 9, "%d.%m.%y", localtime(&s));
-	set_recording_date( b);
-	strftime( b, 9, "%H.%M.%s", localtime(&s));
-	set_recording_time( b);
+        char b[9];
+        strftime( b, 9, "%d.%m.%y", localtime(&s));
+        set_recording_date( b);
+        strftime( b, 9, "%H.%M.%s", localtime(&s));
+        set_recording_time( b);
 
-	return 0;
+        return 0;
 }
 
 
@@ -320,45 +320,45 @@ tuple<string, string>
 CSource::
 figure_session_and_episode()
 {
-	string session, episode;
+        string session, episode;
 
-	// (a) parsed from RecordingID_raw
-	char int_session[81], int_episode[81];
-	string rec_id_isolated (agh::str::trim( recording_id()));
+        // (a) parsed from RecordingID_raw
+        char int_session[81], int_episode[81];
+        string rec_id_isolated (agh::str::trim( recording_id()));
 #define T "%80[-a-zA-Z0-9 _]"
-	if ( sscanf( rec_id_isolated.c_str(), T "," T,      int_episode, int_session) == 2 ||
-	     sscanf( rec_id_isolated.c_str(), T ":" T,      int_session, int_episode) == 2 ||
-	     sscanf( rec_id_isolated.c_str(), T "/"  T,     int_session, int_episode) == 2 ||
-	     sscanf( rec_id_isolated.c_str(), T " (" T ")", int_session, int_episode) == 2 )
-		;
-	else
-		_status |= bad_session_or_episode;
+        if ( sscanf( rec_id_isolated.c_str(), T "," T,      int_episode, int_session) == 2 ||
+             sscanf( rec_id_isolated.c_str(), T ":" T,      int_session, int_episode) == 2 ||
+             sscanf( rec_id_isolated.c_str(), T "/"  T,     int_session, int_episode) == 2 ||
+             sscanf( rec_id_isolated.c_str(), T " (" T ")", int_session, int_episode) == 2 )
+                ;
+        else
+                _status |= bad_session_or_episode;
 #undef T
 
-	// (b) identified from file name
-	///// if ( sscanf( agh::fs::path_elements( filename).back().c_str(), "%*s-%d.%s", ) == 3 )
-	size_t	basename_start = _filename.rfind( '/'),
-		dot = _filename.rfind('.');
-	string fn_episode =
-		_filename.substr(
-			basename_start + 1,
-			dot - basename_start - 1);
-	// chip away '-1' if present
-	if ( fn_episode.size() >= 3 /* strlen("a-1") */ ) {
-		size_t sz = fn_episode.size();
-		if ( fn_episode[sz-2] == '-' && isdigit(fn_episode[sz-1]) )
-			fn_episode.erase( sz-2, 2);
-	}
-
-	if ( _status & bad_session_or_episode ) { // (a) failed
-		episode.assign( fn_episode);    // use RecordingID_raw as Session
-		session.assign( rec_id_isolated);
-	} else {
-		episode.assign( int_episode);
-		session.assign( int_session);
-	}
-
-	return make_tuple( session, episode);
+        // (b) identified from file name
+        ///// if ( sscanf( agh::fs::path_elements( filename).back().c_str(), "%*s-%d.%s", ) == 3 )
+        size_t        basename_start = _filename.rfind( '/'),
+                dot = _filename.rfind('.');
+        string fn_episode =
+                _filename.substr(
+                        basename_start + 1,
+                        dot - basename_start - 1);
+        // chip away '-1' if present
+        if ( fn_episode.size() >= 3 /* strlen("a-1") */ ) {
+                size_t sz = fn_episode.size();
+                if ( fn_episode[sz-2] == '-' && isdigit(fn_episode[sz-1]) )
+                        fn_episode.erase( sz-2, 2);
+        }
+
+        if ( _status & bad_session_or_episode ) { // (a) failed
+                episode.assign( fn_episode);    // use RecordingID_raw as Session
+                session.assign( rec_id_isolated);
+        } else {
+                episode.assign( int_episode);
+                session.assign( int_session);
+        }
+
+        return make_tuple( session, episode);
 }
 
 
@@ -368,24 +368,24 @@ void
 CSource::
 figure_times( const string& date_s, const string& time_s, TAcceptTimeFormat)
 {
-	struct tm ts;
-	char *p;
-	//memset( &ts, 0, sizeof(struct tm));
-	ts.tm_isdst = 0;  // importantly
-	p = strptime( date_s.c_str(), "%d.%m.%y", &ts);
-	if ( p == NULL || *p != '\0' ) {
-		_status |= bad_datetime;
-	}
-	p = strptime( time_s.c_str(), "%H.%M.%S", &ts);
-	if ( p == NULL || *p != '\0' ) {
-		_status |= bad_datetime;
-	}
-
-	// if ( ts.tm_year < 50 )
-	// 	ts.tm_year += 100;
-	_start_time = mktime( &ts);
-	if ( _start_time == (time_t)-1 )
-		_status |= bad_datetime;
+        struct tm ts;
+        char *p;
+        //memset( &ts, 0, sizeof(struct tm));
+        ts.tm_isdst = 0;  // importantly
+        p = strptime( date_s.c_str(), "%d.%m.%y", &ts);
+        if ( p == NULL || *p != '\0' ) {
+                _status |= bad_datetime;
+        }
+        p = strptime( time_s.c_str(), "%H.%M.%S", &ts);
+        if ( p == NULL || *p != '\0' ) {
+                _status |= bad_datetime;
+        }
+
+        // if ( ts.tm_year < 50 )
+        //         ts.tm_year += 100;
+        _start_time = mktime( &ts);
+        if ( _start_time == (time_t)-1 )
+                _status |= bad_datetime;
 }
 
 
@@ -395,93 +395,93 @@ figure_times( const string& date_s, const string& time_s, TAcceptTimeFormat)
 valarray<TFloat>
 CSource::
 get_region_filtered_smpl( const int h,
-			  const size_t smpla, const size_t smplz) const
+                          const size_t smpla, const size_t smplz) const
 {
-	valarray<TFloat> recp =
-		get_region_original_smpl( h, smpla, smplz);
-	if ( recp.size() == 0 )
-		return valarray<TFloat> (0);
-	// and zeromean
-       	recp -= (recp.sum() / recp.size());
+        valarray<TFloat> recp =
+                get_region_original_smpl( h, smpla, smplz);
+        if ( recp.size() == 0 )
+                return valarray<TFloat> (0);
+        // and zeromean
+               recp -= (recp.sum() / recp.size());
 
-	size_t this_samplerate = samplerate(h);
+        size_t this_samplerate = samplerate(h);
 
       // artifacts
-	const auto& AA = artifacts(h);
-	for ( const auto& A : AA() ) {
-		size_t	Aa = A.a * this_samplerate,
-			Az = A.z * this_samplerate;
-		if ( unlikely (Aa >= smplz) )
-			break;
-		size_t	run = (Az - Aa),
-			window = min( run, this_samplerate),
-			t;
-		if ( unlikely (Az > smplz) )
-			run = smplz - Aa;
-		valarray<TFloat>
-			W (run);
-
-		if ( run > window ) {
-			// construct a vector of multipliers using an INVERTED windowing function on the
-			// first and last windows of the run
-			size_t	t0;
-			for ( t = 0; t < window/2; ++t )
-				W[t] = (1 - sigproc::winf[(size_t)AA.dampen_window_type]( t, window));
-			t0 = run-window;  // start of the last window but one
-			for ( t = window/2; t < window; ++t )
-				W[t0 + t] = (1 - sigproc::winf[(size_t)AA.dampen_window_type]( t, window));
-			// AND, connect mid-first to mid-last windows (at lowest value of the window)
-			TFloat minimum = sigproc::winf[(size_t)AA.dampen_window_type]( window/2, window);
-			W[ slice(window/2, run-window, 1) ] =
-				(1. - minimum);
-		} else  // run is shorter than samplerate (1 sec)
-			for ( t = 0; t < window; ++t )
-				W[t] = (1 - sigproc::winf[(size_t)AA.dampen_window_type]( t, window));
-
-		// now gently apply the multiplier vector onto the artifacts
-		recp[ slice(Aa, run, 1) ] *= (W * (TFloat)AA.factor);
-	}
+        const auto& AA = artifacts(h);
+        for ( const auto& A : AA() ) {
+                size_t        Aa = A.a * this_samplerate,
+                        Az = A.z * this_samplerate;
+                if ( unlikely (Aa >= smplz) )
+                        break;
+                size_t        run = (Az - Aa),
+                        window = min( run, this_samplerate),
+                        t;
+                if ( unlikely (Az > smplz) )
+                        run = smplz - Aa;
+                valarray<TFloat>
+                        W (run);
+
+                if ( run > window ) {
+                        // construct a vector of multipliers using an INVERTED windowing function on the
+                        // first and last windows of the run
+                        size_t        t0;
+                        for ( t = 0; t < window/2; ++t )
+                                W[t] = (1 - sigproc::winf[(size_t)AA.dampen_window_type]( t, window));
+                        t0 = run-window;  // start of the last window but one
+                        for ( t = window/2; t < window; ++t )
+                                W[t0 + t] = (1 - sigproc::winf[(size_t)AA.dampen_window_type]( t, window));
+                        // AND, connect mid-first to mid-last windows (at lowest value of the window)
+                        TFloat minimum = sigproc::winf[(size_t)AA.dampen_window_type]( window/2, window);
+                        W[ slice(window/2, run-window, 1) ] =
+                                (1. - minimum);
+                } else  // run is shorter than samplerate (1 sec)
+                        for ( t = 0; t < window; ++t )
+                                W[t] = (1 - sigproc::winf[(size_t)AA.dampen_window_type]( t, window));
+
+                // now gently apply the multiplier vector onto the artifacts
+                recp[ slice(Aa, run, 1) ] *= (W * (TFloat)AA.factor);
+        }
 
       // filters
-	const auto& ff = filters(h);
-	if ( ff.low_pass_cutoff > 0. && ff.high_pass_cutoff > 0. &&
-	     ff.low_pass_order  > 0  && ff.high_pass_order  > 0 ) {
-		auto tmp (exstrom::band_pass(
-				  recp, this_samplerate,
-				  ff.high_pass_cutoff, ff.low_pass_cutoff,
-				  ff.low_pass_order, true));
-		recp = tmp;
-	} else {
-		if ( ff.low_pass_cutoff > 0. && ff.low_pass_order > 0 ) {
-			auto tmp (exstrom::low_pass(
-					  recp, this_samplerate,
-					  ff.low_pass_cutoff, ff.low_pass_order, true));
-			recp = tmp;
-		}
-		if ( ff.high_pass_cutoff > 0. && ff.high_pass_order > 0 ) {
-			auto tmp (exstrom::high_pass(
-					  recp, this_samplerate,
-					  ff.high_pass_cutoff, ff.high_pass_order, true));
-			recp = tmp;
-		}
-	}
-
-	switch ( ff.notch_filter ) {
-	case SFilterPack::TNotchFilter::at50Hz:
-		recp = exstrom::band_stop( recp, this_samplerate,
-					   48, 52, 1, true);  // hardcoded numerals spotted!
-	    break;
-	case SFilterPack::TNotchFilter::at60Hz:
-		recp = exstrom::band_stop( recp, this_samplerate,
-					   58, 62, 1, true);
-	    break;
-	case SFilterPack::TNotchFilter::none:
-	default:
-	    break;
-	}
-
-	// filters happen to append samples, so
-	return move(recp[ slice (0, smplz-smpla, 1)]);
+        const auto& ff = filters(h);
+        if ( ff.low_pass_cutoff > 0. && ff.high_pass_cutoff > 0. &&
+             ff.low_pass_order  > 0  && ff.high_pass_order  > 0 ) {
+                auto tmp (exstrom::band_pass(
+                                  recp, this_samplerate,
+                                  ff.high_pass_cutoff, ff.low_pass_cutoff,
+                                  ff.low_pass_order, true));
+                recp = tmp;
+        } else {
+                if ( ff.low_pass_cutoff > 0. && ff.low_pass_order > 0 ) {
+                        auto tmp (exstrom::low_pass(
+                                          recp, this_samplerate,
+                                          ff.low_pass_cutoff, ff.low_pass_order, true));
+                        recp = tmp;
+                }
+                if ( ff.high_pass_cutoff > 0. && ff.high_pass_order > 0 ) {
+                        auto tmp (exstrom::high_pass(
+                                          recp, this_samplerate,
+                                          ff.high_pass_cutoff, ff.high_pass_order, true));
+                        recp = tmp;
+                }
+        }
+
+        switch ( ff.notch_filter ) {
+        case SFilterPack::TNotchFilter::at50Hz:
+                recp = exstrom::band_stop( recp, this_samplerate,
+                                           48, 52, 1, true);  // hardcoded numerals spotted!
+            break;
+        case SFilterPack::TNotchFilter::at60Hz:
+                recp = exstrom::band_stop( recp, this_samplerate,
+                                           58, 62, 1, true);
+            break;
+        case SFilterPack::TNotchFilter::none:
+        default:
+            break;
+        }
+
+        // filters happen to append samples, so
+        return move(recp[ slice (0, smplz-smpla, 1)]);
 }
 
 
@@ -490,34 +490,34 @@ get_region_filtered_smpl( const int h,
 int
 CSource::
 export_original( const int h,
-		 const string& fname) const
+                 const string& fname) const
 {
-	valarray<TFloat> signal = get_signal_original( h);
-	FILE *fd = fopen( fname.c_str(), "w");
-	if ( fd ) {
-		for ( size_t i = 0; i < signal.size(); ++i )
-			fprintf( fd, "%g\n", signal[i]);
-		fclose( fd);
-		return 0;
-	} else
-		return -1;
+        valarray<TFloat> signal = get_signal_original( h);
+        FILE *fd = fopen( fname.c_str(), "w");
+        if ( fd ) {
+                for ( size_t i = 0; i < signal.size(); ++i )
+                        fprintf( fd, "%g\n", signal[i]);
+                fclose( fd);
+                return 0;
+        } else
+                return -1;
 }
 
 
 int
 CSource::
 export_filtered( const int h,
-		 const string& fname) const
+                 const string& fname) const
 {
-	valarray<TFloat> signal = get_signal_filtered( h);
-	FILE *fd = fopen( fname.c_str(), "w");
-	if ( fd ) {
-		for ( size_t i = 0; i < signal.size(); ++i )
-			fprintf( fd, "%g\n", signal[i]);
-		fclose( fd);
-		return 0;
-	} else
-		return -1;
+        valarray<TFloat> signal = get_signal_filtered( h);
+        FILE *fd = fopen( fname.c_str(), "w");
+        if ( fd ) {
+                for ( size_t i = 0; i < signal.size(); ++i )
+                        fprintf( fd, "%g\n", signal[i]);
+                fclose( fd);
+                return 0;
+        } else
+                return -1;
 }
 
 
@@ -526,33 +526,33 @@ string
 CSource::
 explain_status( const int status)
 {
-	list<string> recv;
-	if ( status & sysfail )
-		recv.emplace_back( "stat or fopen error");
-	if ( status & bad_header )
-		recv.emplace_back( "Ill-formed header");
-	if ( status & missing_patient_id )
-		recv.emplace_back( "Missing PatientId");
-	if ( status & bad_numfld )
-		recv.emplace_back( "Garbage in numerical fields");
-	if ( status & bad_datetime )
-		recv.emplace_back( "Date/time field ill-formed");
-	if ( status & bad_session_or_episode )
-		recv.emplace_back( "No session/episode information in RecordingID");
-	if ( status & non1020_channel )
-		recv.emplace_back( "Channel designation not following the 10-20 system");
-	if ( status & invalid_subject_details )
-		recv.emplace_back( "PatientId has incomplete or ill-formed subject details");
-	if ( status & nonkemp_signaltype )
-		recv.emplace_back( "Signal type not listed in Kemp et al");
-	if ( status & dup_channels )
-		recv.emplace_back( "Duplicate channel names");
-	if ( status & too_many_channels )
-		recv.emplace_back( string("Number of channels grearter than ") + to_string(max_channels));
-	if ( status & conflicting_channel_type )
-		recv.emplace_back( "Explicitly specified signal type does not match type of known channel name");
-
-	return recv.empty() ? "" : agh::str::join(recv, "\n") + "\n";
+        list<string> recv;
+        if ( status & sysfail )
+                recv.emplace_back( "stat or fopen error");
+        if ( status & bad_header )
+                recv.emplace_back( "Ill-formed header");
+        if ( status & missing_patient_id )
+                recv.emplace_back( "Missing PatientId");
+        if ( status & bad_numfld )
+                recv.emplace_back( "Garbage in numerical fields");
+        if ( status & bad_datetime )
+                recv.emplace_back( "Date/time field ill-formed");
+        if ( status & bad_session_or_episode )
+                recv.emplace_back( "No session/episode information in RecordingID");
+        if ( status & non1020_channel )
+                recv.emplace_back( "Channel designation not following the 10-20 system");
+        if ( status & invalid_subject_details )
+                recv.emplace_back( "PatientId has incomplete or ill-formed subject details");
+        if ( status & nonkemp_signaltype )
+                recv.emplace_back( "Signal type not listed in Kemp et al");
+        if ( status & dup_channels )
+                recv.emplace_back( "Duplicate channel names");
+        if ( status & too_many_channels )
+                recv.emplace_back( string("Number of channels grearter than ") + to_string(max_channels));
+        if ( status & conflicting_channel_type )
+                recv.emplace_back( "Explicitly specified signal type does not match type of known channel name");
+
+        return recv.empty() ? "" : agh::str::join(recv, "\n") + "\n";
 }
 
 
diff --git a/upstream/src/libsigfile/source-base.hh b/upstream/src/libsigfile/source-base.hh
index 33019a7..0c7d487 100644
--- a/upstream/src/libsigfile/source-base.hh
+++ b/upstream/src/libsigfile/source-base.hh
@@ -35,40 +35,40 @@ bool is_fname_ext_supported( const string&);
 inline string
 make_fname_hypnogram( const string& filename, size_t pagesize)
 {
-	return agh::fs::make_fname_base(
-		filename,
-		supported_sigfile_extensions,
-		agh::fs::TMakeFnameOption::hidden)
-		+ "-" + to_string( (long long unsigned)pagesize) + ".hypnogram";
+        return agh::fs::make_fname_base(
+                filename,
+                supported_sigfile_extensions,
+                agh::fs::TMakeFnameOption::hidden)
+                + "-" + to_string( (long long unsigned)pagesize) + ".hypnogram";
 }
 
 inline string
 make_fname_artifacts( const string& filename, const SChannel& channel)
 {
-	return agh::fs::make_fname_base(
-		filename,
-		supported_sigfile_extensions,
-		agh::fs::TMakeFnameOption::hidden)
-		+ "-" + channel.name() + ".af";
+        return agh::fs::make_fname_base(
+                filename,
+                supported_sigfile_extensions,
+                agh::fs::TMakeFnameOption::hidden)
+                + "-" + channel.name() + ".af";
 }
 
 inline string
 make_fname_annotations( const string& filename, const SChannel& channel)
 {
-	return agh::fs::make_fname_base(
-		filename,
-		supported_sigfile_extensions,
-		agh::fs::TMakeFnameOption::hidden)
-		+ "-" + channel.name() + ".annotations";
+        return agh::fs::make_fname_base(
+                filename,
+                supported_sigfile_extensions,
+                agh::fs::TMakeFnameOption::hidden)
+                + "-" + channel.name() + ".annotations";
 }
 
 inline string
 make_fname_filters( const string& _filename)
 {
-	return agh::fs::make_fname_base( _filename,
-		supported_sigfile_extensions,
-		agh::fs::TMakeFnameOption::hidden)
-		+ ".filters";
+        return agh::fs::make_fname_base( _filename,
+                supported_sigfile_extensions,
+                agh::fs::TMakeFnameOption::hidden)
+                + ".filters";
 }
 
 
@@ -78,51 +78,51 @@ make_fname_filters( const string& _filename)
 
 
 struct SArtifacts {
-	SArtifacts (float f_ = 0.95,
-		    sigproc::TWinType dwt_ = sigproc::TWinType::welch)
-	      : factor (f_),
-		dampen_window_type (dwt_)
-		{}
-
-	list<agh::alg::SSpan<double>>
-		obj;
-	float	factor;
-	sigproc::TWinType
-		dampen_window_type;
-
-	list<agh::alg::SSpan<double>>&
-	operator() ()
-		{
-			return obj;
-		}
-	const list<agh::alg::SSpan<double>>&
-	operator() () const
-		{
-			return obj;
-		}
-
-	bool empty() const
-		{
-			return obj.empty();
-		}
-	size_t total() const
-		{
-			size_t q = 0;
-			for ( auto& A : obj )
-				q += (A.z - A.a);
-			return q;
-		}
-
-	void mark_artifact( double aa, double az);
-	void clear_artifact( double aa, double az);
-	void clear_all()
-		{
-			obj.clear();
-		}
-
-	float region_dirty_fraction( double a, double z) const;
-
-	unsigned long dirty_signature() const;
+        SArtifacts (float f_ = 0.95,
+                    sigproc::TWinType dwt_ = sigproc::TWinType::welch)
+              : factor (f_),
+                dampen_window_type (dwt_)
+                {}
+
+        list<agh::alg::SSpan<double>>
+                obj;
+        float        factor;
+        sigproc::TWinType
+                dampen_window_type;
+
+        list<agh::alg::SSpan<double>>&
+        operator() ()
+                {
+                        return obj;
+                }
+        const list<agh::alg::SSpan<double>>&
+        operator() () const
+                {
+                        return obj;
+                }
+
+        bool empty() const
+                {
+                        return obj.empty();
+                }
+        size_t total() const
+                {
+                        size_t q = 0;
+                        for ( auto& A : obj )
+                                q += (A.z - A.a);
+                        return q;
+                }
+
+        void mark_artifact( double aa, double az);
+        void clear_artifact( double aa, double az);
+        void clear_all()
+                {
+                        obj.clear();
+                }
+
+        float region_dirty_fraction( double a, double z) const;
+
+        unsigned long dirty_signature() const;
 };
 
 
@@ -130,33 +130,33 @@ struct SArtifacts {
 
 
 struct SAnnotation {
-	static const char EOA = '$';
-
-	agh::alg::SSpan<double> span;
-	string label;
-	enum TType {
-		plain,
-		phasic_event_spindle,
-		phasic_event_K_complex,
-		eyeblink,
-		TType_total
-	};
-	TType type;
-
-	SAnnotation (double aa, double az, const string& l, TType t = TType::plain)
-	      : span {aa, az},
-		label (l),
-		type (t)
-		{}
-
-	bool operator==( const SAnnotation& rv) const
-		{
-			return span == rv.span && label == rv.label && type == rv.type;
-		}
-	bool operator<( const SAnnotation& rv) const
-		{
-			return span < rv.span;
-		}
+        static const char EOA = '$';
+
+        agh::alg::SSpan<double> span;
+        string label;
+        enum TType {
+                plain,
+                phasic_event_spindle,
+                phasic_event_K_complex,
+                eyeblink,
+                TType_total
+        };
+        TType type;
+
+        SAnnotation (double aa, double az, const string& l, TType t = TType::plain)
+              : span {aa, az},
+                label (l),
+                type (t)
+                {}
+
+        bool operator==( const SAnnotation& rv) const
+                {
+                        return span == rv.span && label == rv.label && type == rv.type;
+                }
+        bool operator<( const SAnnotation& rv) const
+                {
+                        return span < rv.span;
+                }
 };
 
 
@@ -164,12 +164,12 @@ struct SAnnotation {
 
 inline void
 mark_annotation( list<SAnnotation>& annotations,
-		 double aa, double az,
-		 const string& label,
-		 SAnnotation::TType t = SAnnotation::TType::plain)
+                 double aa, double az,
+                 const string& label,
+                 SAnnotation::TType t = SAnnotation::TType::plain)
 {
-	annotations.emplace_back( aa, az, label, t);
-	annotations.sort();
+        annotations.emplace_back( aa, az, label, t);
+        annotations.sort();
 }
 
 
@@ -177,293 +177,293 @@ mark_annotation( list<SAnnotation>& annotations,
 
 
 struct SFilterPack {
-	enum TNotchFilter : int {
-		none, at50Hz, at60Hz, TNotchFilter_total
-	};
-
-	SFilterPack ()
-	      : low_pass_cutoff (0.),
-		low_pass_order (0),
-		high_pass_cutoff (0.),
-		high_pass_order (0),
-		notch_filter (TNotchFilter::none)
-		{}
-	SFilterPack (double lpo, unsigned lpc, double hpo, unsigned hpc, TNotchFilter nf)
-	      : low_pass_cutoff (lpc),
-		low_pass_order (lpo),
-		high_pass_cutoff (hpc),
-		high_pass_order (hpo),
-		notch_filter (nf)
-		{}
-
-	bool have_filters() const
-		{
-			return low_pass_cutoff > 0. || high_pass_cutoff > 0. ||
-				notch_filter != SFilterPack::TNotchFilter::none;
-		}
-	bool is_valid() const
-		{
-			return high_pass_order < 5 &&
-			       low_pass_order < 5 &&
-			       notch_filter >= TNotchFilter::none &&
-			       notch_filter < TNotchFilter::TNotchFilter_total;
-		}
-	void reset()
-		{
-			high_pass_cutoff = low_pass_cutoff = 0.;
-			high_pass_order = low_pass_order = 0;
-			notch_filter = TNotchFilter::none;
-		}
-
-	double		low_pass_cutoff;
-	unsigned	low_pass_order;
-	double		high_pass_cutoff;
-	unsigned	high_pass_order;
-
-	TNotchFilter
-		notch_filter;
-
-	unsigned long dirty_signature() const;
+        enum TNotchFilter : int {
+                none, at50Hz, at60Hz, TNotchFilter_total
+        };
+
+        SFilterPack ()
+              : low_pass_cutoff (0.),
+                low_pass_order (0),
+                high_pass_cutoff (0.),
+                high_pass_order (0),
+                notch_filter (TNotchFilter::none)
+                {}
+        SFilterPack (double lpo, unsigned lpc, double hpo, unsigned hpc, TNotchFilter nf)
+              : low_pass_cutoff (lpc),
+                low_pass_order (lpo),
+                high_pass_cutoff (hpc),
+                high_pass_order (hpo),
+                notch_filter (nf)
+                {}
+
+        bool have_filters() const
+                {
+                        return low_pass_cutoff > 0. || high_pass_cutoff > 0. ||
+                                notch_filter != SFilterPack::TNotchFilter::none;
+                }
+        bool is_valid() const
+                {
+                        return high_pass_order < 5 &&
+                               low_pass_order < 5 &&
+                               notch_filter >= TNotchFilter::none &&
+                               notch_filter < TNotchFilter::TNotchFilter_total;
+                }
+        void reset()
+                {
+                        high_pass_cutoff = low_pass_cutoff = 0.;
+                        high_pass_order = low_pass_order = 0;
+                        notch_filter = TNotchFilter::none;
+                }
+
+        double                low_pass_cutoff;
+        unsigned        low_pass_order;
+        double                high_pass_cutoff;
+        unsigned        high_pass_order;
+
+        TNotchFilter
+                notch_filter;
+
+        unsigned long dirty_signature() const;
 };
 
 
 
 
 class CSource {
-	friend class CTypedSource;
+        friend class CTypedSource;
     public:
-	enum TFlags {
-		no_ancillary_files         = 1<<1,
-		no_field_consistency_check = 1<<2,
-	};
-	enum TStatus : int_least32_t {
-		ok			  = 0,
-		bad_header		  = (1 <<  0),
-		bad_numfld		  = (1 <<  1),
-		bad_datetime		  = (1 <<  2),
-		bad_session_or_episode	  = (1 <<  3),
-		nonkemp_signaltype	  = (1 <<  4),
-		non1020_channel		  = (1 <<  5),
-		dup_channels		  = (1 <<  6),
-		sysfail			  = (1 <<  7),
-		too_many_channels	  = (1 <<  8),
-		missing_patient_id        = (1 <<  9),
-		invalid_subject_details   = (1 << 10),
-		conflicting_channel_type  = (1 << 11),
-	};
-	const static unsigned COMMON_STATUS_BITS = 11;
+        enum TFlags {
+                no_ancillary_files         = 1<<1,
+                no_field_consistency_check = 1<<2,
+        };
+        enum TStatus : int_least32_t {
+                ok                          = 0,
+                bad_header                  = (1 <<  0),
+                bad_numfld                  = (1 <<  1),
+                bad_datetime                  = (1 <<  2),
+                bad_session_or_episode          = (1 <<  3),
+                nonkemp_signaltype          = (1 <<  4),
+                non1020_channel                  = (1 <<  5),
+                dup_channels                  = (1 <<  6),
+                sysfail                          = (1 <<  7),
+                too_many_channels          = (1 <<  8),
+                missing_patient_id        = (1 <<  9),
+                invalid_subject_details   = (1 << 10),
+                conflicting_channel_type  = (1 << 11),
+        };
+        const static unsigned COMMON_STATUS_BITS = 11;
     protected:
-	string	_filename;
+        string        _filename;
 
-	int_least32_t
-		_status;
+        int_least32_t
+                _status;
 
-	int	_flags;
+        int        _flags;
 
-	agh::SSubjectId
-		_subject;
+        agh::SSubjectId
+                _subject;
 
     public:
-	DELETE_DEFAULT_METHODS (CSource);
-	CSource (const string& fname_, int flags_ = 0)
-	      : _filename (fname_),
-		_status (0),
-		_flags (flags_)
-		{
-			// if ( not (_flags & no_ancillary_files) )
-			// 	load_ancillary_files();
-			/// defer until, at least, n_channels is known
-		}
-	CSource( CSource&&);
-	virtual ~CSource()
-		{
-			// if ( not (_flags & no_ancillary_files) )
-			// 	save_ancillary_files();
-			/// for similar reasons, some methods will revert to pure when called from CSource dtor
-		}
-
-	int status()	const { return _status; }
-	int flags()	const { return _flags; }
-
-	static string explain_status( int);
-	virtual string explain_status() const
-		{ return move(explain_status( _status)); }
-
-	enum TDetails { with_channels = 1, with_annotations = 2 };
-	virtual string details( int which_details)	const = 0;
+        DELETE_DEFAULT_METHODS (CSource);
+        CSource (const string& fname_, int flags_ = 0)
+              : _filename (fname_),
+                _status (0),
+                _flags (flags_)
+                {
+                        // if ( not (_flags & no_ancillary_files) )
+                        //         load_ancillary_files();
+                        /// defer until, at least, n_channels is known
+                }
+        CSource( CSource&&);
+        virtual ~CSource()
+                {
+                        // if ( not (_flags & no_ancillary_files) )
+                        //         save_ancillary_files();
+                        /// for similar reasons, some methods will revert to pure when called from CSource dtor
+                }
+
+        int status()        const { return _status; }
+        int flags()        const { return _flags; }
+
+        static string explain_status( int);
+        virtual string explain_status() const
+                { return move(explain_status( _status)); }
+
+        enum TDetails { with_channels = 1, with_annotations = 2 };
+        virtual string details( int which_details)        const = 0;
 
       // identification
-	const char* filename() const
-		{
-			return _filename.c_str();
-		}
-	const agh::SSubjectId& subject() const
-		{
-			return _subject;
-		}
-	virtual const char* patient_id()		const = 0;
-	virtual const char* recording_id()		const = 0;
-	virtual const char* comment()			const = 0;
-	// probably parsed out of recording_id
-	virtual const char* episode()			const = 0;
-	virtual const char* session()			const = 0;
+        const char* filename() const
+                {
+                        return _filename.c_str();
+                }
+        const agh::SSubjectId& subject() const
+                {
+                        return _subject;
+                }
+        virtual const char* patient_id()                const = 0;
+        virtual const char* recording_id()                const = 0;
+        virtual const char* comment()                        const = 0;
+        // probably parsed out of recording_id
+        virtual const char* episode()                        const = 0;
+        virtual const char* session()                        const = 0;
 
       // recording time and duration
-	time_t	_start_time,
-		_end_time;
-	virtual time_t start_time() const
-		{ return _start_time; }
-	virtual time_t end_time() const
-		{ return _end_time; }
-	virtual double recording_time()			const = 0;
-
-	virtual int set_start_time( time_t);
-	virtual int set_recording_date( const string&) = 0;
-	virtual int set_recording_time( const string&) = 0;
+        time_t        _start_time,
+                _end_time;
+        virtual time_t start_time() const
+                { return _start_time; }
+        virtual time_t end_time() const
+                { return _end_time; }
+        virtual double recording_time()                        const = 0;
+
+        virtual int set_start_time( time_t);
+        virtual int set_recording_date( const string&) = 0;
+        virtual int set_recording_time( const string&) = 0;
 
       // channels
-	const static size_t max_channels = 1024;
-
-	virtual size_t n_channels()			const = 0;
-	virtual list<SChannel> channel_list()		const = 0;
-	virtual bool have_channel( const SChannel&) 	const = 0;
-	virtual int channel_id( const SChannel&)	const = 0;
-	virtual const SChannel& channel_by_id( int)	const = 0;
-	virtual SChannel::TType
-	signal_type( int)				const = 0;
-	virtual size_t samplerate( int)			const = 0;
-
-	// the following methods are pass-through:
-	// 1. annotations
-	// (a) per-channel
-	virtual list<SAnnotation>&
-	annotations( int)			      = 0;
-	virtual const list<SAnnotation>&
-	annotations( int) const			      = 0;
-
-	// (b) common
-	virtual list<SAnnotation>&
-	annotations()				      = 0;
-	virtual const list<SAnnotation>&
-	annotations()				const = 0;
-
-	// artifacts
-	virtual SArtifacts&
-	artifacts( int)				      = 0;
-	virtual const SArtifacts&
-	artifacts( int)				const = 0;
-
-	// filters
-	virtual SFilterPack&
-	filters( int)				      = 0;
-	virtual const SFilterPack&
-	filters( int)				const = 0;
-
-	unsigned long
-	dirty_signature( int id) const
-		{
-			return artifacts(id).dirty_signature() + filters(id).dirty_signature();
-		}
-
-	virtual int load_ancillary_files();
-	virtual int save_ancillary_files();
+        const static size_t max_channels = 1024;
+
+        virtual size_t n_channels()                        const = 0;
+        virtual list<SChannel> channel_list()                const = 0;
+        virtual bool have_channel( const SChannel&)         const = 0;
+        virtual int channel_id( const SChannel&)        const = 0;
+        virtual const SChannel& channel_by_id( int)        const = 0;
+        virtual SChannel::TType
+        signal_type( int)                                const = 0;
+        virtual size_t samplerate( int)                        const = 0;
+
+        // the following methods are pass-through:
+        // 1. annotations
+        // (a) per-channel
+        virtual list<SAnnotation>&
+        annotations( int)                              = 0;
+        virtual const list<SAnnotation>&
+        annotations( int) const                              = 0;
+
+        // (b) common
+        virtual list<SAnnotation>&
+        annotations()                                      = 0;
+        virtual const list<SAnnotation>&
+        annotations()                                const = 0;
+
+        // artifacts
+        virtual SArtifacts&
+        artifacts( int)                                      = 0;
+        virtual const SArtifacts&
+        artifacts( int)                                const = 0;
+
+        // filters
+        virtual SFilterPack&
+        filters( int)                                      = 0;
+        virtual const SFilterPack&
+        filters( int)                                const = 0;
+
+        unsigned long
+        dirty_signature( int id) const
+                {
+                        return artifacts(id).dirty_signature() + filters(id).dirty_signature();
+                }
+
+        virtual int load_ancillary_files();
+        virtual int save_ancillary_files();
 
       // setters
-	virtual int set_patient_id( const string&)    = 0;
-	virtual int set_recording_id( const string&)  = 0;
-	virtual int set_episode( const string&)	      = 0;
-	virtual int set_session( const string&)	      = 0;
-	virtual int set_comment( const string&)	      = 0;
+        virtual int set_patient_id( const string&)    = 0;
+        virtual int set_recording_id( const string&)  = 0;
+        virtual int set_episode( const string&)              = 0;
+        virtual int set_session( const string&)              = 0;
+        virtual int set_comment( const string&)              = 0;
 
       // get samples
-	// original
-	virtual valarray<TFloat>
-	get_region_original_smpl( int, size_t, size_t) const = 0;
-
-	valarray<TFloat>
-	get_region_original_sec( const int h,
-				 const float seconds_off_start,
-				 const float seconds_off_end) const
-		{
-			size_t sr = samplerate(h);
-			return get_region_original_smpl(
-				h,
-				seconds_off_start * sr,
-				seconds_off_end   * sr);
-		}
-
-	virtual valarray<TFloat>  // let derived classes provide optimised methods
-	get_signal_original( const int h) const
-		{
-			return get_region_original_smpl(
-				h,
-				0.0f, recording_time() * samplerate(h));
-		}
-
-	// filtered
-	virtual valarray<TFloat>
-	get_region_filtered_smpl( int, size_t, size_t) const;
-
-	valarray<TFloat>
-	get_region_filtered_sec( const int h,
-				 const float seconds_off_start,
-				 const float seconds_off_end) const
-		{
-			size_t sr = samplerate(h);
-			return get_region_filtered_smpl(
-				h,
-				seconds_off_start * sr,
-				seconds_off_end   * sr);
-		}
-
-	virtual valarray<TFloat>
-	get_signal_filtered( const int h) const
-		{
-			return get_region_filtered_sec(
-				h,
-				0.0f, recording_time() * samplerate(h));
-		}
+        // original
+        virtual valarray<TFloat>
+        get_region_original_smpl( int, size_t, size_t) const = 0;
+
+        valarray<TFloat>
+        get_region_original_sec( const int h,
+                                 const float seconds_off_start,
+                                 const float seconds_off_end) const
+                {
+                        size_t sr = samplerate(h);
+                        return get_region_original_smpl(
+                                h,
+                                seconds_off_start * sr,
+                                seconds_off_end   * sr);
+                }
+
+        virtual valarray<TFloat>  // let derived classes provide optimised methods
+        get_signal_original( const int h) const
+                {
+                        return get_region_original_smpl(
+                                h,
+                                0.0f, recording_time() * samplerate(h));
+                }
+
+        // filtered
+        virtual valarray<TFloat>
+        get_region_filtered_smpl( int, size_t, size_t) const;
+
+        valarray<TFloat>
+        get_region_filtered_sec( const int h,
+                                 const float seconds_off_start,
+                                 const float seconds_off_end) const
+                {
+                        size_t sr = samplerate(h);
+                        return get_region_filtered_smpl(
+                                h,
+                                seconds_off_start * sr,
+                                seconds_off_end   * sr);
+                }
+
+        virtual valarray<TFloat>
+        get_signal_filtered( const int h) const
+                {
+                        return get_region_filtered_sec(
+                                h,
+                                0.0f, recording_time() * samplerate(h));
+                }
 
       // put samples
-	virtual int
-	put_region_smpl( int, const valarray<TFloat>&, size_t) = 0;
+        virtual int
+        put_region_smpl( int, const valarray<TFloat>&, size_t) = 0;
 
-	int put_region_sec( const int h, const valarray<TFloat>& src, const float offset)
-		{ return put_region_smpl( h, src, offset * samplerate(h)); }
+        int put_region_sec( const int h, const valarray<TFloat>& src, const float offset)
+                { return put_region_smpl( h, src, offset * samplerate(h)); }
 
-	int put_signal( const int h, const valarray<TFloat>& src)
-		{ return put_region_smpl( h, src, 0); }
+        int put_signal( const int h, const valarray<TFloat>& src)
+                { return put_region_smpl( h, src, 0); }
 
       // signal data info
-	virtual pair<TFloat, TFloat>
-	get_real_original_signal_range( int) const = 0;
+        virtual pair<TFloat, TFloat>
+        get_real_original_signal_range( int) const = 0;
 
-	virtual pair<TFloat, TFloat>
-	get_real_filtered_signal_range( int) const = 0;
+        virtual pair<TFloat, TFloat>
+        get_real_filtered_signal_range( int) const = 0;
 
       // export
-	virtual int
-	export_original( int, const string& fname) const;
-	virtual int
-	export_filtered( int, const string& fname) const;
+        virtual int
+        export_original( int, const string& fname) const;
+        virtual int
+        export_filtered( int, const string& fname) const;
 
       // filenames
-	string make_fname_artifacts( const SChannel& channel) const
-		{
-			return sigfile::make_fname_artifacts( filename(), channel);
-		}
-	string make_fname_annotations( const SChannel& channel) const
-		{
-			return sigfile::make_fname_annotations( filename(), channel);
-		}
+        string make_fname_artifacts( const SChannel& channel) const
+                {
+                        return sigfile::make_fname_artifacts( filename(), channel);
+                }
+        string make_fname_annotations( const SChannel& channel) const
+                {
+                        return sigfile::make_fname_annotations( filename(), channel);
+                }
 
       // supporting functions
-	tuple<string, string>
-	figure_session_and_episode(); // hand over the pair separately for specific ways to store these fields in derived classes
+        tuple<string, string>
+        figure_session_and_episode(); // hand over the pair separately for specific ways to store these fields in derived classes
 
-	enum class TAcceptTimeFormat { edf_strict, any };
-	void
-	figure_times( const string&, const string&, TAcceptTimeFormat);
+        enum class TAcceptTimeFormat { edf_strict, any };
+        void
+        figure_times( const string&, const string&, TAcceptTimeFormat);
 };
 
 
diff --git a/upstream/src/libsigfile/tsv.cc b/upstream/src/libsigfile/tsv.cc
index 606aabd..da8892d 100644
--- a/upstream/src/libsigfile/tsv.cc
+++ b/upstream/src/libsigfile/tsv.cc
@@ -40,35 +40,35 @@ CTSVFile::
 CTSVFile (const string& fname_, const int flags_)
       : CSource (fname_, flags_)
 {
-	{
-		struct stat stat0;
-		int stst = stat( fname_.c_str(), &stat0);
-		if ( stst == -1 )
-			throw invalid_argument (explain_status(_status |= CSource::TStatus::sysfail));
-	}
-	_f = fopen( fname_.c_str(), "r");
-	if ( !_f )
-		throw invalid_argument (explain_status(_status |= sysfail));
-	_subtype =
-		(strcasecmp( &fname_[fname_.size()-4], ".csv") == 0)
-		? TSubtype::csv
-		: (strcasecmp( &fname_[fname_.size()-4], ".tsv") == 0) ? TSubtype::tsv
-		: TSubtype::invalid;
+        {
+                struct stat stat0;
+                int stst = stat( fname_.c_str(), &stat0);
+                if ( stst == -1 )
+                        throw invalid_argument (explain_status(_status |= CSource::TStatus::sysfail));
+        }
+        _f = fopen( fname_.c_str(), "r");
+        if ( !_f )
+                throw invalid_argument (explain_status(_status |= sysfail));
+        _subtype =
+                (strcasecmp( &fname_[fname_.size()-4], ".csv") == 0)
+                ? TSubtype::csv
+                : (strcasecmp( &fname_[fname_.size()-4], ".tsv") == 0) ? TSubtype::tsv
+                : TSubtype::invalid;
 
       // parse header
-	if ( _parse_header() ) {  // creates channels list
-		if ( not (flags_ & sigfile::CSource::no_field_consistency_check) ) {
-			throw invalid_argument (explain_status(_status)); // _status set in _parse_header()
-		} else
-			fprintf( stderr, "CTSVFile::CTSVFile(\"%s\") Warning: parse header failed, but proceeding anyway\n", fname_.c_str());
-	}
-	// channels now available
-
-	if ( _read_data() )
-		throw invalid_argument (explain_status(_status)); // _status set in _parse_header()
-
-	if ( not (flags_ & CSource::no_ancillary_files) )
-		load_ancillary_files();
+        if ( _parse_header() ) {  // creates channels list
+                if ( not (flags_ & sigfile::CSource::no_field_consistency_check) ) {
+                        throw invalid_argument (explain_status(_status)); // _status set in _parse_header()
+                } else
+                        fprintf( stderr, "CTSVFile::CTSVFile(\"%s\") Warning: parse header failed, but proceeding anyway\n", fname_.c_str());
+        }
+        // channels now available
+
+        if ( _read_data() )
+                throw invalid_argument (explain_status(_status)); // _status set in _parse_header()
+
+        if ( not (flags_ & CSource::no_ancillary_files) )
+                load_ancillary_files();
 }
 
 
@@ -76,33 +76,33 @@ CTSVFile (const string& fname_, const int flags_)
 
 CTSVFile::
 CTSVFile (const string& fname_, const TSubtype subtype_, const int flags_,
-	  const list<SChannel>& channels_,
-	  const size_t samplerate_,
-	  const double recording_time_)
+          const list<SChannel>& channels_,
+          const size_t samplerate_,
+          const double recording_time_)
       : CSource (fname_, flags_),
-	_subtype (subtype_),
-	_samplerate (samplerate_),
-	_line0 (nullptr)
+        _subtype (subtype_),
+        _samplerate (samplerate_),
+        _line0 (nullptr)
 {
-	_f = fopen( fname_.c_str(), "r");
-	if ( !_f ) {
-		fprintf( stderr, "CTSVFile::CTSVFile(\"%s\"): Failed to open file for writing\n", fname_.c_str());
-		throw invalid_argument (explain_status(_status |= CSource::TStatus::sysfail));
-	}
+        _f = fopen( fname_.c_str(), "r");
+        if ( !_f ) {
+                fprintf( stderr, "CTSVFile::CTSVFile(\"%s\"): Failed to open file for writing\n", fname_.c_str());
+                throw invalid_argument (explain_status(_status |= CSource::TStatus::sysfail));
+        }
 
       // fill out some essential header fields
-	_subject = {"Fafa_1", "Mr. Fafa"};
-	set_recording_id( "Zzz");
-	set_comment( fname_);
-	set_start_time( time(NULL));
-
-	size_t hi = 0;
-	for ( auto& h : channels_ ) {
-		auto& H = channels[hi++];
-		H.ucd = h;
-	}
-
-	resize_seconds( recording_time_);
+        _subject = {"Fafa_1", "Mr. Fafa"};
+        set_recording_id( "Zzz");
+        set_comment( fname_);
+        set_start_time( time(NULL));
+
+        size_t hi = 0;
+        for ( auto& h : channels_ ) {
+                auto& H = channels[hi++];
+                H.ucd = h;
+        }
+
+        resize_seconds( recording_time_);
 }
 
 
@@ -112,22 +112,22 @@ CTSVFile::
 CTSVFile (CTSVFile&& rv)
       : CSource (move(rv))
 {
-	swap( _episode,    rv._episode);
-	swap( _session,    rv._session);
+        swap( _episode,    rv._episode);
+        swap( _session,    rv._session);
 
-	swap( metadata, rv.metadata);
+        swap( metadata, rv.metadata);
 
-	_subtype    = rv._subtype;
+        _subtype    = rv._subtype;
 
-	swap( channels, rv.channels);
-	swap( common_annotations, rv.common_annotations);
+        swap( channels, rv.channels);
+        swap( common_annotations, rv.common_annotations);
 
-	_f = rv._f;
-	rv._f = nullptr;
+        _f = rv._f;
+        rv._f = nullptr;
 
-	_line0_mallocked_bytes = rv._line0_mallocked_bytes;
-	_line0 = rv._line0;
-	rv._line0 = nullptr;
+        _line0_mallocked_bytes = rv._line0_mallocked_bytes;
+        _line0 = rv._line0;
+        rv._line0 = nullptr;
 
 }
 
@@ -135,10 +135,10 @@ CTSVFile (CTSVFile&& rv)
 CTSVFile::
 ~CTSVFile ()
 {
-	if ( not (_flags & sigfile::CSource::no_ancillary_files) )
-		save_ancillary_files();
-	if ( _line0 )
-		free( (void*)_line0);
+        if ( not (_flags & sigfile::CSource::no_ancillary_files) )
+                save_ancillary_files();
+        if ( _line0 )
+                free( (void*)_line0);
 }
 
 
@@ -147,15 +147,15 @@ int
 CTSVFile::
 set_recording_date( const string& s)
 {
-	metadata["recording_date"] = s;
-	return 0;
+        metadata["recording_date"] = s;
+        return 0;
 }
 int
 CTSVFile::
 set_recording_time( const string& s)
 {
-	metadata["recording_time"] = s;
-	return 0;
+        metadata["recording_time"] = s;
+        return 0;
 }
 
 
@@ -164,93 +164,93 @@ CTSVFile::
 _parse_header()
 {
       // 1. read metadata
-	regex_t RE;
-	regcomp( &RE, "^#\\W*([a-zA-Z_][a-zA-Z_0-9]*)\\W*(:|=)\\W*(.+)\\W*\n", REG_EXTENDED);
-	regmatch_t M[1+1+2];
-
-	_line0_mallocked_bytes = 4096;
-	_line0 = (char*)malloc( _line0_mallocked_bytes);
-
-	while ( getline( &_line0, &_line0_mallocked_bytes, _f) != -1 ) {
-		if ( _line0[0] == '\n' )
-			continue;
-		if ( regexec( &RE, _line0, 1+1+2, M, 0) == 0 ) {
-			string	K = trim( string (_line0, M[1].rm_so, (M[1].rm_eo - M[1].rm_so))),
-				V = trim( string (_line0, M[3].rm_so, (M[3].rm_eo - M[3].rm_so)));
-			metadata[K] = V;
-		} else if ( _line0[0] != '#' )
-			break; // end of header
-	}
+        regex_t RE;
+        regcomp( &RE, "^#\\W*([a-zA-Z_][a-zA-Z_0-9]*)\\W*(:|=)\\W*(.+)\\W*\n", REG_EXTENDED);
+        regmatch_t M[1+1+2];
+
+        _line0_mallocked_bytes = 4096;
+        _line0 = (char*)malloc( _line0_mallocked_bytes);
+
+        while ( getline( &_line0, &_line0_mallocked_bytes, _f) != -1 ) {
+                if ( _line0[0] == '\n' )
+                        continue;
+                if ( regexec( &RE, _line0, 1+1+2, M, 0) == 0 ) {
+                        string        K = trim( string (_line0, M[1].rm_so, (M[1].rm_eo - M[1].rm_so))),
+                                V = trim( string (_line0, M[3].rm_so, (M[3].rm_eo - M[3].rm_so)));
+                        metadata[K] = V;
+                } else if ( _line0[0] != '#' )
+                        break; // end of header
+        }
 
       // 2. pick essential bits
-	if ( metadata.find( "recording_id") == metadata.end() ) {
-		fprintf( stderr, "No session/episode in header\n");
-		_status |= bad_session_or_episode;
-		return -1;
-	}
-
-	if ( metadata.find( "patient_id") == metadata.end() ) {
-		fprintf( stderr, "No patient_id in header\n");
-		_status |= CSource::missing_patient_id;;
-		return -1;
-	}
-	_status |=
-		_subject.parse_recording_id_edf_style( metadata["patient_id"]);
-
-	if ( metadata.find( "recording_date") == metadata.end() ||
-	     metadata.find( "recording_time") == metadata.end() ) {
-		fprintf( stderr, "No recording_date in header\n");
-		_status |= CSource::bad_datetime;
-		return -1;
-	}
-
-	figure_times(
-		metadata["recording_date"],
-		metadata["recording_time"],
-		TAcceptTimeFormat::any);
-	if ( _status & bad_datetime && !(_flags & CSource::TFlags::no_field_consistency_check) )
-		return -1;
-
-	// if ( metadata.find( "comment") == metadata.end() )
-	// 	;
-
-	if ( metadata.find( "samplerate") == metadata.end() ||
-	     (_samplerate = stoi( metadata["samplerate"])) > 2048 ) {
-		fprintf( stderr, "Samplerate missing or too high in header\n");
-		_status |= bad_header;
-		return -1;
-	}
-
-	if ( metadata.find( "channels") == metadata.end() ) {
-		fprintf( stderr, "No channels in header\n");
-		_status |= bad_header;
-		return -1;
-	}
-	for ( const auto& h : agh::str::tokens( metadata["channels"], " ,;\t") )
-		channels.emplace_back( h);
+        if ( metadata.find( "recording_id") == metadata.end() ) {
+                fprintf( stderr, "No session/episode in header\n");
+                _status |= bad_session_or_episode;
+                return -1;
+        }
+
+        if ( metadata.find( "patient_id") == metadata.end() ) {
+                fprintf( stderr, "No patient_id in header\n");
+                _status |= CSource::missing_patient_id;;
+                return -1;
+        }
+        _status |=
+                _subject.parse_recording_id_edf_style( metadata["patient_id"]);
+
+        if ( metadata.find( "recording_date") == metadata.end() ||
+             metadata.find( "recording_time") == metadata.end() ) {
+                fprintf( stderr, "No recording_date in header\n");
+                _status |= CSource::bad_datetime;
+                return -1;
+        }
+
+        figure_times(
+                metadata["recording_date"],
+                metadata["recording_time"],
+                TAcceptTimeFormat::any);
+        if ( _status & bad_datetime && !(_flags & CSource::TFlags::no_field_consistency_check) )
+                return -1;
+
+        // if ( metadata.find( "comment") == metadata.end() )
+        //         ;
+
+        if ( metadata.find( "samplerate") == metadata.end() ||
+             (_samplerate = stoi( metadata["samplerate"])) > 2048 ) {
+                fprintf( stderr, "Samplerate missing or too high in header\n");
+                _status |= bad_header;
+                return -1;
+        }
+
+        if ( metadata.find( "channels") == metadata.end() ) {
+                fprintf( stderr, "No channels in header\n");
+                _status |= bad_header;
+                return -1;
+        }
+        for ( const auto& h : agh::str::tokens( metadata["channels"], " ,;\t") )
+                channels.emplace_back( h);
 
       // 3. deal with episode and session
-	tie( _session, _episode) =
-		figure_session_and_episode();
+        tie( _session, _episode) =
+                figure_session_and_episode();
 
       // 4. are channels unique?
-	for ( auto &H : channels )
-		for ( auto &J : channels ) {
-			if ( &J != &H && J.ucd == H.ucd ) {
-				_status |= dup_channels;
-				goto outer_break;
-			}
-		}
+        for ( auto &H : channels )
+                for ( auto &J : channels ) {
+                        if ( &J != &H && J.ucd == H.ucd ) {
+                                _status |= dup_channels;
+                                goto outer_break;
+                        }
+                }
 outer_break:
 
       // 4. sample one line of channel data
-	if ( agh::str::tokens( _line0, "\t;, ").size() != channels.size() ) {
-		fprintf( stderr, "Number of channels declared in header (%zu) different from number of columns of data\n", channels.size());
-		_status |= bad_channel_count;
-		return -1;
-	}
+        if ( agh::str::tokens( _line0, "\t;, ").size() != channels.size() ) {
+                fprintf( stderr, "Number of channels declared in header (%zu) different from number of columns of data\n", channels.size());
+                _status |= bad_channel_count;
+                return -1;
+        }
 
-	return 0;
+        return 0;
 }
 
 
@@ -258,89 +258,89 @@ int
 CTSVFile::
 _read_data()
 {
-	// _line0 contains the first row of data already (it is the
-	// first line not beginning with a #)
-
-	vector<vector<double>> c2 (channels.size());
-	size_t r, ll = 0;
-
-	if ( metadata["series"] == "irregular" ) {
-		vector<unsigned long> offsets;
-		do {
-			double ts;
-			if ( 1 != sscanf( _line0, "%lg%*[,\t]", &ts) ) {
-				fprintf( stderr, "Bad offset (at data line %zu)\n", ll);
-				_status |= bad_offset;
-				return -1;
-			}
-			if ( ll > 0 && ts * _samplerate <= offsets.back() ) {
-				fprintf( stderr, "Offsets not increasing (at data line %zu)\n", ll);
-				_status |= offsets_not_incteasing;
-				return -1;
-			}
-
-			offsets.push_back( ts * _samplerate);
-
-			for ( r = 0; r < channels.size(); ++r ) {
-				double x;
-				if ( 1 != sscanf( _line0, "%lg%*[,\t]", &x) )
-					goto outer_break1;
-				c2[r].push_back( x);
-			}
-			++ll;
-		} while ( getline( &_line0, &_line0_mallocked_bytes, _f) > 0 );
-	outer_break1:
-
-		if ( r != 0 && r != channels.size() ) {
-			fprintf( stderr, "Number of data read (%zu) not a multiple of channel count (%zu)\n", r, channels.size());
-			_status |= bad_channel_count;
-			return -1;
-		}
-
-	      // interpolate and resample
-		for ( size_t h = 0; h < channels.size(); ++h ) {
-			valarray<TFloat> interpolated =
-				sigproc::interpolate<TFloat>(
-					offsets,
-					_samplerate,
-					c2[h],
-					1./_samplerate);
-			channels[h].data.resize( interpolated.size());
-			channels[h].data = interpolated;
-		}
-
-
-	} else {
-		do {
-			for ( r = 0; r < channels.size(); ++r ) {
-				double x;
-				if ( 1 != sscanf( _line0, "%lg%*[,\t]", &x) )
-					goto outer_break2;
-				c2[r].push_back( x);
-			}
-			++ll;
-		} while ( getline( &_line0, &_line0_mallocked_bytes, _f) > 0 );
-	outer_break2:
-
-		if ( r != 0 && r != channels.size() ) {
-			fprintf( stderr, "Number of data read (%zu) not a multiple of channel count (%zu)\n", r, channels.size());
-			_status |= bad_channel_count;
-			return -1;
-		}
-
-		// vector -> valarray
-		for ( size_t h = 0; h < channels.size(); ++h ) {
-			channels[h].data.resize( ll);
-			for ( size_t i = 0; i < ll; ++i )
-				channels[h].data[i] = c2[h][i];
-		}
-	}
-
-
-	// only now as late
-	_end_time = _start_time + (time_t)recording_time();
-
-	return 0;
+        // _line0 contains the first row of data already (it is the
+        // first line not beginning with a #)
+
+        vector<vector<double>> c2 (channels.size());
+        size_t r, ll = 0;
+
+        if ( metadata["series"] == "irregular" ) {
+                vector<unsigned long> offsets;
+                do {
+                        double ts;
+                        if ( 1 != sscanf( _line0, "%lg%*[,\t]", &ts) ) {
+                                fprintf( stderr, "Bad offset (at data line %zu)\n", ll);
+                                _status |= bad_offset;
+                                return -1;
+                        }
+                        if ( ll > 0 && ts * _samplerate <= offsets.back() ) {
+                                fprintf( stderr, "Offsets not increasing (at data line %zu)\n", ll);
+                                _status |= offsets_not_incteasing;
+                                return -1;
+                        }
+
+                        offsets.push_back( ts * _samplerate);
+
+                        for ( r = 0; r < channels.size(); ++r ) {
+                                double x;
+                                if ( 1 != sscanf( _line0, "%lg%*[,\t]", &x) )
+                                        goto outer_break1;
+                                c2[r].push_back( x);
+                        }
+                        ++ll;
+                } while ( getline( &_line0, &_line0_mallocked_bytes, _f) > 0 );
+        outer_break1:
+
+                if ( r != 0 && r != channels.size() ) {
+                        fprintf( stderr, "Number of data read (%zu) not a multiple of channel count (%zu)\n", r, channels.size());
+                        _status |= bad_channel_count;
+                        return -1;
+                }
+
+              // interpolate and resample
+                for ( size_t h = 0; h < channels.size(); ++h ) {
+                        valarray<TFloat> interpolated =
+                                sigproc::interpolate<TFloat>(
+                                        offsets,
+                                        _samplerate,
+                                        c2[h],
+                                        1./_samplerate);
+                        channels[h].data.resize( interpolated.size());
+                        channels[h].data = interpolated;
+                }
+
+
+        } else {
+                do {
+                        for ( r = 0; r < channels.size(); ++r ) {
+                                double x;
+                                if ( 1 != sscanf( _line0, "%lg%*[,\t]", &x) )
+                                        goto outer_break2;
+                                c2[r].push_back( x);
+                        }
+                        ++ll;
+                } while ( getline( &_line0, &_line0_mallocked_bytes, _f) > 0 );
+        outer_break2:
+
+                if ( r != 0 && r != channels.size() ) {
+                        fprintf( stderr, "Number of data read (%zu) not a multiple of channel count (%zu)\n", r, channels.size());
+                        _status |= bad_channel_count;
+                        return -1;
+                }
+
+                // vector -> valarray
+                for ( size_t h = 0; h < channels.size(); ++h ) {
+                        channels[h].data.resize( ll);
+                        for ( size_t i = 0; i < ll; ++i )
+                                channels[h].data[i] = c2[h][i];
+                }
+        }
+
+
+        // only now as late
+        _end_time = _start_time + (time_t)recording_time();
+
+        return 0;
 }
 
 
@@ -352,14 +352,14 @@ int
 CTSVFile::
 put_region_smpl( int h, const valarray<TFloat>& V, size_t off)
 {
-	if ( unlikely (h > (int)channels.size() - 1) )
-		throw out_of_range ("Bad channel index");
-	if ( unlikely (off + V.size() > channels[h].data.size()) )
-		throw out_of_range ("Bad offset");
+        if ( unlikely (h > (int)channels.size() - 1) )
+                throw out_of_range ("Bad channel index");
+        if ( unlikely (off + V.size() > channels[h].data.size()) )
+                throw out_of_range ("Bad offset");
 
-	channels[h].data[ slice (off, V.size(), 1) ] = V[ slice (0, V.size(), 1) ];
+        channels[h].data[ slice (off, V.size(), 1) ] = V[ slice (0, V.size(), 1) ];
 
-	return 0;
+        return 0;
 }
 
 
@@ -368,10 +368,10 @@ size_t
 CTSVFile::
 resize_seconds( double s)
 {
-	assert ( s > 0. );
-	for ( auto& H : channels )
-		H.data.resize( s * _samplerate);
-	return 0;
+        assert ( s > 0. );
+        for ( auto& H : channels )
+                H.data.resize( s * _samplerate);
+        return 0;
 }
 
 
@@ -379,37 +379,37 @@ string
 CTSVFile::
 details( const int which) const
 {
-	ostringstream recv;
-	char b[20];
-	recv << agh::str::sasprintf(
-		"File\t: %s\n"
-		" subtype\t: %s\n"
-		" PatientID\t: %s\n"
-		" RecordingID\t: %s\n"
-		" Start time\t: %s\n"
-		" Duration\t: %s\n"
-		" # of channels\t: %zu\n"
-		" Sample rate\t: %zu\n",
-		agh::str::homedir2tilda( filename()).c_str(),
-		subtype_s(),
-		patient_id(),
-		recording_id(),
-		(strftime( b, 20, "%F %T", localtime(&_start_time)), b),
-		agh::str::dhms( recording_time()).c_str(),
-		channels.size(),
-		_samplerate);
-
-	if ( which & with_channels ) {
-		size_t i = 0;
-		for ( auto &H : channels )
-			recv << agh::str::sasprintf(
-				" Channel %zu:\n"
-				"  Label\t: %s\n",
-				++i,
-				H.ucd.name());
-	}
-
-	return recv.str();
+        ostringstream recv;
+        char b[20];
+        recv << agh::str::sasprintf(
+                "File\t: %s\n"
+                " subtype\t: %s\n"
+                " PatientID\t: %s\n"
+                " RecordingID\t: %s\n"
+                " Start time\t: %s\n"
+                " Duration\t: %s\n"
+                " # of channels\t: %zu\n"
+                " Sample rate\t: %zu\n",
+                agh::str::homedir2tilda( filename()).c_str(),
+                subtype_s(),
+                patient_id(),
+                recording_id(),
+                (strftime( b, 20, "%F %T", localtime(&_start_time)), b),
+                agh::str::dhms( recording_time()).c_str(),
+                channels.size(),
+                _samplerate);
+
+        if ( which & with_channels ) {
+                size_t i = 0;
+                for ( auto &H : channels )
+                        recv << agh::str::sasprintf(
+                                " Channel %zu:\n"
+                                "  Label\t: %s\n",
+                                ++i,
+                                H.ucd.name());
+        }
+
+        return recv.str();
 }
 
 
@@ -422,14 +422,14 @@ string
 CTSVFile::
 explain_status( const int status)
 {
-	list<string> recv;
-	if ( status & bad_channel_count )
-		recv.emplace_back( "Number of channels declared in header different from number of columns of data");
-	if ( status & bad_offset )
-		recv.emplace_back( "Bad offset");
-	if ( status & offsets_not_incteasing )
-		recv.emplace_back( "Offsets in an irregular-series data not increasing");
-	return CSource::explain_status(status) + (recv.empty() ? "" : (join(recv, "\n") + '\n'));
+        list<string> recv;
+        if ( status & bad_channel_count )
+                recv.emplace_back( "Number of channels declared in header different from number of columns of data");
+        if ( status & bad_offset )
+                recv.emplace_back( "Bad offset");
+        if ( status & offsets_not_incteasing )
+                recv.emplace_back( "Offsets in an irregular-series data not increasing");
+        return CSource::explain_status(status) + (recv.empty() ? "" : (join(recv, "\n") + '\n'));
 }
 
 
diff --git a/upstream/src/libsigfile/tsv.hh b/upstream/src/libsigfile/tsv.hh
index 50092f2..03a724b 100644
--- a/upstream/src/libsigfile/tsv.hh
+++ b/upstream/src/libsigfile/tsv.hh
@@ -43,324 +43,324 @@ class CTSVFile
   : public CSource {
 
       // deleted
-	bool operator==( const CTSVFile&) const = delete;
-	CTSVFile() = delete;
+        bool operator==( const CTSVFile&) const = delete;
+        CTSVFile() = delete;
 
     public:
-	// subtype
-	enum class TSubtype {
-		invalid,
-		csv,
-		tsv,
-	};
-	TSubtype subtype() const
-		{ return _subtype; }
-	static const char*
-	subtype_s( TSubtype t)
-		{
-			switch (t) {
-			case TSubtype::csv: return "csv";
-			case TSubtype::tsv: return "tsv";
-			default:  return "(invalid)";
-			}
-		}
-	const char*
-	subtype_s() const
-		{ return subtype_s( _subtype); }
+        // subtype
+        enum class TSubtype {
+                invalid,
+                csv,
+                tsv,
+        };
+        TSubtype subtype() const
+                { return _subtype; }
+        static const char*
+        subtype_s( TSubtype t)
+                {
+                        switch (t) {
+                        case TSubtype::csv: return "csv";
+                        case TSubtype::tsv: return "tsv";
+                        default:  return "(invalid)";
+                        }
+                }
+        const char*
+        subtype_s() const
+                { return subtype_s( _subtype); }
 
       // ctor
-	CTSVFile (const CTSVFile&)
-	      : CSource("")
-		{
-			throw invalid_argument("nono");
-		}
-	// open existing
-	CTSVFile (const string& fname, int flags = 0);
-	// create new
-	CTSVFile (const string& fname, TSubtype, int flags,
-		  const list<SChannel>&,
-		  const size_t samplerate_,
-		  const double recording_time_);
-	CTSVFile (CTSVFile&&);
+        CTSVFile (const CTSVFile&)
+              : CSource("")
+                {
+                        throw invalid_argument("nono");
+                }
+        // open existing
+        CTSVFile (const string& fname, int flags = 0);
+        // create new
+        CTSVFile (const string& fname, TSubtype, int flags,
+                  const list<SChannel>&,
+                  const size_t samplerate_,
+                  const double recording_time_);
+        CTSVFile (CTSVFile&&);
       // dtor
        ~CTSVFile ();
 
       // interface
-	// status
-	string explain_status() const
-		{ return explain_status( _status); }
-
-	// identification
-	const char* patient_id() const
-		{
-			const auto I = metadata.find("patient_id");
-			return (I == metadata.end()) ? "" : I->second.c_str();
-		}
-	const char* recording_id() const
-		{
-			const auto I = metadata.find("recording_id");
-			return (I == metadata.end()) ? "" : I->second.c_str();
-		}
-	const char* comment() const
-		{
-			const auto I = metadata.find("comment");
-			return (I == metadata.end()) ? "" : I->second.c_str();
-		}
-	const char* episode() const
-		{ return _episode.c_str(); }
-	const char* session() const
-		{ return _session.c_str(); }
-
-	// times
-	double recording_time() const // in seconds
-		{ return (double)channels.front().data.size() / _samplerate; } // all channels have the same sr, obviously
-	int set_recording_date( const string&);
-	int set_recording_time( const string&);
-
-	// setters
-	int set_patient_id( const string& s)
-		{
-			metadata["patient_id"] = s;
-			return 0;
-		}
-	int set_recording_id( const string& s)
-		{
-			metadata["recording_id"] = s;
-			return 0;
-		}
-	int set_comment( const string& s)
-		{
-			metadata["comment"] = s;
-			return 0;
-		}
-
-	int set_episode( const string& s) // assigning to _episode or _session directly won't have a lasting effect; think again.
-		{
-			_episode = s;
-			return 0;
-		}
-	int set_session( const string& s)
-		{
-			_session = s;
-			return 0;
-		}
-
-	// channels
-	size_t n_channels() const
-		{ return channels.size(); }
-	list<SChannel>
-	channel_list() const
-		{
-			list<SChannel> ret;
-			for ( auto &H : channels )
-				ret.push_back( H.ucd);
-			return ret;
-		}
-	bool
-	have_channel( const SChannel& h) const
-		{ return find( channels.cbegin(), channels.cend(), h) != channels.cend(); }
-	int
-	channel_id( const SChannel& h) const
-		{
-			for ( size_t i = 0; i < channels.size(); ++i )
-				if ( channels[i].ucd == h )
-					return i;
-			return -1;
-		}
-	const SChannel&
-	channel_by_id( const int h) const
-		{ return channels[h].ucd; }
-
-	SChannel::TType
-	signal_type( const int h) const
-		{ return operator[](h).ucd.type(); }
-
-	size_t
-	samplerate( int) const
-		{ return _samplerate; }
-
-	list<SAnnotation>&
-	annotations( const int h)
-		{ return operator[](h).annotations; }
-	const list<SAnnotation>&
-	annotations( const int h) const
-		{ return operator[](h).annotations; }
-
-	list<SAnnotation>&
-	annotations()
-		{ return common_annotations; }
-	const list<SAnnotation>&
-	annotations() const
-		{ return common_annotations; }
-
-	// artifacts
-	SArtifacts&
-	artifacts( int h)
-		{ return operator[](h).artifacts; }
-	const SArtifacts&
-	artifacts( int h) const
-		{ return operator[](h).artifacts; }
-
-	// filters
-	SFilterPack&
-	filters( const int h)
-		{ return operator[](h).filters; }
-	const SFilterPack&
-	filters( const int h) const
-		{ return operator[](h).filters; }
+        // status
+        string explain_status() const
+                { return explain_status( _status); }
+
+        // identification
+        const char* patient_id() const
+                {
+                        const auto I = metadata.find("patient_id");
+                        return (I == metadata.end()) ? "" : I->second.c_str();
+                }
+        const char* recording_id() const
+                {
+                        const auto I = metadata.find("recording_id");
+                        return (I == metadata.end()) ? "" : I->second.c_str();
+                }
+        const char* comment() const
+                {
+                        const auto I = metadata.find("comment");
+                        return (I == metadata.end()) ? "" : I->second.c_str();
+                }
+        const char* episode() const
+                { return _episode.c_str(); }
+        const char* session() const
+                { return _session.c_str(); }
+
+        // times
+        double recording_time() const // in seconds
+                { return (double)channels.front().data.size() / _samplerate; } // all channels have the same sr, obviously
+        int set_recording_date( const string&);
+        int set_recording_time( const string&);
+
+        // setters
+        int set_patient_id( const string& s)
+                {
+                        metadata["patient_id"] = s;
+                        return 0;
+                }
+        int set_recording_id( const string& s)
+                {
+                        metadata["recording_id"] = s;
+                        return 0;
+                }
+        int set_comment( const string& s)
+                {
+                        metadata["comment"] = s;
+                        return 0;
+                }
+
+        int set_episode( const string& s) // assigning to _episode or _session directly won't have a lasting effect; think again.
+                {
+                        _episode = s;
+                        return 0;
+                }
+        int set_session( const string& s)
+                {
+                        _session = s;
+                        return 0;
+                }
+
+        // channels
+        size_t n_channels() const
+                { return channels.size(); }
+        list<SChannel>
+        channel_list() const
+                {
+                        list<SChannel> ret;
+                        for ( auto &H : channels )
+                                ret.push_back( H.ucd);
+                        return ret;
+                }
+        bool
+        have_channel( const SChannel& h) const
+                { return find( channels.cbegin(), channels.cend(), h) != channels.cend(); }
+        int
+        channel_id( const SChannel& h) const
+                {
+                        for ( size_t i = 0; i < channels.size(); ++i )
+                                if ( channels[i].ucd == h )
+                                        return i;
+                        return -1;
+                }
+        const SChannel&
+        channel_by_id( const int h) const
+                { return channels[h].ucd; }
+
+        SChannel::TType
+        signal_type( const int h) const
+                { return operator[](h).ucd.type(); }
+
+        size_t
+        samplerate( int) const
+                { return _samplerate; }
+
+        list<SAnnotation>&
+        annotations( const int h)
+                { return operator[](h).annotations; }
+        const list<SAnnotation>&
+        annotations( const int h) const
+                { return operator[](h).annotations; }
+
+        list<SAnnotation>&
+        annotations()
+                { return common_annotations; }
+        const list<SAnnotation>&
+        annotations() const
+                { return common_annotations; }
+
+        // artifacts
+        SArtifacts&
+        artifacts( int h)
+                { return operator[](h).artifacts; }
+        const SArtifacts&
+        artifacts( int h) const
+                { return operator[](h).artifacts; }
+
+        // filters
+        SFilterPack&
+        filters( const int h)
+                { return operator[](h).filters; }
+        const SFilterPack&
+        filters( const int h) const
+                { return operator[](h).filters; }
 
 
       // signal data extractors
-	valarray<TFloat>
-	get_region_original_smpl( const int h, const size_t sa, const size_t sz) const
-		{ return operator[](h).data[ slice (sa, sz-sa, 1) ];}
+        valarray<TFloat>
+        get_region_original_smpl( const int h, const size_t sa, const size_t sz) const
+                { return operator[](h).data[ slice (sa, sz-sa, 1) ];}
 
-	valarray<TFloat>
-	get_signal_original( const int h) const // there is a CSource::get_signal_original already, but this one is a little better
-		{ return get_region_original_smpl( h, 0, channels.front().data.size()-1); }
+        valarray<TFloat>
+        get_signal_original( const int h) const // there is a CSource::get_signal_original already, but this one is a little better
+                { return get_region_original_smpl( h, 0, channels.front().data.size()-1); }
 
-	valarray<TFloat>
-	get_signal_filtered( const int h) const
-		{ return get_region_filtered_smpl( h, 0, channels.front().data.size()-1); }
+        valarray<TFloat>
+        get_signal_filtered( const int h) const
+                { return get_region_filtered_smpl( h, 0, channels.front().data.size()-1); }
 
       // put signal
-	int put_region_smpl( int, const valarray<TFloat>&, size_t);
-	int put_region_sec( const int h, const valarray<TFloat>& src, const float offset)
-		{ return put_region_smpl( h, src, (size_t)(offset * _samplerate)); }
+        int put_region_smpl( int, const valarray<TFloat>&, size_t);
+        int put_region_sec( const int h, const valarray<TFloat>& src, const float offset)
+                { return put_region_smpl( h, src, (size_t)(offset * _samplerate)); }
 
-	int put_signal( const int h, const valarray<TFloat>& src)
-		{ return put_region_smpl( h, src, 0); }
+        int put_signal( const int h, const valarray<TFloat>& src)
+                { return put_region_smpl( h, src, 0); }
 
       // signal data info
-	pair<TFloat, TFloat>
-	get_real_original_signal_range( const int h) const
-		{
-			auto x = get_signal_original( h);
-			return {x.min(), x.max()};
-		}
-
-	pair<TFloat, TFloat>
-	get_real_filtered_signal_range( const int h) const
-		{
-			auto x = get_signal_filtered( h);
-			return {x.min(), x.max()};
-		}
-
-	pair<TFloat, TFloat>
-	get_max_filtered_signal_range( const int h) const
-		{
-			auto x = get_signal_filtered( h);
-			return {x.min(), x.max()};   // an approximate
-		}
+        pair<TFloat, TFloat>
+        get_real_original_signal_range( const int h) const
+                {
+                        auto x = get_signal_original( h);
+                        return {x.min(), x.max()};
+                }
+
+        pair<TFloat, TFloat>
+        get_real_filtered_signal_range( const int h) const
+                {
+                        auto x = get_signal_filtered( h);
+                        return {x.min(), x.max()};
+                }
+
+        pair<TFloat, TFloat>
+        get_max_filtered_signal_range( const int h) const
+                {
+                        auto x = get_signal_filtered( h);
+                        return {x.min(), x.max()};   // an approximate
+                }
 
       // adjust capacity
-	size_t
-	resize_seconds( double);
+        size_t
+        resize_seconds( double);
 
       // reporting & misc
-	string details( int which_details) const;
+        string details( int which_details) const;
 
-	sigproc::TWinType af_dampen_window_type; // master copy
+        sigproc::TWinType af_dampen_window_type; // master copy
 
-	map<string,string>
-		metadata;
+        map<string,string>
+                metadata;
 
       // channels
-	struct SSignal {
-		SSignal (const SChannel& ch)
-		      : ucd (ch)
-			{}
-
-		SChannel
-			ucd; // Universal Channel Designation, епта
-
-		double	scale;
-
-		valarray<TFloat>
-			data;
-
-		bool operator==( const SChannel& h) const
-			{
-				return ucd == h;
-			}
-		bool operator==( const string& h) const
-			{
-				return ucd.name() == h;
-			}
-
-		list<SAnnotation>
-			annotations;
-		SArtifacts
-			artifacts;
-		SFilterPack
-			filters;
-	};
-	vector<SSignal>
-		channels;
-
-	list<SAnnotation> // timepoints in seconds
-		common_annotations;
+        struct SSignal {
+                SSignal (const SChannel& ch)
+                      : ucd (ch)
+                        {}
+
+                SChannel
+                        ucd; // Universal Channel Designation, епта
+
+                double        scale;
+
+                valarray<TFloat>
+                        data;
+
+                bool operator==( const SChannel& h) const
+                        {
+                                return ucd == h;
+                        }
+                bool operator==( const string& h) const
+                        {
+                                return ucd.name() == h;
+                        }
+
+                list<SAnnotation>
+                        annotations;
+                SArtifacts
+                        artifacts;
+                SFilterPack
+                        filters;
+        };
+        vector<SSignal>
+                channels;
+
+        list<SAnnotation> // timepoints in seconds
+                common_annotations;
 
       // signal accessors
-	SSignal& operator[]( size_t i)
-		{
-			if ( unlikely (i >= channels.size()) )
-				throw out_of_range ("Signal index out of range");
-			return channels[i];
-		}
-	const SSignal& operator[]( size_t i) const
-		{
-			if ( unlikely( i >= channels.size()) )
-				throw out_of_range ("Signal index out of range");
-			return channels[i];
-		}
-
-	SSignal& operator[]( const SChannel& h)
-		{
-			auto S = find( channels.begin(), channels.end(), h);
-			if ( S == channels.end() )
-				throw out_of_range (string ("Unknown channel ") + h.name());
-			return *S;
-		}
-	const SSignal& operator[]( const SChannel& h) const
-		{
-			auto S = find( channels.begin(), channels.end(), h);
-			if ( S == channels.end() )
-				throw out_of_range (string ("Unknown channel ") + h.name());
-			return *S;
-		}
-
-
-	enum TStatus : int_least32_t {
-		bad_channel_count        = (1 << (COMMON_STATUS_BITS + 1)),
-		bad_offset		 = (1 << (COMMON_STATUS_BITS + 2)),
-		offsets_not_incteasing	 = (1 << (COMMON_STATUS_BITS + 3)),
-		inoperable		 = (bad_header
-					   | bad_numfld
-					   | bad_datetime
-					   | dup_channels
-					   | sysfail
-					   | too_many_channels
-					   | bad_offset
-					   | offsets_not_incteasing)
-	};
-	static string explain_status( int);
+        SSignal& operator[]( size_t i)
+                {
+                        if ( unlikely (i >= channels.size()) )
+                                throw out_of_range ("Signal index out of range");
+                        return channels[i];
+                }
+        const SSignal& operator[]( size_t i) const
+                {
+                        if ( unlikely( i >= channels.size()) )
+                                throw out_of_range ("Signal index out of range");
+                        return channels[i];
+                }
+
+        SSignal& operator[]( const SChannel& h)
+                {
+                        auto S = find( channels.begin(), channels.end(), h);
+                        if ( S == channels.end() )
+                                throw out_of_range (string ("Unknown channel ") + h.name());
+                        return *S;
+                }
+        const SSignal& operator[]( const SChannel& h) const
+                {
+                        auto S = find( channels.begin(), channels.end(), h);
+                        if ( S == channels.end() )
+                                throw out_of_range (string ("Unknown channel ") + h.name());
+                        return *S;
+                }
+
+
+        enum TStatus : int_least32_t {
+                bad_channel_count        = (1 << (COMMON_STATUS_BITS + 1)),
+                bad_offset                 = (1 << (COMMON_STATUS_BITS + 2)),
+                offsets_not_incteasing         = (1 << (COMMON_STATUS_BITS + 3)),
+                inoperable                 = (bad_header
+                                           | bad_numfld
+                                           | bad_datetime
+                                           | dup_channels
+                                           | sysfail
+                                           | too_many_channels
+                                           | bad_offset
+                                           | offsets_not_incteasing)
+        };
+        static string explain_status( int);
 
     private:
       // header...
-	string	_episode,
-		_session;
+        string        _episode,
+                _session;
 
-	TSubtype _subtype;
+        TSubtype _subtype;
 
-	size_t	_samplerate;
+        size_t        _samplerate;
 
-	FILE	*_f;
-	char	*_line0;
-	size_t	_line0_mallocked_bytes;
+        FILE        *_f;
+        char        *_line0;
+        size_t        _line0_mallocked_bytes;
 
-	int _parse_header();
-	int _read_data();
+        int _parse_header();
+        int _read_data();
 };
 
 
diff --git a/upstream/src/libsigfile/typed-source.cc b/upstream/src/libsigfile/typed-source.cc
index 0214a0b..a178b1e 100644
--- a/upstream/src/libsigfile/typed-source.cc
+++ b/upstream/src/libsigfile/typed-source.cc
@@ -25,36 +25,36 @@ using sigfile::CEDFFile;
 
 CTypedSource::
 CTypedSource (const string& fname,
-	      const size_t pagesize,
-	      const int flags)
+              const size_t pagesize,
+              const int flags)
       : CHypnogram (pagesize)
 {
-	switch ( _type = source_file_type(fname) ) {
-	case TType::ascii:
-		_obj = new CTSVFile( fname, flags);
-		break;
-	case TType::edf:
-		_obj = new CEDFFile( fname, flags);
-		break;
-
-	case TType::bin:
-		throw invalid_argument ("Source type 'bin' not supported");
-	case TType::unrecognised:
-		throw invalid_argument ("Unrecognised source type");
-	}
-
-	if ( flags | ~CSource::no_ancillary_files ) {
-		// CHypnogram::
-		CHypnogram::load( sigfile::make_fname_hypnogram(fname, pagesize));
-		size_t scorable_pages = ceil( _obj->recording_time() / pagesize);
-		if ( CHypnogram::pages() != scorable_pages ) {
-			if ( CHypnogram::pages() > 0 )
-				fprintf( stderr, "CSource(\"%s\"): number of scorable pages @pagesize=%zu (%g / %zu = %zu) "
-					 "differs from the number read from hypnogram file (%zu); adjusting hypnogram size\n",
-					 fname.c_str(), pagesize, _obj->recording_time(), pagesize, scorable_pages, CHypnogram::pages());
-			CHypnogram::_pages.resize( scorable_pages);
-		}
-	}
+        switch ( _type = source_file_type(fname) ) {
+        case TType::ascii:
+                _obj = new CTSVFile( fname, flags);
+                break;
+        case TType::edf:
+                _obj = new CEDFFile( fname, flags);
+                break;
+
+        case TType::bin:
+                throw invalid_argument ("Source type 'bin' not supported");
+        case TType::unrecognised:
+                throw invalid_argument ("Unrecognised source type");
+        }
+
+        if ( flags | ~CSource::no_ancillary_files ) {
+                // CHypnogram::
+                CHypnogram::load( sigfile::make_fname_hypnogram(fname, pagesize));
+                size_t scorable_pages = ceil( _obj->recording_time() / pagesize);
+                if ( CHypnogram::pages() != scorable_pages ) {
+                        if ( CHypnogram::pages() > 0 )
+                                fprintf( stderr, "CSource(\"%s\"): number of scorable pages @pagesize=%zu (%g / %zu = %zu) "
+                                         "differs from the number read from hypnogram file (%zu); adjusting hypnogram size\n",
+                                         fname.c_str(), pagesize, _obj->recording_time(), pagesize, scorable_pages, CHypnogram::pages());
+                        CHypnogram::_pages.resize( scorable_pages);
+                }
+        }
 }
 
 
@@ -63,20 +63,20 @@ CTypedSource::
 CTypedSource (CTypedSource&& rv)
       : CHypnogram (move(rv))
 {
-	_type   = rv._type;
-	_obj    = rv._obj;
-	rv._obj = nullptr;
+        _type   = rv._type;
+        _obj    = rv._obj;
+        rv._obj = nullptr;
 }
 
 
 CTypedSource::
 ~CTypedSource ()
 {
-	if ( _obj ) {
-		if ( not (_obj->_flags & CSource::no_ancillary_files) )
-			CHypnogram::save( make_fname_hypnogram());
-		delete _obj;
-	}
+        if ( _obj ) {
+                if ( not (_obj->_flags & CSource::no_ancillary_files) )
+                        CHypnogram::save( make_fname_hypnogram());
+                delete _obj;
+        }
 }
 
 
@@ -85,16 +85,16 @@ CTypedSource::TType
 CTypedSource::
 source_file_type( const string& fname)
 {
-	if ( fname.size() > 4 &&
-	     strcasecmp( &fname[fname.size()-4], ".edf") == 0 )
-		return TType::edf;
+        if ( fname.size() > 4 &&
+             strcasecmp( &fname[fname.size()-4], ".edf") == 0 )
+                return TType::edf;
 
-	if ( fname.size() > 4 &&
-	     (strcasecmp( &fname[fname.size()-4], ".tsv") == 0 ||
-	      strcasecmp( &fname[fname.size()-4], ".csv") == 0 ) )
-		return TType::ascii;
+        if ( fname.size() > 4 &&
+             (strcasecmp( &fname[fname.size()-4], ".tsv") == 0 ||
+              strcasecmp( &fname[fname.size()-4], ".csv") == 0 ) )
+                return TType::ascii;
 
-	return TType::unrecognised;
+        return TType::unrecognised;
 }
 
 
diff --git a/upstream/src/libsigfile/typed-source.hh b/upstream/src/libsigfile/typed-source.hh
index abee6ee..6e1980a 100644
--- a/upstream/src/libsigfile/typed-source.hh
+++ b/upstream/src/libsigfile/typed-source.hh
@@ -30,54 +30,54 @@ namespace sigfile {
 class CTypedSource
   : public CHypnogram {
 
-	void operator=( const CTypedSource&) = delete;
-	CTypedSource () = delete;
+        void operator=( const CTypedSource&) = delete;
+        CTypedSource () = delete;
     public:
-	enum class TType : int {
-		unrecognised,
-		bin, ascii,
-		edf,
-	};
+        enum class TType : int {
+                unrecognised,
+                bin, ascii,
+                edf,
+        };
 
     private:
-	TType	_type;  // rtti is evil
-	CSource
-		*_obj;
+        TType        _type;  // rtti is evil
+        CSource
+                *_obj;
     public:
-	CTypedSource (const CTypedSource&)
-	      : CHypnogram (-1)
-		{
-			throw invalid_argument("nono");
-		}
+        CTypedSource (const CTypedSource&)
+              : CHypnogram (-1)
+                {
+                        throw invalid_argument("nono");
+                }
       // ctor
-	CTypedSource (const string& fname, size_t pagesize, int flags = 0);
-	CTypedSource (CTypedSource&& rv);
+        CTypedSource (const string& fname, size_t pagesize, int flags = 0);
+        CTypedSource (CTypedSource&& rv);
        ~CTypedSource ();
 
-	TType type() const { return _type; }
+        TType type() const { return _type; }
 
       // passthrough to obj
-	CSource& operator()()
-		{ return *_obj; }
-	const CSource& operator()() const
-		{ return *_obj; }
+        CSource& operator()()
+                { return *_obj; }
+        const CSource& operator()() const
+                { return *_obj; }
 
-	// specialisations for the two known sigfile types
-	template <class T> T& obj();
-	template <class T> const T& obj() const;
+        // specialisations for the two known sigfile types
+        template <class T> T& obj();
+        template <class T> const T& obj() const;
 
       // filenames
-	string make_fname_hypnogram() const
-		{
-			return sigfile::make_fname_hypnogram( _obj->filename(), pagesize());
-		}
+        string make_fname_hypnogram() const
+                {
+                        return sigfile::make_fname_hypnogram( _obj->filename(), pagesize());
+                }
 
-	static TType source_file_type( const string& fname) __attribute__ ((pure));
+        static TType source_file_type( const string& fname) __attribute__ ((pure));
 };
 
 
-template <> inline	 CTSVFile& CTypedSource::obj()       { return *(CTSVFile*)_obj; }
-template <> inline	 CEDFFile& CTypedSource::obj()       { return *(CEDFFile*)_obj; }
+template <> inline         CTSVFile& CTypedSource::obj()       { return *(CTSVFile*)_obj; }
+template <> inline         CEDFFile& CTypedSource::obj()       { return *(CEDFFile*)_obj; }
 template <> inline const CTSVFile& CTypedSource::obj() const { return *(CTSVFile*)_obj; }
 template <> inline const CEDFFile& CTypedSource::obj() const { return *(CEDFFile*)_obj; }
 
@@ -85,13 +85,13 @@ template <> inline const CEDFFile& CTypedSource::obj() const { return *(CEDFFile
 
 template <typename T = int>
 struct SNamedChannel {
-	CSource& source;
-	T sig_no;
-	SNamedChannel (CSource& source_, T sig_no_)
-	      : source (source_),
-		sig_no (sig_no_)
-		{}
-	SNamedChannel (const SNamedChannel&) = default;
+        CSource& source;
+        T sig_no;
+        SNamedChannel (CSource& source_, T sig_no_)
+              : source (source_),
+                sig_no (sig_no_)
+                {}
+        SNamedChannel (const SNamedChannel&) = default;
 };
 
 
diff --git a/upstream/src/libsigproc/exstrom.hh b/upstream/src/libsigproc/exstrom.hh
index 0741676..68ed9c8 100644
--- a/upstream/src/libsigproc/exstrom.hh
+++ b/upstream/src/libsigproc/exstrom.hh
@@ -93,27 +93,27 @@ namespace exstrom {
 
   n  -  The number of binomials to multiply
   p  -  Pointer to an array of doubles where p[2i] (i=0...n-1) is
-	assumed to be the real part of the coefficient of the ith binomial
-	and p[2i+1] is assumed to be the imaginary part. The overall size
-	of the array is then 2n.
+        assumed to be the real part of the coefficient of the ith binomial
+        and p[2i+1] is assumed to be the imaginary part. The overall size
+        of the array is then 2n.
 */
 
 template <typename T>
 valarray<T>
 binomial_mult( unsigned n, const valarray<T>& p)
 {
-	valarray<T> a (2*n);
-
-	unsigned i, j;
-	for ( i = 0; i < n; ++i ) {
-		for ( j = i; j > 0; --j ) {
-			a[2*j  ] += p[2*i] * a[2*(j-1)  ] - p[2*i+1] * a[2*(j-1)+1];
-			a[2*j+1] += p[2*i] * a[2*(j-1)+1] + p[2*i+1] * a[2*(j-1)  ];
-		}
-		a[0] += p[2*i  ];
-		a[1] += p[2*i+1];
-	}
-	return move(a);
+        valarray<T> a (2*n);
+
+        unsigned i, j;
+        for ( i = 0; i < n; ++i ) {
+                for ( j = i; j > 0; --j ) {
+                        a[2*j  ] += p[2*i] * a[2*(j-1)  ] - p[2*i+1] * a[2*(j-1)+1];
+                        a[2*j+1] += p[2*i] * a[2*(j-1)+1] + p[2*i+1] * a[2*(j-1)  ];
+                }
+                a[0] += p[2*i  ];
+                a[1] += p[2*i+1];
+        }
+        return move(a);
 }
 
 
@@ -153,33 +153,33 @@ template <typename T>
 valarray<T>
 trinomial_mult( unsigned n, const valarray<T>& b, const valarray<T>& c)
 {
-	valarray<T> a (4*n);
+        valarray<T> a (4*n);
 
-	a[2] = c[0];
-	a[3] = c[1];
-	a[0] = b[0];
-	a[1] = b[1];
+        a[2] = c[0];
+        a[3] = c[1];
+        a[0] = b[0];
+        a[1] = b[1];
 
-	unsigned i, j;
+        unsigned i, j;
 
-	for( i = 1; i < n; ++i ) {
-		a[2*(2*i+1)]   += c[2*i]*a[2*(2*i-1)]   - c[2*i+1]*a[2*(2*i-1)+1];
-		a[2*(2*i+1)+1] += c[2*i]*a[2*(2*i-1)+1] + c[2*i+1]*a[2*(2*i-1)  ];
+        for( i = 1; i < n; ++i ) {
+                a[2*(2*i+1)]   += c[2*i]*a[2*(2*i-1)]   - c[2*i+1]*a[2*(2*i-1)+1];
+                a[2*(2*i+1)+1] += c[2*i]*a[2*(2*i-1)+1] + c[2*i+1]*a[2*(2*i-1)  ];
 
-		for ( j = 2*i; j > 1; --j ) {
-			a[2*j]   += b[2*i] * a[2*(j-1)]   - b[2*i+1] * a[2*(j-1)+1] +
-				c[2*i] * a[2*(j-2)]   - c[2*i+1] * a[2*(j-2)+1];
-			a[2*j+1] += b[2*i] * a[2*(j-1)+1] + b[2*i+1] * a[2*(j-1)] +
-				c[2*i] * a[2*(j-2)+1] + c[2*i+1] * a[2*(j-2)  ];
-		}
+                for ( j = 2*i; j > 1; --j ) {
+                        a[2*j]   += b[2*i] * a[2*(j-1)]   - b[2*i+1] * a[2*(j-1)+1] +
+                                c[2*i] * a[2*(j-2)]   - c[2*i+1] * a[2*(j-2)+1];
+                        a[2*j+1] += b[2*i] * a[2*(j-1)+1] + b[2*i+1] * a[2*(j-1)] +
+                                c[2*i] * a[2*(j-2)+1] + c[2*i+1] * a[2*(j-2)  ];
+                }
 
-		a[2] += b[2*i] * a[0] - b[2*i+1] * a[1] + c[2*i  ];
-		a[3] += b[2*i] * a[1] + b[2*i+1] * a[0] + c[2*i+1];
-		a[0] += b[2*i  ];
-		a[1] += b[2*i+1];
-	}
+                a[2] += b[2*i] * a[0] - b[2*i+1] * a[1] + c[2*i  ];
+                a[3] += b[2*i] * a[1] + b[2*i+1] * a[0] + c[2*i+1];
+                a[0] += b[2*i  ];
+                a[1] += b[2*i+1];
+        }
 
-	return move(a);
+        return move(a);
 }
 
 /**********************************************************************
@@ -192,39 +192,39 @@ template <typename T>
 valarray<T>
 dcof_bwlp( unsigned n, T fcf)
 {
-	T	theta,     // M_PI * fcf / 2.0
-		st,        // sine of theta
-		ct,        // cosine of theta
-		parg,      // pole angle
-		sparg,     // sine of the pole angle
-		cparg,     // cosine of the pole angle
-		a;         // workspace variable
-	valarray<T>
-		rcof (2*n), // binomial coefficients
-		dcof;	    // dk coefficients
-
-	theta = M_PI * fcf;
-	st = sin(theta);
-	ct = cos(theta);
-
-	unsigned k;
-	for ( k = 0; k < n; ++k ) {
-		parg = M_PI * (T)(2*k+1)/(T)(2*n);
-		sparg = sin(parg);
-		cparg = cos(parg);
-		a = 1.0 + st*sparg;
-		rcof[2*k] = -ct/a;
-		rcof[2*k+1] = -st*cparg/a;
-	}
-
-	dcof = binomial_mult( n, rcof);
-
-	dcof[1] = dcof[0];
-	dcof[0] = 1.0;
-	for ( k = 3; k <= n; ++k )
-		dcof[k] = dcof[2*k-2];
-
-	return move(dcof);
+        T        theta,     // M_PI * fcf / 2.0
+                st,        // sine of theta
+                ct,        // cosine of theta
+                parg,      // pole angle
+                sparg,     // sine of the pole angle
+                cparg,     // cosine of the pole angle
+                a;         // workspace variable
+        valarray<T>
+                rcof (2*n), // binomial coefficients
+                dcof;            // dk coefficients
+
+        theta = M_PI * fcf;
+        st = sin(theta);
+        ct = cos(theta);
+
+        unsigned k;
+        for ( k = 0; k < n; ++k ) {
+                parg = M_PI * (T)(2*k+1)/(T)(2*n);
+                sparg = sin(parg);
+                cparg = cos(parg);
+                a = 1.0 + st*sparg;
+                rcof[2*k] = -ct/a;
+                rcof[2*k+1] = -st*cparg/a;
+        }
+
+        dcof = binomial_mult( n, rcof);
+
+        dcof[1] = dcof[0];
+        dcof[0] = 1.0;
+        for ( k = 3; k <= n; ++k )
+                dcof[k] = dcof[2*k-2];
+
+        return move(dcof);
 }
 
 
@@ -237,7 +237,7 @@ template <typename T>
 valarray<T>
 dcof_bwhp( unsigned n, T fcf)
 {
-	return move(dcof_bwlp( n, fcf));
+        return move(dcof_bwlp( n, fcf));
 }
 
 
@@ -251,48 +251,48 @@ template <typename T>
 valarray<T>
 dcof_bwbp( unsigned n, T f1f, T f2f)
 {
-	T	theta,     // M_PI * (f2f - f1f) / 2.0
-		cp,        // cosine of phi
-		st,        // sine of theta
-		ct,        // cosine of theta
-		s2t,       // sine of 2*theta
-		c2t,       // cosine 0f 2*theta
-		parg,      // pole angle
-		sparg,     // sine of pole angle
-		cparg,     // cosine of pole angle
-		a;         // workspace variables
-
-	cp = cos(M_PI * (f2f + f1f) / 2.0);
-	theta = M_PI * (f2f - f1f) / 2.0;
-	st = sin(theta);
-	ct = cos(theta);
-	s2t = 2.0*st*ct;        // sine of 2*theta
-	c2t = 2.0*ct*ct - 1.0;  // cosine 0f 2*theta
-
-	valarray<T>
-		rcof (2*n), // z^-2 coefficients
-		tcof (2*n); // z^-1 coefficients
-
-	unsigned k;
-	for ( k = 0; k < n; ++k ) {
-		parg = M_PI * (T)(2*k+1)/(T)(2*n);
-		sparg = sin(parg);
-		cparg = cos(parg);
-		a = 1.0 + s2t*sparg;
-		rcof[2*k] = c2t/a;
-		rcof[2*k+1] = -s2t*cparg/a;
-		tcof[2*k] = -2.0*cp*(ct+st*sparg)/a;
-		tcof[2*k+1] = 2.0*cp*st*cparg/a;
-	}
-
-	valarray<T> dcof // dk coefficients
-		= trinomial_mult( n, tcof, rcof);
-
-	dcof[1] = dcof[0];
-	dcof[0] = 1.0;
-	for ( k = 3; k <= 2*n; ++k )
-		dcof[k] = dcof[2*k-2];
-	return move(dcof);
+        T        theta,     // M_PI * (f2f - f1f) / 2.0
+                cp,        // cosine of phi
+                st,        // sine of theta
+                ct,        // cosine of theta
+                s2t,       // sine of 2*theta
+                c2t,       // cosine 0f 2*theta
+                parg,      // pole angle
+                sparg,     // sine of pole angle
+                cparg,     // cosine of pole angle
+                a;         // workspace variables
+
+        cp = cos(M_PI * (f2f + f1f) / 2.0);
+        theta = M_PI * (f2f - f1f) / 2.0;
+        st = sin(theta);
+        ct = cos(theta);
+        s2t = 2.0*st*ct;        // sine of 2*theta
+        c2t = 2.0*ct*ct - 1.0;  // cosine 0f 2*theta
+
+        valarray<T>
+                rcof (2*n), // z^-2 coefficients
+                tcof (2*n); // z^-1 coefficients
+
+        unsigned k;
+        for ( k = 0; k < n; ++k ) {
+                parg = M_PI * (T)(2*k+1)/(T)(2*n);
+                sparg = sin(parg);
+                cparg = cos(parg);
+                a = 1.0 + s2t*sparg;
+                rcof[2*k] = c2t/a;
+                rcof[2*k+1] = -s2t*cparg/a;
+                tcof[2*k] = -2.0*cp*(ct+st*sparg)/a;
+                tcof[2*k+1] = 2.0*cp*st*cparg/a;
+        }
+
+        valarray<T> dcof // dk coefficients
+                = trinomial_mult( n, tcof, rcof);
+
+        dcof[1] = dcof[0];
+        dcof[0] = 1.0;
+        for ( k = 3; k <= 2*n; ++k )
+                dcof[k] = dcof[2*k-2];
+        return move(dcof);
 }
 
 
@@ -308,21 +308,21 @@ inline
 valarray<int>
 ccof_bwlp( unsigned n)
 {
-	int m, i;
+        int m, i;
 
-	valarray<int> ccof (n+1);
+        valarray<int> ccof (n+1);
 
-	ccof[0] = 1;
-	ccof[1] = n;
-	m = n/2;
-	for ( i = 2; i <= m; ++i ) {
-		ccof[  i] = (n-i+1)*ccof[i-1]/i;
-		ccof[n-i] = ccof[i];
-	}
-	ccof[n-1] = n;
-	ccof[n] = 1;
+        ccof[0] = 1;
+        ccof[1] = n;
+        m = n/2;
+        for ( i = 2; i <= m; ++i ) {
+                ccof[  i] = (n-i+1)*ccof[i-1]/i;
+                ccof[n-i] = ccof[i];
+        }
+        ccof[n-1] = n;
+        ccof[n] = 1;
 
-	return move(ccof);
+        return move(ccof);
 }
 
 
@@ -336,12 +336,12 @@ inline
 valarray<int>
 ccof_bwhp( unsigned n)
 {
-	valarray<int> ccof = ccof_bwlp( n);
-	for ( unsigned i = 0; i <= n; ++i )
-		if ( i % 2 )
-			ccof[i] = -ccof[i];
+        valarray<int> ccof = ccof_bwlp( n);
+        for ( unsigned i = 0; i <= n; ++i )
+                if ( i % 2 )
+                        ccof[i] = -ccof[i];
 
-	return move(ccof);
+        return move(ccof);
 }
 
 
@@ -355,17 +355,17 @@ inline
 valarray<int>
 ccof_bwbp( unsigned n)
 {
-	valarray<int>
-		ccof (2*n + 1);
-	valarray<int>
-		tcof = ccof_bwhp( n);
-
-	for ( size_t i = 0; i < n; ++i ) {
-		ccof[2*i] = tcof[i];
-		ccof[2*i+1] = 0.0;
-	}
-	ccof[2*n] = tcof[n];
-	return move(ccof);
+        valarray<int>
+                ccof (2*n + 1);
+        valarray<int>
+                tcof = ccof_bwhp( n);
+
+        for ( size_t i = 0; i < n; ++i ) {
+                ccof[2*i] = tcof[i];
+                ccof[2*i+1] = 0.0;
+        }
+        ccof[2*n] = tcof[n];
+        return move(ccof);
 }
 
 
@@ -379,24 +379,24 @@ template <typename T>
 valarray<T>
 ccof_bwbs( unsigned n, T f1f, T f2f)
 {
-	T alpha = -2.0 * cos( M_PI * (f2f + f1f) / 2.0) / cos(M_PI * (f2f - f1f) / 2.0);
-	valarray<T> ccof (2*n + 1);
+        T alpha = -2.0 * cos( M_PI * (f2f + f1f) / 2.0) / cos(M_PI * (f2f - f1f) / 2.0);
+        valarray<T> ccof (2*n + 1);
 
-	ccof[0] = 1.0;
+        ccof[0] = 1.0;
 
-	ccof[2] = 1.0;
-	ccof[1] = alpha;
+        ccof[2] = 1.0;
+        ccof[1] = alpha;
 
-	for( size_t i = 1; i < n; ++i ) {
-		ccof[2*i + 2] += ccof[2*i];
-		for( size_t j = 2*i; j > 1; --j )
-			ccof[j+1] += alpha * ccof[j] + ccof[j-1];
+        for( size_t i = 1; i < n; ++i ) {
+                ccof[2*i + 2] += ccof[2*i];
+                for( size_t j = 2*i; j > 1; --j )
+                        ccof[j+1] += alpha * ccof[j] + ccof[j-1];
 
-		ccof[2] += alpha * ccof[1] + 1.0;
-		ccof[1] += alpha;
-	}
+                ccof[2] += alpha * ccof[1] + 1.0;
+                ccof[1] += alpha;
+        }
 
-	return move(ccof);
+        return move(ccof);
 }
 
 
@@ -413,24 +413,24 @@ template <typename T>
 T
 sf_bwlp( unsigned n, T fcf)
 {
-	T	omega = M_PI * fcf,      // M_PI * fcf
-		fomega = sin(omega),     // function of omega
-		parg0 = M_PI / (T)(2*n), // zeroth pole angle
-		sf;                      // scaling factor
+        T        omega = M_PI * fcf,      // M_PI * fcf
+                fomega = sin(omega),     // function of omega
+                parg0 = M_PI / (T)(2*n), // zeroth pole angle
+                sf;                      // scaling factor
 
-	unsigned k;
-	//m = n / 2;
-	sf = 1.0;
-	for( k = 0; k < n/2; ++k )
-		sf *= 1.0 + fomega * sin((T)(2*k+1)*parg0);
+        unsigned k;
+        //m = n / 2;
+        sf = 1.0;
+        for( k = 0; k < n/2; ++k )
+                sf *= 1.0 + fomega * sin((T)(2*k+1)*parg0);
 
-	fomega = sin(omega / 2.0);
+        fomega = sin(omega / 2.0);
 
-	if ( n % 2 )
-		sf *= fomega + cos(omega / 2.0);
-	sf = pow( fomega, n) / sf;
+        if ( n % 2 )
+                sf *= fomega + cos(omega / 2.0);
+        sf = pow( fomega, n) / sf;
 
-	return sf;
+        return sf;
 }
 
 
@@ -447,24 +447,24 @@ template <typename T>
 T
 sf_bwhp( unsigned n, T fcf)
 {
-	T	omega = M_PI * fcf,      // M_PI * fcf
-		fomega = sin(omega),     // function of omega
-		parg0 = M_PI / (T)(2*n), // zeroth pole angle
-		sf;                      // scaling factor
+        T        omega = M_PI * fcf,      // M_PI * fcf
+                fomega = sin(omega),     // function of omega
+                parg0 = M_PI / (T)(2*n), // zeroth pole angle
+                sf;                      // scaling factor
 
-	unsigned k;
-	//m = n / 2;
-	sf = 1.0;
-	for ( k = 0; k < n/2; ++k )
-		sf *= 1.0 + fomega * sin((T)(2*k+1)*parg0);
+        unsigned k;
+        //m = n / 2;
+        sf = 1.0;
+        for ( k = 0; k < n/2; ++k )
+                sf *= 1.0 + fomega * sin((T)(2*k+1)*parg0);
 
-	fomega = cos(omega / 2.0);
+        fomega = cos(omega / 2.0);
 
-	if ( n % 2 )
-		sf *= fomega + cos(omega / 2.0);
-	sf = pow( fomega, n) / sf;
+        if ( n % 2 )
+                sf *= fomega + cos(omega / 2.0);
+        sf = pow( fomega, n) / sf;
 
-	return sf;
+        return sf;
 }
 
 
@@ -481,25 +481,25 @@ T
 __attribute__ ((const))
 sf_bwbp( unsigned n, T f1f, T f2f )
 {
-	T	ctt = 1.0 / tan(M_PI * (f2f - f1f) / 2.0),       // cotangent of theta
-		sfr = 1., sfi = 0.,  // real and imaginary parts of the scaling factor
-		parg,      // pole angle
-		sparg,     // sine of pole angle
-		cparg,     // cosine of pole angle
-		a, b, c;   // workspace variables
-
-	for ( unsigned k = 0; k < n; ++k ) {
-		parg = M_PI * (T)(2*k+1)/(T)(2*n);
-		sparg = ctt + sin(parg);
-		cparg = cos(parg);
-		a = (sfr + sfi)*(sparg - cparg);
-		b = sfr * sparg;
-		c = -sfi * cparg;
-		sfr = b - c;
-		sfi = a - b - c;
-	}
-
-	return 1.0 / sfr;
+        T        ctt = 1.0 / tan(M_PI * (f2f - f1f) / 2.0),       // cotangent of theta
+                sfr = 1., sfi = 0.,  // real and imaginary parts of the scaling factor
+                parg,      // pole angle
+                sparg,     // sine of pole angle
+                cparg,     // cosine of pole angle
+                a, b, c;   // workspace variables
+
+        for ( unsigned k = 0; k < n; ++k ) {
+                parg = M_PI * (T)(2*k+1)/(T)(2*n);
+                sparg = ctt + sin(parg);
+                cparg = cos(parg);
+                a = (sfr + sfi)*(sparg - cparg);
+                b = sfr * sparg;
+                c = -sfi * cparg;
+                sfr = b - c;
+                sfi = a - b - c;
+        }
+
+        return 1.0 / sfr;
 }
 
 
@@ -508,25 +508,25 @@ T
 __attribute__ ((const))
 sf_bwbs( unsigned n, T f1f, T f2f )
 {
-	T	tt  = tan(M_PI * (f2f - f1f) / 2.0),       // tangent of theta
-		sfr = 1., sfi = 0.,  // real and imaginary parts of the scaling factor
-		parg,      // pole angle
-		sparg,     // sine of pole angle
-		cparg,     // cosine of pole angle
-		a, b, c;   // workspace variables
-
-	for ( unsigned k = 0; k < n; ++k ) {
-		parg = M_PI * (double)(2*k+1)/(double)(2*n);
-		sparg = tt + sin(parg);
-		cparg = cos(parg);
-		a = (sfr + sfi)*(sparg - cparg);
-		b = sfr * sparg;
-		c = -sfi * cparg;
-		sfr = b - c;
-		sfi = a - b - c;
-	}
-
-	return 1.0 / sfr;
+        T        tt  = tan(M_PI * (f2f - f1f) / 2.0),       // tangent of theta
+                sfr = 1., sfi = 0.,  // real and imaginary parts of the scaling factor
+                parg,      // pole angle
+                sparg,     // sine of pole angle
+                cparg,     // cosine of pole angle
+                a, b, c;   // workspace variables
+
+        for ( unsigned k = 0; k < n; ++k ) {
+                parg = M_PI * (double)(2*k+1)/(double)(2*n);
+                sparg = tt + sin(parg);
+                cparg = cos(parg);
+                a = (sfr + sfi)*(sparg - cparg);
+                b = sfr * sparg;
+                c = -sfi * cparg;
+                sfr = b - c;
+                sfi = a - b - c;
+        }
+
+        return 1.0 / sfr;
 }
 
 
@@ -540,97 +540,97 @@ sf_bwbs( unsigned n, T f1f, T f2f )
 template <typename T>
 valarray<T>
 low_pass( const valarray<T>& in,
-	  size_t samplerate,
-	  float cutoff, unsigned order, bool scale)
+          size_t samplerate,
+          float cutoff, unsigned order, bool scale)
 {
-//	printf( "low_pass( %zu, %g, %u, %d)\n", samplerate, cutoff, order, scale);
-	size_t	i, j;
-
-	T	fcf = 2. * cutoff/samplerate;
-	valarray<T>
-		dcof = dcof_bwlp( order, fcf);		/* the d coefficients */
-	valarray<int>
-		ccof_ = ccof_bwlp( order);		/* the c coefficients */
-	valarray<T>
-		ccof (ccof_.size());
-	if ( scale )
-		for ( i = 0; i < ccof_.size(); ++i )
-			ccof[i] = ccof_[i] * sf_bwlp( order, fcf);
-	else
-		for ( i = 0; i < ccof_.size(); ++i )
-			ccof[i] = ccof_[i];
-
-	unsigned
-		nc = ccof.size(),
-		nd = dcof.size();
-	size_t	in_size = in.size(),
-		out_size = in_size + nc;
-	valarray<T> out (out_size);
-
-	for ( i = 0; i < out_size; ++i ) {
-		T s1 = 0., s2 = 0.;
-		for( j = (i < nd ? 0 : i - nd + 1); j < i; ++j )
-			s1 += dcof[i-j] * out[j];
-
-		for( j = (i < nc ? 0 : i - nc + 1); j <= (i < in_size ? i : in_size - 1); ++j )
-			s2 += ccof[i-j] * in[j];
-
-		out[i] = s2 - s1;
-	}
-
-	return move(out);
+//        printf( "low_pass( %zu, %g, %u, %d)\n", samplerate, cutoff, order, scale);
+        size_t        i, j;
+
+        T        fcf = 2. * cutoff/samplerate;
+        valarray<T>
+                dcof = dcof_bwlp( order, fcf);                /* the d coefficients */
+        valarray<int>
+                ccof_ = ccof_bwlp( order);                /* the c coefficients */
+        valarray<T>
+                ccof (ccof_.size());
+        if ( scale )
+                for ( i = 0; i < ccof_.size(); ++i )
+                        ccof[i] = ccof_[i] * sf_bwlp( order, fcf);
+        else
+                for ( i = 0; i < ccof_.size(); ++i )
+                        ccof[i] = ccof_[i];
+
+        unsigned
+                nc = ccof.size(),
+                nd = dcof.size();
+        size_t        in_size = in.size(),
+                out_size = in_size + nc;
+        valarray<T> out (out_size);
+
+        for ( i = 0; i < out_size; ++i ) {
+                T s1 = 0., s2 = 0.;
+                for( j = (i < nd ? 0 : i - nd + 1); j < i; ++j )
+                        s1 += dcof[i-j] * out[j];
+
+                for( j = (i < nc ? 0 : i - nc + 1); j <= (i < in_size ? i : in_size - 1); ++j )
+                        s2 += ccof[i-j] * in[j];
+
+                out[i] = s2 - s1;
+        }
+
+        return move(out);
 }
 
 
 template <typename T>
 valarray<T>
 high_pass( const valarray<T>& in,
-	   size_t samplerate,
-	   float cutoff, unsigned order, bool scale)
+           size_t samplerate,
+           float cutoff, unsigned order, bool scale)
 {
-	size_t	i, j;
-
-	T	fcf = 2. * cutoff/samplerate;
-	valarray<T>
-		dcof = dcof_bwhp( order, fcf);		/* the d coefficients */
-	// printf( "dcof: ");
-	// for ( i = 0; i < dcof.size(); ++i )
-	// 	printf( " %g", dcof[i]);
-	// printf( "\n");
-	valarray<int>
-		ccof_ = ccof_bwhp( order);		/* the c coefficients */
-	valarray<T>
-		ccof (ccof_.size());
-	if ( scale )
-		for ( i = 0; i < ccof_.size(); ++i )
-			ccof[i] = ccof_[i] * sf_bwhp( order, fcf);
-	else
-		for ( i = 0; i < ccof_.size(); ++i )
-			ccof[i] = ccof_[i];
-	// printf( "ccof: ");
-	// for ( i = 0; i < ccof.size(); ++i )
-	// 	printf( " %g", ccof[i]);
-	// printf( "\n");
-
-	unsigned
-		nc = ccof.size(),
-		nd = dcof.size();
-	size_t	in_size = in.size(),
-		out_size = in_size + nc;
-	valarray<T> out (out_size);
-
-	for ( i = 0; i < out_size; ++i ) {
-		T s1 = 0., s2 = 0.;
-		for( j = (i < nd ? 0 : i - nd + 1); j < i; ++j )
-			s1 += dcof[i-j] * out[j];
-
-		for( j = (i < nc ? 0 : i - nc + 1); j <= (i < in_size ? i : in_size - 1); ++j )
-			s2 += ccof[i-j] * in[j];
-
-		out[i] = s2 - s1;
-	}
-
-	return move(out);
+        size_t        i, j;
+
+        T        fcf = 2. * cutoff/samplerate;
+        valarray<T>
+                dcof = dcof_bwhp( order, fcf);                /* the d coefficients */
+        // printf( "dcof: ");
+        // for ( i = 0; i < dcof.size(); ++i )
+        //         printf( " %g", dcof[i]);
+        // printf( "\n");
+        valarray<int>
+                ccof_ = ccof_bwhp( order);                /* the c coefficients */
+        valarray<T>
+                ccof (ccof_.size());
+        if ( scale )
+                for ( i = 0; i < ccof_.size(); ++i )
+                        ccof[i] = ccof_[i] * sf_bwhp( order, fcf);
+        else
+                for ( i = 0; i < ccof_.size(); ++i )
+                        ccof[i] = ccof_[i];
+        // printf( "ccof: ");
+        // for ( i = 0; i < ccof.size(); ++i )
+        //         printf( " %g", ccof[i]);
+        // printf( "\n");
+
+        unsigned
+                nc = ccof.size(),
+                nd = dcof.size();
+        size_t        in_size = in.size(),
+                out_size = in_size + nc;
+        valarray<T> out (out_size);
+
+        for ( i = 0; i < out_size; ++i ) {
+                T s1 = 0., s2 = 0.;
+                for( j = (i < nd ? 0 : i - nd + 1); j < i; ++j )
+                        s1 += dcof[i-j] * out[j];
+
+                for( j = (i < nc ? 0 : i - nc + 1); j <= (i < in_size ? i : in_size - 1); ++j )
+                        s2 += ccof[i-j] * in[j];
+
+                out[i] = s2 - s1;
+        }
+
+        return move(out);
 }
 
 
@@ -639,110 +639,110 @@ high_pass( const valarray<T>& in,
 template <typename T>
 valarray<T>
 band_pass( const valarray<T>& in,
-	   size_t samplerate,
-	   float lo_cutoff, float hi_cutoff,
-	   unsigned order, bool scale)
+           size_t samplerate,
+           float lo_cutoff, float hi_cutoff,
+           unsigned order, bool scale)
 {
-	size_t	i, j;
-
-	T	f1f = 2. * lo_cutoff/samplerate,
-		f2f = 2. * hi_cutoff/samplerate;
-	valarray<T>
-		dcof = dcof_bwbp( order, f1f, f2f);		/* the d coefficients */
-	// printf( "dcof: ");
-	// for ( i = 0; i < dcof.size(); ++i )
-	// 	printf( " %g", dcof[i]);
-	// printf( "\n");
-	valarray<int>
-		ccof_ = ccof_bwbp( order);	/* the c coefficients */
-	valarray<T>
-		ccof (ccof_.size());
-	if ( scale ) {
-		T sf = sf_bwbp( order, f1f, f2f);
-		for ( i = 0; i < ccof_.size(); ++i )
-			ccof[i] = ccof_[i] * sf;
-	} else
-		for ( i = 0; i < ccof_.size(); ++i )
-			ccof[i] = ccof_[i];
-	// printf( "ccof: ");
-	// for ( i = 0; i < ccof.size(); ++i )
-	// 	printf( " %g", ccof[i]);
-	// printf( "\n");
-
-	unsigned
-		nc = ccof.size(),
-		nd = dcof.size();
-	size_t	in_size = in.size(),
-		out_size = in_size + nc;
-	valarray<T> out (out_size);
-
-	for( i = 0; i < out_size; ++i ) {
-		T s1 = 0., s2 = 0.;
-		for( j = (i < nd ? 0 : i - nd + 1); j < i; ++j )
-			s1 += dcof[i-j] * out[j];
-
-		for( j = (i < nc ? 0 : i - nc + 1); j <= (i < in_size ? i : in_size - 1); ++j )
-			s2 += ccof[i-j] * in[j];
-
-		out[i] = s2 - s1;
-	}
-
-	return move(out);
+        size_t        i, j;
+
+        T        f1f = 2. * lo_cutoff/samplerate,
+                f2f = 2. * hi_cutoff/samplerate;
+        valarray<T>
+                dcof = dcof_bwbp( order, f1f, f2f);                /* the d coefficients */
+        // printf( "dcof: ");
+        // for ( i = 0; i < dcof.size(); ++i )
+        //         printf( " %g", dcof[i]);
+        // printf( "\n");
+        valarray<int>
+                ccof_ = ccof_bwbp( order);        /* the c coefficients */
+        valarray<T>
+                ccof (ccof_.size());
+        if ( scale ) {
+                T sf = sf_bwbp( order, f1f, f2f);
+                for ( i = 0; i < ccof_.size(); ++i )
+                        ccof[i] = ccof_[i] * sf;
+        } else
+                for ( i = 0; i < ccof_.size(); ++i )
+                        ccof[i] = ccof_[i];
+        // printf( "ccof: ");
+        // for ( i = 0; i < ccof.size(); ++i )
+        //         printf( " %g", ccof[i]);
+        // printf( "\n");
+
+        unsigned
+                nc = ccof.size(),
+                nd = dcof.size();
+        size_t        in_size = in.size(),
+                out_size = in_size + nc;
+        valarray<T> out (out_size);
+
+        for( i = 0; i < out_size; ++i ) {
+                T s1 = 0., s2 = 0.;
+                for( j = (i < nd ? 0 : i - nd + 1); j < i; ++j )
+                        s1 += dcof[i-j] * out[j];
+
+                for( j = (i < nc ? 0 : i - nc + 1); j <= (i < in_size ? i : in_size - 1); ++j )
+                        s2 += ccof[i-j] * in[j];
+
+                out[i] = s2 - s1;
+        }
+
+        return move(out);
 }
 
 
 template <typename T>
 valarray<T>
 band_stop( const valarray<T>& in,
-	   size_t samplerate,
-	   float lo_cutoff, float hi_cutoff,
-	   unsigned order, bool scale)
+           size_t samplerate,
+           float lo_cutoff, float hi_cutoff,
+           unsigned order, bool scale)
 {
-	size_t	i, j;
-
-	T	f1f = 2. * lo_cutoff/samplerate,
-		f2f = 2. * hi_cutoff/samplerate;
-	valarray<T>
-		dcof = dcof_bwbp( order, f1f, f2f);		/* the d coefficients */
-	// printf( "dcof: ");
-	// for ( i = 0; i < dcof.size(); ++i )
-	// 	printf( " %g", dcof[i]);
-	// printf( "\n");
-	valarray<T>
-		ccof_ = ccof_bwbs<T>( order, f1f, f2f);	/* the c coefficients */
-	valarray<T>
-		ccof (ccof_.size());
-	if ( scale ) {
-		T sf = sf_bwbs( order, f1f, f2f);
-		for ( i = 0; i < ccof_.size(); ++i )
-			ccof[i] = ccof_[i] * sf;
-	} else
-		for ( i = 0; i < ccof_.size(); ++i )
-			ccof[i] = ccof_[i];
-	// printf( "ccof: ");
-	// for ( i = 0; i < ccof.size(); ++i )
-	// 	printf( " %g", ccof[i]);
-	// printf( "\n");
-
-	unsigned
-		nc = ccof.size(),
-		nd = dcof.size();
-	size_t	in_size = in.size(),
-		out_size = in_size + nc;
-	valarray<T> out (out_size);
-
-	for( i = 0; i < out_size; ++i ) {
-		T s1 = 0., s2 = 0.;
-		for( j = (i < nd ? 0 : i - nd + 1); j < i; ++j )
-			s1 += dcof[i-j] * out[j];
-
-		for( j = (i < nc ? 0 : i - nc + 1); j <= (i < in_size ? i : in_size - 1); ++j )
-			s2 += ccof[i-j] * in[j];
-
-		out[i] = s2 - s1;
-	}
-
-	return move(out);
+        size_t        i, j;
+
+        T        f1f = 2. * lo_cutoff/samplerate,
+                f2f = 2. * hi_cutoff/samplerate;
+        valarray<T>
+                dcof = dcof_bwbp( order, f1f, f2f);                /* the d coefficients */
+        // printf( "dcof: ");
+        // for ( i = 0; i < dcof.size(); ++i )
+        //         printf( " %g", dcof[i]);
+        // printf( "\n");
+        valarray<T>
+                ccof_ = ccof_bwbs<T>( order, f1f, f2f);        /* the c coefficients */
+        valarray<T>
+                ccof (ccof_.size());
+        if ( scale ) {
+                T sf = sf_bwbs( order, f1f, f2f);
+                for ( i = 0; i < ccof_.size(); ++i )
+                        ccof[i] = ccof_[i] * sf;
+        } else
+                for ( i = 0; i < ccof_.size(); ++i )
+                        ccof[i] = ccof_[i];
+        // printf( "ccof: ");
+        // for ( i = 0; i < ccof.size(); ++i )
+        //         printf( " %g", ccof[i]);
+        // printf( "\n");
+
+        unsigned
+                nc = ccof.size(),
+                nd = dcof.size();
+        size_t        in_size = in.size(),
+                out_size = in_size + nc;
+        valarray<T> out (out_size);
+
+        for( i = 0; i < out_size; ++i ) {
+                T s1 = 0., s2 = 0.;
+                for( j = (i < nd ? 0 : i - nd + 1); j < i; ++j )
+                        s1 += dcof[i-j] * out[j];
+
+                for( j = (i < nc ? 0 : i - nc + 1); j <= (i < in_size ? i : in_size - 1); ++j )
+                        s2 += ccof[i-j] * in[j];
+
+                out[i] = s2 - s1;
+        }
+
+        return move(out);
 }
 
 
diff --git a/upstream/src/libsigproc/ext-filters.hh b/upstream/src/libsigproc/ext-filters.hh
index e689df9..5e0cd09 100644
--- a/upstream/src/libsigproc/ext-filters.hh
+++ b/upstream/src/libsigproc/ext-filters.hh
@@ -29,179 +29,179 @@ enum TFilterDirection { forward, back };
 
 template <typename T>
 class CFilter_base {
-	DELETE_DEFAULT_METHODS (CFilter_base<T>);
+        DELETE_DEFAULT_METHODS (CFilter_base<T>);
 
     protected:
-	size_t samplerate;
-	TFilterDirection direction;
-
-	CFilter_base (size_t samplerate_,
-		      TFilterDirection direction_ = forward)
-	      : samplerate (samplerate_),
-		direction (direction_)
-		{
-			if ( samplerate_ == 0 )
-				throw invalid_argument ("CFilter_base(): samplerate is 0");
-		}
-
-	virtual valarray<T>
-	apply( const valarray<T>& in, bool) = 0;
-	void reset()
-		{}
+        size_t samplerate;
+        TFilterDirection direction;
+
+        CFilter_base (size_t samplerate_,
+                      TFilterDirection direction_ = forward)
+              : samplerate (samplerate_),
+                direction (direction_)
+                {
+                        if ( samplerate_ == 0 )
+                                throw invalid_argument ("CFilter_base(): samplerate is 0");
+                }
+
+        virtual valarray<T>
+        apply( const valarray<T>& in, bool) = 0;
+        void reset()
+                {}
 };
 
 
 template <typename T>
 class CFilterIIR
   : public CFilter_base<T> {
-	DELETE_DEFAULT_METHODS (CFilterIIR<T>);
+        DELETE_DEFAULT_METHODS (CFilterIIR<T>);
 
     protected:
-	CFilterIIR<T> (size_t samplerate_,
-		       TFilterDirection direction_,
-		       T gain_, T back_polate_)
-	      : CFilter_base<T> (samplerate_, direction_),
-		anticipate (true),
-		gain (gain_),
-		back_polate (back_polate_)
-		{
-			calculate_iir_coefficients();
-		}
-	virtual void reset()
-		{
-			CFilter_base<T>::reset();
-
-			calculate_iir_coefficients();
-
-			filter_state_z = 0.;
-			filter_state_p = 0.;
-		}
-
-	virtual void reset( T xn)
-		{
-			calculate_iir_coefficients();
-
-			zeros = 0.;
-			filter_state_z = xn;
-			filter_state_p = xn * zeros.sum() / (1. - poles.sum());
-		}
-
-
-	bool	anticipate;
-	valarray<T>
-		filter_state_p,
-		filter_state_z,
-		poles,
-		zeros;
-	T	gain,
-		back_polate;
+        CFilterIIR<T> (size_t samplerate_,
+                       TFilterDirection direction_,
+                       T gain_, T back_polate_)
+              : CFilter_base<T> (samplerate_, direction_),
+                anticipate (true),
+                gain (gain_),
+                back_polate (back_polate_)
+                {
+                        calculate_iir_coefficients();
+                }
+        virtual void reset()
+                {
+                        CFilter_base<T>::reset();
+
+                        calculate_iir_coefficients();
+
+                        filter_state_z = 0.;
+                        filter_state_p = 0.;
+                }
+
+        virtual void reset( T xn)
+                {
+                        calculate_iir_coefficients();
+
+                        zeros = 0.;
+                        filter_state_z = xn;
+                        filter_state_p = xn * zeros.sum() / (1. - poles.sum());
+                }
+
+
+        bool        anticipate;
+        valarray<T>
+                filter_state_p,
+                filter_state_z,
+                poles,
+                zeros;
+        T        gain,
+                back_polate;
 
     public:
-	void calculate_iir_coefficients()
-		{}
-	virtual valarray<T>
-	apply( const valarray<T>& in, bool);
+        void calculate_iir_coefficients()
+                {}
+        virtual valarray<T>
+        apply( const valarray<T>& in, bool);
 };
 
 
 template <typename T>
 class CFilterSE
   : public CFilterIIR<T> {
-	DELETE_DEFAULT_METHODS (CFilterSE<T>);
+        DELETE_DEFAULT_METHODS (CFilterSE<T>);
 
     public:
-	CFilterSE<T> (size_t samplerate_, TFilterDirection direction_,
-		      T gain_, T back_polate_,
-		      T f0_, T fc_, T bandwidth_)
-	      : CFilterIIR<T> (samplerate_, direction_, gain_, back_polate_),
-		f0 (f0_),
-		fc (fc_),
-		bandwidth (bandwidth_)
-		{
-			CFilterIIR<T>::zeros.resize(3); CFilterIIR<T>::filter_state_z.resize(3);
-			CFilterIIR<T>::poles.resize(3); CFilterIIR<T>::filter_state_p.resize(4);    // NrPoles+1 !!!!!111адинадин
-			calculate_iir_coefficients();
-		}
-
-	void calculate_iir_coefficients()
-		{
-			CFilterIIR<T>::calculate_iir_coefficients();
-
-			T	ts = 1.0 / CFilterIIR<T>::samplerate,
-				fprewarp, r, s, t;
-
-			fprewarp = tan( f0 * M_PI * ts) / (M_PI * ts);
-			r = gsl_pow_2( 2. * M_PI * fprewarp * ts);
-			// From November 1992 prewarping applied because of Arends results !
-			// r:=sqr(2.0*pi*f0*Ts);                         No prewarping
-			s = 2. * M_PI * bandwidth * ts * 2.;
-			t = 4. + r + s;
-			CFilterIIR<T>::poles[0] = 1.;
-			CFilterIIR<T>::poles[1] = (8.0 - 2.0 * r) / t;
-			CFilterIIR<T>::poles[2] = (-4.0 + s - r) / t;
-
-			fprewarp = tan(fc * M_PI * ts) / (M_PI * ts);
-			r = 2.0 / (2. * M_PI * fprewarp);
-			s = CFilterIIR<T>::gain * 2. * M_PI * bandwidth * 2.;
-
-			CFilterIIR<T>::zeros[0] = s * (r + ts)   / t;
-			CFilterIIR<T>::zeros[1] = s * (-2.0 * r) / t;
-			CFilterIIR<T>::zeros[2] = s * (r - ts)   / t;
-		}
+        CFilterSE<T> (size_t samplerate_, TFilterDirection direction_,
+                      T gain_, T back_polate_,
+                      T f0_, T fc_, T bandwidth_)
+              : CFilterIIR<T> (samplerate_, direction_, gain_, back_polate_),
+                f0 (f0_),
+                fc (fc_),
+                bandwidth (bandwidth_)
+                {
+                        CFilterIIR<T>::zeros.resize(3); CFilterIIR<T>::filter_state_z.resize(3);
+                        CFilterIIR<T>::poles.resize(3); CFilterIIR<T>::filter_state_p.resize(4);    // NrPoles+1 !!!!!111адинадин
+                        calculate_iir_coefficients();
+                }
+
+        void calculate_iir_coefficients()
+                {
+                        CFilterIIR<T>::calculate_iir_coefficients();
+
+                        T        ts = 1.0 / CFilterIIR<T>::samplerate,
+                                fprewarp, r, s, t;
+
+                        fprewarp = tan( f0 * M_PI * ts) / (M_PI * ts);
+                        r = gsl_pow_2( 2. * M_PI * fprewarp * ts);
+                        // From November 1992 prewarping applied because of Arends results !
+                        // r:=sqr(2.0*pi*f0*Ts);                         No prewarping
+                        s = 2. * M_PI * bandwidth * ts * 2.;
+                        t = 4. + r + s;
+                        CFilterIIR<T>::poles[0] = 1.;
+                        CFilterIIR<T>::poles[1] = (8.0 - 2.0 * r) / t;
+                        CFilterIIR<T>::poles[2] = (-4.0 + s - r) / t;
+
+                        fprewarp = tan(fc * M_PI * ts) / (M_PI * ts);
+                        r = 2.0 / (2. * M_PI * fprewarp);
+                        s = CFilterIIR<T>::gain * 2. * M_PI * bandwidth * 2.;
+
+                        CFilterIIR<T>::zeros[0] = s * (r + ts)   / t;
+                        CFilterIIR<T>::zeros[1] = s * (-2.0 * r) / t;
+                        CFilterIIR<T>::zeros[2] = s * (r - ts)   / t;
+                }
 
     private:
-	T	f0,
-		fc,
-		bandwidth;
+        T        f0,
+                fc,
+                bandwidth;
 };
 
 template <typename T>
 class CFilterDUE
   : public CFilterIIR<T> {
-	DELETE_DEFAULT_METHODS (CFilterDUE<T>);
+        DELETE_DEFAULT_METHODS (CFilterDUE<T>);
 
     public:
-	CFilterDUE<T> (size_t samplerate_, TFilterDirection direction_,
-		       T gain_, T back_polate_,
-		       T minus_3db_frequency_)
-	      : CFilterIIR<T> (samplerate_, direction_, gain_, back_polate_),
-		minus_3db_frequency (minus_3db_frequency_)
-		{
-			CFilterIIR<T>::zeros.resize(3); CFilterIIR<T>::filter_state_z.resize(3);
-			CFilterIIR<T>::poles.resize(1); CFilterIIR<T>::filter_state_p.resize(2);    // NrPoles+1 !!!!!
-			calculate_iir_coefficients();
-		}
-
-	void calculate_iir_coefficients()
-		{
-			CFilterIIR<T>::calculate_iir_coefficients();
-
-			T	ts = 1. / CFilterIIR<T>::samplerate,
-				fprewarp = tan( M_PI * minus_3db_frequency * ts) / (M_PI * ts),
-				r = 1. / (2. * M_PI * fprewarp),
-				s = ts / 2.;
-
-			/// this is what m.roussen has in Library/Filters/DUEFilter.cs:
-			// FZeros[0] = Gain * (s + r);
-			// FZeros[1] = Gain * (s - r);
-			// FPoles[0] = 1.0;
-			/// note the last assignment is to FPoles -- which isn't used anyway at index 0
-			CFilterIIR<T>::zeros[0] = CFilterIIR<T>::gain * (s + r);
-			CFilterIIR<T>::zeros[1] = CFilterIIR<T>::gain * (s - r);
-			CFilterIIR<T>::zeros[2] = 1.;
-
-			// so I got zeros[2] assigned by transcription mistake (should be to poles[0]) -- and
-			// it worked!  *Except* that zeros, through this assignment, has now grown to 3, which
-			// causes an invalid read in apply(), and went miraculously undetected until noticed
-			// (thank valgrind) at 0.9_rc stage
-			CFilterIIR<T>::poles[0] = 1.;
-			// Still, FPoles[0] = 1.0 is here for whatever it is intended to do
-
-			// May your life be forever geweldig, mate!
-		}
+        CFilterDUE<T> (size_t samplerate_, TFilterDirection direction_,
+                       T gain_, T back_polate_,
+                       T minus_3db_frequency_)
+              : CFilterIIR<T> (samplerate_, direction_, gain_, back_polate_),
+                minus_3db_frequency (minus_3db_frequency_)
+                {
+                        CFilterIIR<T>::zeros.resize(3); CFilterIIR<T>::filter_state_z.resize(3);
+                        CFilterIIR<T>::poles.resize(1); CFilterIIR<T>::filter_state_p.resize(2);    // NrPoles+1 !!!!!
+                        calculate_iir_coefficients();
+                }
+
+        void calculate_iir_coefficients()
+                {
+                        CFilterIIR<T>::calculate_iir_coefficients();
+
+                        T        ts = 1. / CFilterIIR<T>::samplerate,
+                                fprewarp = tan( M_PI * minus_3db_frequency * ts) / (M_PI * ts),
+                                r = 1. / (2. * M_PI * fprewarp),
+                                s = ts / 2.;
+
+                        /// this is what m.roussen has in Library/Filters/DUEFilter.cs:
+                        // FZeros[0] = Gain * (s + r);
+                        // FZeros[1] = Gain * (s - r);
+                        // FPoles[0] = 1.0;
+                        /// note the last assignment is to FPoles -- which isn't used anyway at index 0
+                        CFilterIIR<T>::zeros[0] = CFilterIIR<T>::gain * (s + r);
+                        CFilterIIR<T>::zeros[1] = CFilterIIR<T>::gain * (s - r);
+                        CFilterIIR<T>::zeros[2] = 1.;
+
+                        // so I got zeros[2] assigned by transcription mistake (should be to poles[0]) -- and
+                        // it worked!  *Except* that zeros, through this assignment, has now grown to 3, which
+                        // causes an invalid read in apply(), and went miraculously undetected until noticed
+                        // (thank valgrind) at 0.9_rc stage
+                        CFilterIIR<T>::poles[0] = 1.;
+                        // Still, FPoles[0] = 1.0 is here for whatever it is intended to do
+
+                        // May your life be forever geweldig, mate!
+                }
 
     private:
-	T	minus_3db_frequency;
+        T        minus_3db_frequency;
 };
 
 
diff --git a/upstream/src/libsigproc/sigproc.cc b/upstream/src/libsigproc/sigproc.cc
index 5ad9e8a..6ad39ce 100644
--- a/upstream/src/libsigproc/sigproc.cc
+++ b/upstream/src/libsigproc/sigproc.cc
@@ -30,45 +30,45 @@ template double sigproc::phase_diff( const SSignalRef<TFloat>&, const SSignalRef
 valarray<float>
 sigproc::
 resample_f( const valarray<float>& signal,
-	    size_t start, size_t end,
-	    size_t to_size,
-	    int alg)
+            size_t start, size_t end,
+            size_t to_size,
+            int alg)
 {
-	if ( unlikely (end <= start) || (end > signal.size()) )
-		throw runtime_error ("bad args for resample");
+        if ( unlikely (end <= start) || (end > signal.size()) )
+                throw runtime_error ("bad args for resample");
 
-	valarray<float>	resampled (to_size);
-	SRC_DATA S;
-	S.data_in       = const_cast<float*>(&signal[start]);
-	S.input_frames  = end - start;
-	S.output_frames = to_size;
-	S.data_out      = &resampled[0];
-	S.src_ratio     = (double)S.output_frames / S.input_frames;
+        valarray<float>        resampled (to_size);
+        SRC_DATA S;
+        S.data_in       = const_cast<float*>(&signal[start]);
+        S.input_frames  = end - start;
+        S.output_frames = to_size;
+        S.data_out      = &resampled[0];
+        S.src_ratio     = (double)S.output_frames / S.input_frames;
 
-	src_simple( &S, alg, 1);
+        src_simple( &S, alg, 1);
 
-	return resampled;
+        return resampled;
 }
 
 valarray<double>
 sigproc::
 resample( const valarray<double>& signal,
-	  size_t start, size_t end,
-	  size_t to_size,
-	  int alg)
+          size_t start, size_t end,
+          size_t to_size,
+          int alg)
 {
-	valarray<float> tmp1 (end - start);
-	for ( size_t i = start; i < end; ++i )
-		tmp1[i] = signal[i];
+        valarray<float> tmp1 (end - start);
+        for ( size_t i = start; i < end; ++i )
+                tmp1[i] = signal[i];
 
-	valarray<float> tmp2
-		= sigproc::resample_f( tmp1, 0, end-start, to_size, alg);
+        valarray<float> tmp2
+                = sigproc::resample_f( tmp1, 0, end-start, to_size, alg);
 
-	valarray<double> ret (end-start);
-	for ( size_t i = 0; i < end-start; ++i )
-		ret[i] = tmp2[i];
+        valarray<double> ret (end-start);
+        for ( size_t i = 0; i < end-start; ++i )
+                ret[i] = tmp2[i];
 
-	return ret;
+        return ret;
 }
 
 
diff --git a/upstream/src/libsigproc/sigproc.hh b/upstream/src/libsigproc/sigproc.hh
index b4cb5f4..45ef906 100644
--- a/upstream/src/libsigproc/sigproc.hh
+++ b/upstream/src/libsigproc/sigproc.hh
@@ -51,22 +51,22 @@ derivative( const valarray<T>&);
 
 valarray<float>
 resample_f( const valarray<float>&,
-	    size_t, size_t, size_t, int);
+            size_t, size_t, size_t, int);
 
 inline valarray<float>
 resample( const valarray<float>& signal,
-	  size_t start, size_t end,
-	  size_t to_size,
-	  int alg = SRC_SINC_FASTEST)
+          size_t start, size_t end,
+          size_t to_size,
+          int alg = SRC_SINC_FASTEST)
 {
-	return resample_f( signal, start, end, to_size, alg);
+        return resample_f( signal, start, end, to_size, alg);
 }
 
 valarray<double>
 resample( const valarray<double>& signal,
-	  size_t start, size_t end,
-	  size_t to_size,
-	  int alg);
+          size_t start, size_t end,
+          size_t to_size,
+          int alg);
 
 
 
@@ -76,7 +76,7 @@ resample( const valarray<double>& signal,
 template <typename T, class Container>
 valarray<T>
 interpolate( const vector<unsigned long>& xi,
-	     unsigned samplerate, const Container& y, double dt);
+             unsigned samplerate, const Container& y, double dt);
 
 
 
@@ -85,9 +85,9 @@ interpolate( const vector<unsigned long>& xi,
 
 template <typename T>
 struct SSignalRef {
-	const valarray<T>&
-		signal;
-	size_t	samplerate;
+        const valarray<T>&
+                signal;
+        size_t        samplerate;
 };
 
 
@@ -97,27 +97,27 @@ struct SSignalRef {
 template <typename T>
 size_t
 envelope( const SSignalRef<T>& in,
-	  double dh,  // tightness
-	  double dt,
-	  valarray<T>* env_lp = nullptr,  // return interpolated
-	  valarray<T>* env_up = nullptr,  // return vector of points
-	  vector<unsigned long> *mini_p = nullptr,
-	  vector<unsigned long> *maxi_p = nullptr);
+          double dh,  // tightness
+          double dt,
+          valarray<T>* env_lp = nullptr,  // return interpolated
+          valarray<T>* env_up = nullptr,  // return vector of points
+          vector<unsigned long> *mini_p = nullptr,
+          vector<unsigned long> *maxi_p = nullptr);
 
 template <typename T>
 valarray<T>
 raw_signal_profile( const SSignalRef<T>& sigref,
-		    double env_dh, double env_dt)
+                    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;
+        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;
 }
 
 
@@ -136,154 +136,154 @@ dzcdf( const SSignalRef<T>& in,
 template <typename T>
 struct SCachedEnvelope
   : public SSignalRef<T> {
-	SCachedEnvelope (const SSignalRef<T>& signal_)
-	      : SSignalRef<T> (signal_)
-		{}
-	SCachedEnvelope (const SCachedEnvelope&) = delete;
-
-	const pair<valarray<T>&, valarray<T>&>
-	operator()( double scope_)
-		{
-			if ( lower.size() == 0 ||
-			     scope != scope_ ) {
-				envelope( (SSignalRef<T>)*this,
-					  scope = scope_,
-					  1./SSignalRef<T>::samplerate,
-					  &lower,
-					  &upper); // don't need anchor points, nor their count
-				mid.resize(lower.size());
-				mid = (upper + lower)/2;
-			}
-			return {lower, upper};
-		}
-	void drop()
-		{
-			upper.resize(0);
-			lower.resize(0);
-		}
-
-	T breadth( double scope_, size_t i)
-		{
-			operator()( scope_);
-			return upper[i] - lower[i];
-		}
-	valarray<T> breadth( double scope_)
-		{
-			operator()( scope_);
-			return upper - lower;
-		}
-
-	T centre( double scope_, size_t i)
-		{
-			operator()( scope_);
-			return mid[i];
-		}
-	valarray<T> centre( double scope_)
-		{
-			operator()( scope_);
-			return mid;
-		}
+        SCachedEnvelope (const SSignalRef<T>& signal_)
+              : SSignalRef<T> (signal_)
+                {}
+        SCachedEnvelope (const SCachedEnvelope&) = delete;
+
+        const pair<valarray<T>&, valarray<T>&>
+        operator()( double scope_)
+                {
+                        if ( lower.size() == 0 ||
+                             scope != scope_ ) {
+                                envelope( (SSignalRef<T>)*this,
+                                          scope = scope_,
+                                          1./SSignalRef<T>::samplerate,
+                                          &lower,
+                                          &upper); // don't need anchor points, nor their count
+                                mid.resize(lower.size());
+                                mid = (upper + lower)/2;
+                        }
+                        return {lower, upper};
+                }
+        void drop()
+                {
+                        upper.resize(0);
+                        lower.resize(0);
+                }
+
+        T breadth( double scope_, size_t i)
+                {
+                        operator()( scope_);
+                        return upper[i] - lower[i];
+                }
+        valarray<T> breadth( double scope_)
+                {
+                        operator()( scope_);
+                        return upper - lower;
+                }
+
+        T centre( double scope_, size_t i)
+                {
+                        operator()( scope_);
+                        return mid[i];
+                }
+        valarray<T> centre( double scope_)
+                {
+                        operator()( scope_);
+                        return mid;
+                }
 
     private:
-	double	scope;
-	valarray<T>
-		upper,
-		mid,
-		lower;
+        double        scope;
+        valarray<T>
+                upper,
+                mid,
+                lower;
 };
 
 template <typename T>
 struct SCachedDzcdf
   : public SSignalRef<T> {
-	SCachedDzcdf (const SSignalRef<T>& signal_)
-	      : SSignalRef<T> (signal_)
-		{}
-	SCachedDzcdf (const SCachedDzcdf&) = delete;
-	// other ctors deleted implicitly due to a member of reference type
-
-	const valarray<T>&
-	operator()( double step_, double sigma_, unsigned smooth_)
-		{
-			if ( data.size() == 0 ||
-			     step != step_ || sigma != sigma_ || smooth != smooth_ )
-				data = dzcdf<T>(
-					(SSignalRef<T>)*this,
-					step = step_, sigma = sigma_, smooth = smooth_);
-			return data;
-		}
-	void drop()
-		{
-			data.resize(0);
-		}
+        SCachedDzcdf (const SSignalRef<T>& signal_)
+              : SSignalRef<T> (signal_)
+                {}
+        SCachedDzcdf (const SCachedDzcdf&) = delete;
+        // other ctors deleted implicitly due to a member of reference type
+
+        const valarray<T>&
+        operator()( double step_, double sigma_, unsigned smooth_)
+                {
+                        if ( data.size() == 0 ||
+                             step != step_ || sigma != sigma_ || smooth != smooth_ )
+                                data = dzcdf<T>(
+                                        (SSignalRef<T>)*this,
+                                        step = step_, sigma = sigma_, smooth = smooth_);
+                        return data;
+                }
+        void drop()
+                {
+                        data.resize(0);
+                }
     private:
-	double	step,
-		sigma;
-	unsigned
-		smooth;
-	valarray<T>
-		data;
+        double        step,
+                sigma;
+        unsigned
+                smooth;
+        valarray<T>
+                data;
 };
 
 template <typename T>
 struct SCachedLowPassCourse
   : public SSignalRef<T> {
-	SCachedLowPassCourse (const SSignalRef<T>& signal_)
-	      : SSignalRef<T> (signal_)
-		{}
-	SCachedLowPassCourse (const SCachedLowPassCourse&) = delete;
-
-	const valarray<T>&
-	operator()( double fcutoff_, unsigned order_)
-		{
-			if ( data.size() == 0 ||
-			     fcutoff != fcutoff_ || order != order_ )
-				data = exstrom::low_pass( SSignalRef<T>::signal, SSignalRef<T>::samplerate,
-							  fcutoff = fcutoff_, order = order_,
-							  true);
-			return data;
-		}
-	void drop()
-		{
-			data.resize(0);
-		}
+        SCachedLowPassCourse (const SSignalRef<T>& signal_)
+              : SSignalRef<T> (signal_)
+                {}
+        SCachedLowPassCourse (const SCachedLowPassCourse&) = delete;
+
+        const valarray<T>&
+        operator()( double fcutoff_, unsigned order_)
+                {
+                        if ( data.size() == 0 ||
+                             fcutoff != fcutoff_ || order != order_ )
+                                data = exstrom::low_pass( SSignalRef<T>::signal, SSignalRef<T>::samplerate,
+                                                          fcutoff = fcutoff_, order = order_,
+                                                          true);
+                        return data;
+                }
+        void drop()
+                {
+                        data.resize(0);
+                }
 
     private:
-	double	fcutoff;
-	unsigned
-		order;
-	valarray<TFloat>
-		data;
+        double        fcutoff;
+        unsigned
+                order;
+        valarray<TFloat>
+                data;
 };
 
 template <typename T>
 struct SCachedBandPassCourse
   : public SSignalRef<T> {
-	SCachedBandPassCourse (const SSignalRef<T>& signal_)
-	      : SSignalRef<T> (signal_)
-		{}
-	SCachedBandPassCourse (const SCachedBandPassCourse&) = delete;
-
-	const valarray<T>&
-	operator()( double ffrom_, double fupto_, unsigned order_)
-		{
-			if ( data.size() == 0 ||
-			     ffrom != ffrom_ || fupto != fupto_ || order != order_ )
-				data = exstrom::band_pass( SSignalRef<T>::signal, SSignalRef<T>::samplerate,
-							   ffrom = ffrom_, fupto = fupto_, order = order_,
-							   true);
-			return data;
-		}
-	void drop()
-		{
-			data.resize(0);
-		}
+        SCachedBandPassCourse (const SSignalRef<T>& signal_)
+              : SSignalRef<T> (signal_)
+                {}
+        SCachedBandPassCourse (const SCachedBandPassCourse&) = delete;
+
+        const valarray<T>&
+        operator()( double ffrom_, double fupto_, unsigned order_)
+                {
+                        if ( data.size() == 0 ||
+                             ffrom != ffrom_ || fupto != fupto_ || order != order_ )
+                                data = exstrom::band_pass( SSignalRef<T>::signal, SSignalRef<T>::samplerate,
+                                                           ffrom = ffrom_, fupto = fupto_, order = order_,
+                                                           true);
+                        return data;
+                }
+        void drop()
+                {
+                        data.resize(0);
+                }
 
     private:
-	double	ffrom, fupto;
-	unsigned
-		order;
-	valarray<TFloat>
-		data;
+        double        ffrom, fupto;
+        unsigned
+                order;
+        valarray<TFloat>
+                data;
 };
 
 
@@ -299,11 +299,11 @@ sig_diff( const valarray<T>& a, const valarray<T>& b, int d);
 template <typename T>
 double
 phase_diff( const SSignalRef<T>& sig1,
-	    const SSignalRef<T>& sig2,
-	    size_t sa, size_t sz,
-	    double fa, double fz,
-	    unsigned order,
-	    size_t scope);
+            const SSignalRef<T>& sig2,
+            size_t sa, size_t sz,
+            double fa, double fz,
+            unsigned order,
+            size_t scope);
 
 
 
diff --git a/upstream/src/libsigproc/winfun.cc b/upstream/src/libsigproc/winfun.cc
index 0d1cbf9..9d36407 100644
--- a/upstream/src/libsigproc/winfun.cc
+++ b/upstream/src/libsigproc/winfun.cc
@@ -20,10 +20,10 @@ using namespace std;
 
 // must match those defined in glade
 const char*
-	sigproc::welch_window_type_names[sigproc::TWinType::TWinType_total] = {
-	"Bartlett", "Blackman", "Blackman-Harris",
-	"Hamming",  "Hanning",  "Parzen",
-	"Square",   "Welch"
+        sigproc::welch_window_type_names[sigproc::TWinType::TWinType_total] = {
+        "Bartlett", "Blackman", "Blackman-Harris",
+        "Hamming",  "Hanning",  "Parzen",
+        "Square",   "Welch"
 };
 
 
@@ -38,10 +38,10 @@ TFloat
 __attribute__ ((const))
 win_bartlett( size_t j, size_t n)
 {
-	TFloat a = 2.0/(n-1), w;
-	if ( (w = j*a) > 1. )
-		w = 2. - w;
-	return w;
+        TFloat a = 2.0/(n-1), w;
+        if ( (w = j*a) > 1. )
+                w = 2. - w;
+        return w;
 }
 
 /* See Oppenheim & Schafer, Digital Signal Processing, p. 242 (1st ed.) */
@@ -49,9 +49,9 @@ TFloat
 __attribute__ ((const))
 win_blackman( size_t j, size_t n)
 {
-	TFloat a = TWOPI/(n-1), w;
-	w = 0.42 - .5 * cos(a * j) + .08 * cos(2 * a * j);
-	return w;
+        TFloat a = TWOPI/(n-1), w;
+        w = 0.42 - .5 * cos(a * j) + .08 * cos(2 * a * j);
+        return w;
 }
 
 /* See Harris, F.J., "On the use of windows for harmonic analysis with the
@@ -60,9 +60,9 @@ TFloat
 __attribute__ ((const))
 win_blackman_harris( size_t j, size_t n)
 {
-	TFloat a = TWOPI/(n-1), w;
-	w = 0.35875 - 0.48829 * cos(a * j) + 0.14128 * cos(2 * a * j) - 0.01168 * cos(3 * a * j);
-	return w;
+        TFloat a = TWOPI/(n-1), w;
+        w = 0.35875 - 0.48829 * cos(a * j) + 0.14128 * cos(2 * a * j) - 0.01168 * cos(3 * a * j);
+        return w;
 }
 
 /* See Oppenheim & Schafer, Digital Signal Processing, p. 242 (1st ed.) */
@@ -70,9 +70,9 @@ TFloat
 __attribute__ ((const))
 win_hamming( size_t j, size_t n)
 {
-	TFloat a = TWOPI/(n-1), w;
-	w = 0.54 - 0.46*cos(a*j);
-	return w;
+        TFloat a = TWOPI/(n-1), w;
+        w = 0.54 - 0.46*cos(a*j);
+        return w;
 }
 
 /* See Oppenheim & Schafer, Digital Signal Processing, p. 242 (1st ed.)
@@ -81,9 +81,9 @@ TFloat
 __attribute__ ((const))
 win_hanning( size_t j, size_t n)
 {
-	TFloat a = TWOPI/(n-1), w;
-	w = 0.5 - 0.5*cos(a*j);
-	return w;
+        TFloat a = TWOPI/(n-1), w;
+        w = 0.5 - 0.5*cos(a*j);
+        return w;
 }
 
 /* See Press, Flannery, Teukolsky, & Vetterling, Numerical Recipes in C,
@@ -92,12 +92,12 @@ TFloat
 __attribute__ ((const))
 win_parzen( size_t j, size_t n)
 {
-	TFloat a = (n-1)/2.0, w;
-	if ( (w = (j-a)/(a+1)) > 0.0 )
-		w = 1 - w;
-	else
-		w = 1 + w;
-	return w;
+        TFloat a = (n-1)/2.0, w;
+        if ( (w = (j-a)/(a+1)) > 0.0 )
+                w = 1 - w;
+        else
+                w = 1 + w;
+        return w;
 }
 
 /* See any of the above references. */
@@ -105,7 +105,7 @@ TFloat
 __attribute__ ((const))
 win_square( size_t, size_t)
 {
-	return 1.0;
+        return 1.0;
 }
 
 /* See Press, Flannery, Teukolsky, & Vetterling, Numerical Recipes in C,
@@ -114,23 +114,23 @@ TFloat
 __attribute__ ((const))
 win_welch( size_t j, size_t n)
 {
-	TFloat a = (n-1)/2.0, w;
-	w = (j-a)/(a+1);
-	w = 1 - w*w;
-	return w;
+        TFloat a = (n-1)/2.0, w;
+        w = (j-a)/(a+1);
+        w = 1 - w*w;
+        return w;
 }
 
 } // namespace
 
 TFloat (*sigproc::winf[])(size_t, size_t) = {
-	win_bartlett,
-	win_blackman,
-	win_blackman_harris,
-	win_hamming,
-	win_hanning,
-	win_parzen,
-	win_square,
-	win_welch
+        win_bartlett,
+        win_blackman,
+        win_blackman_harris,
+        win_hamming,
+        win_hanning,
+        win_parzen,
+        win_square,
+        win_welch
 };
 
 
diff --git a/upstream/src/libsigproc/winfun.hh b/upstream/src/libsigproc/winfun.hh
index 7c2a2a5..8d938de 100644
--- a/upstream/src/libsigproc/winfun.hh
+++ b/upstream/src/libsigproc/winfun.hh
@@ -23,19 +23,19 @@ using namespace std;
 namespace sigproc {
 
 enum TWinType {
-	bartlett,
-	blackman,
-	blackman_harris,
-	hamming,
-	hanning,
-	parzen,
-	square,
-	welch,
-	TWinType_total
+        bartlett,
+        blackman,
+        blackman_harris,
+        hamming,
+        hanning,
+        parzen,
+        square,
+        welch,
+        TWinType_total
 };
 
 extern const char*
-	welch_window_type_names[TWinType::TWinType_total];
+        welch_window_type_names[TWinType::TWinType_total];
 
 extern TFloat (*winf[])(size_t, size_t);
 
diff --git a/upstream/src/tools/agh-profile-gen.cc b/upstream/src/tools/agh-profile-gen.cc
index 944735c..1f83108 100644
--- a/upstream/src/tools/agh-profile-gen.cc
+++ b/upstream/src/tools/agh-profile-gen.cc
@@ -9,7 +9,6 @@
  *         License:  GPL
  */
 
-
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
@@ -38,33 +37,33 @@ using namespace std;
 #define ARGV0 "agh-profile-gen"
 
 const char
-	*argp_program_version = ARGV0 " " VERSION,
-	*argp_program_bug_address = "<" PACKAGE_BUGREPORT ">";
+        *argp_program_version = ARGV0 " " VERSION,
+        *argp_program_bug_address = "<" PACKAGE_BUGREPORT ">";
 
 static char doc[] =
        ARGV0 " -- sleep profile (PSD, MC, SWU) generator";
 
 enum TOptChar : char {
-	o_profile    = 't',
-	o_page       = 'p',
-	o_step       = 'i',
-	o_psd_params = 'P',
-	o_mc_params  = 'M',
-	o_swu_params = 'S',
-	o_channel    = 'h',
+        o_profile    = 't',
+        o_page       = 'p',
+        o_step       = 'i',
+        o_psd_params = 'P',
+        o_mc_params  = 'M',
+        o_swu_params = 'S',
+        o_channel    = 'h',
 };
 
 #pragma GCC diagnostic ignored "-Wmissing-field-initializers"
 #pragma GCC diagnostic push
 static struct argp_option options[] = {
-       {"channel",		o_channel,    "CHANNEL",		0, "use this channel (0-based)"			},
-       {"profile",		o_profile,    "pms",			0, "profile(s) to generate (p=PSD, m=MC, s=SWU)"},
-       {"page",			o_page,       "PAGESIZE",		0, "page size (sec)"				},
-       {"step",			o_step,       "STEP",			0, "step (sec)"					},
-       {"psd-params",		o_psd_params, "BINSIZE",		0, "PSD: binsize (sec, one of .1, .25, .5)"	},
-       {"mc-params",		o_mc_params,  "SCOPE:F0FC:BANDWIDTH:IIR_BACKPOLATE:GAIN:SMOOTH",
-									0, "MC parameters"				},
-       {"swu-params",		o_swu_params, "MIN_UPSWING_LEN",	0, "SWU parameters"				},
+       {"channel",      o_channel,    "CHANNEL",          0, "use this channel (0-based)"                    },
+       {"profile",      o_profile,    "pms",              0, "profile(s) to generate (p=PSD, m=MC, s=SWU)"   },
+       {"page",         o_page,       "PAGESIZE",         0, "page size (sec)"                               },
+       {"step",         o_step,       "STEP",             0, "step (sec)"                                    },
+       {"psd-params",   o_psd_params, "BINSIZE",          0, "PSD: binsize (sec, one of .1, .25, .5)"        },
+       {"mc-params",    o_mc_params,  "SCOPE:F0FC:BANDWIDTH:IIR_BACKPOLATE:GAIN:SMOOTH",
+                                                          0, "MC parameters"                                 },
+       {"swu-params",   o_swu_params, "MIN_UPSWING_LEN",  0, "SWU parameters"                                },
        { 0 }
      };
 #pragma GCC diagnostic pop
@@ -74,92 +73,92 @@ static char args_doc[] = "FILE";
 static error_t parse_opt( int, char*, struct argp_state*);
 
 static struct argp argp = {
-	options,
-	parse_opt,
-	args_doc,
-	doc
+        options,
+        parse_opt,
+        args_doc,
+        doc
 };
 
 
 struct SArguments {
-	string	file;
-	int	h;
+        string        file;
+        int        h;
 
-	double	pagesize, // will propagate to any *_pp
-		step;
+        double        pagesize, // will propagate to any *_pp
+                step;
 
-	set<metrics::TType>
-		types;
+        set<metrics::TType>
+                types;
 
-	metrics::psd::SPPack psd_pp;
-	metrics::mc ::SPPack mc_pp;
-	metrics::swu::SPPack swu_pp;
+        metrics::psd::SPPack psd_pp;
+        metrics::mc ::SPPack mc_pp;
+        metrics::swu::SPPack swu_pp;
 
-	SArguments()
-	      : h (-1),
-		pagesize (NAN),
-		step (NAN)
-		{}
+        SArguments()
+              : h (-1),
+                pagesize (NAN),
+                step (NAN)
+                {}
 };
 
 
 static error_t
 parse_opt( int key, char *arg, struct argp_state *state)
 {
-	auto& Q = *(SArguments*)state->input;
-
-	switch ( key ) {
-	case TOptChar::o_profile:
-		if ( strchr( arg, 'p') )
-			Q.types.insert(metrics::TType::psd);
-		if ( strchr( arg, 'm') )
-			Q.types.insert(metrics::TType::mc);
-		if ( strchr( arg, 's') )
-			Q.types.insert(metrics::TType::swu);
-		break;
-
-	case TOptChar::o_page:
-		Q.pagesize = atof( arg);
-		break;
-
-	case TOptChar::o_step:
-		Q.step = atof( arg);
-		break;
-
-	case TOptChar::o_channel:
-		Q.h = atoi( arg);
-		break;
-
-	case TOptChar::o_psd_params:
-		sscanf( arg, "%lg",
-			&Q.psd_pp.binsize);
-		break;
-
-	case TOptChar::o_mc_params:
-		sscanf( arg, "%lg:%lg:%lg:%lg:%lg",
-			&Q.mc_pp.scope, &Q.mc_pp.f0fc, &Q.mc_pp.bandwidth, &Q.mc_pp.iir_backpolate, &Q.mc_pp.mc_gain);
-		break;
-
-	case TOptChar::o_swu_params:
-		sscanf( arg, "%lg",
-			&Q.swu_pp.min_upswing_duration);
-		break;
-
-	case ARGP_KEY_ARG:
-		if ( Q.file.empty() )
-			Q.file = arg;
-		else
-			throw invalid_argument ("Can only process one file/channel at a time");
-		break;
-
-	case ARGP_KEY_END:
-		if ( state->arg_num < 1 )
-			argp_usage( state);
-		break;
-	default:
-		return (error_t)ARGP_ERR_UNKNOWN;
-	}
-	return (error_t)0;
+        auto& Q = *(SArguments*)state->input;
+
+        switch ( key ) {
+        case TOptChar::o_profile:
+                if ( strchr( arg, 'p') )
+                        Q.types.insert(metrics::TType::psd);
+                if ( strchr( arg, 'm') )
+                        Q.types.insert(metrics::TType::mc);
+                if ( strchr( arg, 's') )
+                        Q.types.insert(metrics::TType::swu);
+                break;
+
+        case TOptChar::o_page:
+                Q.pagesize = atof( arg);
+                break;
+
+        case TOptChar::o_step:
+                Q.step = atof( arg);
+                break;
+
+        case TOptChar::o_channel:
+                Q.h = atoi( arg);
+                break;
+
+        case TOptChar::o_psd_params:
+                sscanf( arg, "%lg",
+                        &Q.psd_pp.binsize);
+                break;
+
+        case TOptChar::o_mc_params:
+                sscanf( arg, "%lg:%lg:%lg:%lg:%lg",
+                        &Q.mc_pp.scope, &Q.mc_pp.f0fc, &Q.mc_pp.bandwidth, &Q.mc_pp.iir_backpolate, &Q.mc_pp.mc_gain);
+                break;
+
+        case TOptChar::o_swu_params:
+                sscanf( arg, "%lg",
+                        &Q.swu_pp.min_upswing_duration);
+                break;
+
+        case ARGP_KEY_ARG:
+                if ( Q.file.empty() )
+                        Q.file = arg;
+                else
+                        throw invalid_argument ("Can only process one file/channel at a time");
+                break;
+
+        case ARGP_KEY_END:
+                if ( state->arg_num < 1 )
+                        argp_usage( state);
+                break;
+        default:
+                return (error_t)ARGP_ERR_UNKNOWN;
+        }
+        return (error_t)0;
 }
 
 
@@ -168,61 +167,61 @@ parse_opt( int key, char *arg, struct argp_state *state)
 int
 main( int argc, char **argv)
 {
-	SArguments A;
-	try {
-		argp_parse( &argp, argc, argv, 0, NULL, (void*)&A);
-
-		if ( A.h == -1 )
-			throw invalid_argument ("Invalid or missing channel");
-
-		if ( A.types.empty() )
-			throw invalid_argument ("Which profiles do you want?");
-
-		if ( !isfinite(A.pagesize) )
-			throw invalid_argument ("Missing or invalid pagesize");
-		if ( !isfinite(A.step) )
-			throw invalid_argument ("Missing or invalid step");
-
-		bool	do_psd = A.types.find( metrics::TType::psd) != A.types.end(),
-			do_mc  = A.types.find( metrics::TType:: mc) != A.types.end(),
-			do_swu = A.types.find( metrics::TType::swu) != A.types.end();
-
-		if ( do_psd )
-			A.psd_pp.pagesize = A.pagesize, A.psd_pp.step = A.step, A.psd_pp.check();
-		if ( do_mc )
-			A.mc_pp.pagesize  = A.pagesize, A.mc_pp.step  = A.step, A.mc_pp.check();
-		if ( do_swu )
-			A.swu_pp.pagesize = A.pagesize, A.swu_pp.step = A.step, A.swu_pp.check();
-
-		if ( A.file.empty() )
-			throw invalid_argument ("Missing file name");
-
-		sigfile::CTypedSource F (A.file, A.pagesize, 0|sigfile::CSource::no_ancillary_files);
-		if ( do_psd ) {
-			metrics::psd::CProfile P (F, A.h, A.psd_pp);
-			if ( P.go_compute() )
-				throw runtime_error ("Failed to compute PSD");
-			P.export_tsv( A.file + ".psd");
-		}
-		if ( do_mc ) {
-			metrics::mc::CProfile P (F, A.h, A.mc_pp);
-			if ( P.go_compute() )
-				throw runtime_error ("Failed to compute MC");
-			P.export_tsv( A.file + ".mc");
-		}
-		if ( do_swu ) {
-			metrics::swu::CProfile P (F, A.h, A.swu_pp);
-			if ( P.go_compute() )
-				throw runtime_error ("Failed to compute SWU");
-			P.export_tsv( A.file + ".swu");
-		}
-
-		return 0;
-
-	} catch ( exception& ex ) {
-		fprintf( stderr, "Error: %s\n", ex.what());
-		return 1;
-	}
+        SArguments A;
+        try {
+                argp_parse( &argp, argc, argv, 0, NULL, (void*)&A);
+
+                if ( A.h == -1 )
+                        throw invalid_argument ("Invalid or missing channel");
+
+                if ( A.types.empty() )
+                        throw invalid_argument ("Which profiles do you want?");
+
+                if ( !isfinite(A.pagesize) )
+                        throw invalid_argument ("Missing or invalid pagesize");
+                if ( !isfinite(A.step) )
+                        throw invalid_argument ("Missing or invalid step");
+
+                bool        do_psd = A.types.find( metrics::TType::psd) != A.types.end(),
+                        do_mc  = A.types.find( metrics::TType:: mc) != A.types.end(),
+                        do_swu = A.types.find( metrics::TType::swu) != A.types.end();
+
+                if ( do_psd )
+                        A.psd_pp.pagesize = A.pagesize, A.psd_pp.step = A.step, A.psd_pp.check();
+                if ( do_mc )
+                        A.mc_pp.pagesize  = A.pagesize, A.mc_pp.step  = A.step, A.mc_pp.check();
+                if ( do_swu )
+                        A.swu_pp.pagesize = A.pagesize, A.swu_pp.step = A.step, A.swu_pp.check();
+
+                if ( A.file.empty() )
+                        throw invalid_argument ("Missing file name");
+
+                sigfile::CTypedSource F (A.file, A.pagesize, 0|sigfile::CSource::no_ancillary_files);
+                if ( do_psd ) {
+                        metrics::psd::CProfile P (F, A.h, A.psd_pp);
+                        if ( P.go_compute() )
+                                throw runtime_error ("Failed to compute PSD");
+                        P.export_tsv( A.file + ".psd");
+                }
+                if ( do_mc ) {
+                        metrics::mc::CProfile P (F, A.h, A.mc_pp);
+                        if ( P.go_compute() )
+                                throw runtime_error ("Failed to compute MC");
+                        P.export_tsv( A.file + ".mc");
+                }
+                if ( do_swu ) {
+                        metrics::swu::CProfile P (F, A.h, A.swu_pp);
+                        if ( P.go_compute() )
+                                throw runtime_error ("Failed to compute SWU");
+                        P.export_tsv( A.file + ".swu");
+                }
+
+                return 0;
+
+        } catch ( exception& ex ) {
+                fprintf( stderr, "Error: %s\n", ex.what());
+                return 1;
+        }
 }
 
 
diff --git a/upstream/src/tools/edfcat.cc b/upstream/src/tools/edfcat.cc
index 0228c30..b85a29c 100644
--- a/upstream/src/tools/edfcat.cc
+++ b/upstream/src/tools/edfcat.cc
@@ -36,40 +36,40 @@ using namespace std;
 
 struct SOperation {
 
-	enum TKind {
-		Noop,
-		Split, Cat, // length-wise
-		Convert,
-		Prune, Merge,
-		Generate
-	};
-	TKind	operation;
-
-	struct SObject : public string {
-		list<size_t>
-			channels;  // if any
-		list<double>
-			timepoints_g;
-		list<int>
-			timepoints_d;
-		size_t	samplerate,
-			record_size;
-		void figure_timepoints( const list<string>&) throw (invalid_argument);
-		void figure_channels( const list<string>&) throw (invalid_argument);
-
-		SObject (const char* rv)
-		      : string (rv)
-			{}
-	};
-	list<SObject>
-		operands;
-	int parse_op( int argc, const char* argv[]) throw (invalid_argument);
-	int exec();
-
-	SOperation( int argc, const char* argv[]) throw (invalid_argument)
-		{
-			parse_op( argc, argv);
-		}
+        enum TKind {
+                Noop,
+                Split, Cat, // length-wise
+                Convert,
+                Prune, Merge,
+                Generate
+        };
+        TKind        operation;
+
+        struct SObject : public string {
+                list<size_t>
+                        channels;  // if any
+                list<double>
+                        timepoints_g;
+                list<int>
+                        timepoints_d;
+                size_t        samplerate,
+                        record_size;
+                void figure_timepoints( const list<string>&) throw (invalid_argument);
+                void figure_channels( const list<string>&) throw (invalid_argument);
+
+                SObject (const char* rv)
+                      : string (rv)
+                        {}
+        };
+        list<SObject>
+                operands;
+        int parse_op( int argc, const char* argv[]) throw (invalid_argument);
+        int exec();
+
+        SOperation( int argc, const char* argv[]) throw (invalid_argument)
+                {
+                        parse_op( argc, argv);
+                }
 };
 
 
@@ -78,58 +78,58 @@ int
 SOperation::
 parse_op( int argc, const char* argv[]) throw (invalid_argument)
 {
-	if ( argc < 2 ) {
-		operation = TKind::Noop;
-		return 0;
-	}
-
-	const char* p = argv[1];
-
-	if        ( strcmp( p, "split") == 0 ) {
-		operation = TKind::Split;
-		if ( argc != 4 )
-			throw invalid_argument ("Usage: split FILE POS1[,POS2,...]");
-		operands.emplace_back( argv[2]);
-		operands.back().figure_timepoints( agh::str::tokens_trimmed( argv[3], ","));
-
-	} else if ( strcmp( p, "cat")   == 0 ) {
-		operation = TKind::Split;
-		if ( argc < 5 )
-			throw invalid_argument ("Usage: cat FILE1 FILE2 [FILE3 ...] RESULT");
-		for ( int k = 2; k < argc; ++k )
-			operands.emplace_back( argv[k]);
-
-	} else if ( strcmp( p, "conv")  == 0 ) {
-		operation = TKind::Convert;
-		if ( argc != 5 )
-			throw invalid_argument ("Usage: conv FILE SAMPLERATE RECORD_SIZE");
-		operands.emplace_back( argv[2]);
-		char *tail;
-		operands.back().samplerate = strtoul( argv[3], &tail, 10);
-		if ( *tail )
-			throw invalid_argument ("Unparsable samplerate");
-		operands.back().record_size = strtoul( argv[4], &tail, 10);
-		if ( *tail )
-			throw invalid_argument ("Unparsable record_size");
-
-	} else if ( strcmp( p, "prune")  == 0 ) {
-		operation = TKind::Prune;
-		if ( argc != 4 )
-			throw invalid_argument ("Usage: prune FILE N1[N2,...]");
-		operands.emplace_back( argv[2]);
-		operands.back().figure_channels( agh::str::tokens_trimmed( argv[3], ","));
-
-	} else if ( strcmp( p, "merge") == 0 ) {
-		operation = TKind::Merge;
-		if ( argc < 4 )
-			throw invalid_argument ("Usage: merge FILE FILE1 [FILE2 ...]");
-		for ( int k = 2; k < argc; ++k )
-			operands.emplace_back( argv[k]);
-
-	} else
-		throw invalid_argument ("Unrecognised operation");
-
-	return 0;
+        if ( argc < 2 ) {
+                operation = TKind::Noop;
+                return 0;
+        }
+
+        const char* p = argv[1];
+
+        if        ( strcmp( p, "split") == 0 ) {
+                operation = TKind::Split;
+                if ( argc != 4 )
+                        throw invalid_argument ("Usage: split FILE POS1[,POS2,...]");
+                operands.emplace_back( argv[2]);
+                operands.back().figure_timepoints( agh::str::tokens_trimmed( argv[3], ","));
+
+        } else if ( strcmp( p, "cat")   == 0 ) {
+                operation = TKind::Split;
+                if ( argc < 5 )
+                        throw invalid_argument ("Usage: cat FILE1 FILE2 [FILE3 ...] RESULT");
+                for ( int k = 2; k < argc; ++k )
+                        operands.emplace_back( argv[k]);
+
+        } else if ( strcmp( p, "conv")  == 0 ) {
+                operation = TKind::Convert;
+                if ( argc != 5 )
+                        throw invalid_argument ("Usage: conv FILE SAMPLERATE RECORD_SIZE");
+                operands.emplace_back( argv[2]);
+                char *tail;
+                operands.back().samplerate = strtoul( argv[3], &tail, 10);
+                if ( *tail )
+                        throw invalid_argument ("Unparsable samplerate");
+                operands.back().record_size = strtoul( argv[4], &tail, 10);
+                if ( *tail )
+                        throw invalid_argument ("Unparsable record_size");
+
+        } else if ( strcmp( p, "prune")  == 0 ) {
+                operation = TKind::Prune;
+                if ( argc != 4 )
+                        throw invalid_argument ("Usage: prune FILE N1[N2,...]");
+                operands.emplace_back( argv[2]);
+                operands.back().figure_channels( agh::str::tokens_trimmed( argv[3], ","));
+
+        } else if ( strcmp( p, "merge") == 0 ) {
+                operation = TKind::Merge;
+                if ( argc < 4 )
+                        throw invalid_argument ("Usage: merge FILE FILE1 [FILE2 ...]");
+                for ( int k = 2; k < argc; ++k )
+                        operands.emplace_back( argv[k]);
+
+        } else
+                throw invalid_argument ("Unrecognised operation");
+
+        return 0;
 }
 
 
@@ -138,49 +138,49 @@ void
 SOperation::SObject::
 figure_timepoints( const list<string>& argv) throw (invalid_argument)
 {
-	for ( auto& A : argv ) {
-		char *tail;
-		long Int = strtol( A.c_str(), &tail, 10);
-		if ( *tail ) {
-			double Double = strtod( A.c_str(), &tail);
-			if ( *tail )
-				throw invalid_argument ("Unparsable timepoint value");
-			else if ( Double < 0. || Double > 1. )
-				throw invalid_argument ("A floating-point timepoint value must be in [0..1] range");
-			else {
-				if ( not timepoints_d.empty() )
-					throw invalid_argument ("Expecting all timepoint values to be either of type int or double");
-				timepoints_g.push_back( Double);
-			}
-		} else {
-			if ( not timepoints_g.empty() )
-				throw invalid_argument ("Expecting all timepoint values to be either of type int or double");
-			timepoints_d.push_back( Int);
-		}
-	}
-	if ( timepoints_d.empty() && timepoints_g.empty() )
-		throw invalid_argument ("Expecting one or more comma-separated timepoints (integers for absolute time in seconds, or doubles in range [0..1] for relative timepoints)");
-
-	timepoints_g.sort(); timepoints_g.unique();
-	timepoints_d.sort(); timepoints_d.unique();
+        for ( auto& A : argv ) {
+                char *tail;
+                long Int = strtol( A.c_str(), &tail, 10);
+                if ( *tail ) {
+                        double Double = strtod( A.c_str(), &tail);
+                        if ( *tail )
+                                throw invalid_argument ("Unparsable timepoint value");
+                        else if ( Double < 0. || Double > 1. )
+                                throw invalid_argument ("A floating-point timepoint value must be in [0..1] range");
+                        else {
+                                if ( not timepoints_d.empty() )
+                                        throw invalid_argument ("Expecting all timepoint values to be either of type int or double");
+                                timepoints_g.push_back( Double);
+                        }
+                } else {
+                        if ( not timepoints_g.empty() )
+                                throw invalid_argument ("Expecting all timepoint values to be either of type int or double");
+                        timepoints_d.push_back( Int);
+                }
+        }
+        if ( timepoints_d.empty() && timepoints_g.empty() )
+                throw invalid_argument ("Expecting one or more comma-separated timepoints (integers for absolute time in seconds, or doubles in range [0..1] for relative timepoints)");
+
+        timepoints_g.sort(); timepoints_g.unique();
+        timepoints_d.sort(); timepoints_d.unique();
 }
 
 void
 SOperation::SObject::
 figure_channels( const list<string>& argv) throw (invalid_argument)
 {
-	for ( auto& A : argv ) {
-		char *tail;
-		long Int = strtol( A.c_str(), &tail, 10) - 1;
-		if ( *tail )
-			throw invalid_argument ("Expecting a list of non-neg integers");
-		else
-			if ( Int < 1 )
-				throw invalid_argument ("Expecting a list of non-neg integers");
-		channels.push_back( Int);
-	}
-	if ( channels.empty() )
-		throw invalid_argument ("Expecting one or more channel comma-separated indices");
+        for ( auto& A : argv ) {
+                char *tail;
+                long Int = strtol( A.c_str(), &tail, 10) - 1;
+                if ( *tail )
+                        throw invalid_argument ("Expecting a list of non-neg integers");
+                else
+                        if ( Int < 1 )
+                                throw invalid_argument ("Expecting a list of non-neg integers");
+                channels.push_back( Int);
+        }
+        if ( channels.empty() )
+                throw invalid_argument ("Expecting one or more channel comma-separated indices");
 }
 
 
@@ -192,164 +192,164 @@ figure_channels( const list<string>& argv) throw (invalid_argument)
 list<pair<sigfile::SChannel, size_t>>
 make_channel_headers_for_CEDFFile( size_t n, const char *fmt, size_t samplerate)
 {
-	list<pair<sigfile::SChannel, size_t>> ret;
-	for ( size_t i = 0; i < n; ++i )
-		ret.emplace_back( agh::str::sasprintf( fmt, i), samplerate);
-	return ret;
+        list<pair<sigfile::SChannel, size_t>> ret;
+        for ( size_t i = 0; i < n; ++i )
+                ret.emplace_back( agh::str::sasprintf( fmt, i), samplerate);
+        return ret;
 }
 
 
 inline void
 sscanf_n_fields( string& linebuf, size_t columns, vector<valarray<TFloat>>& recp, size_t i)
 {
-	char *p = &linebuf[0];
-	for ( size_t f = 0; f < columns; ++f ) {
-		recp[f][i] = strtod( p, &p);
-		if ( (f == columns-1 && *p) || (f < columns-1 && !isspace(*p)) ) {
-			fprintf( stderr, "Bad data (row %zu, field %zu) at: \"%s\"\n", i, f, p);
-			throw runtime_error ("Bad data");
-		}
-		p += strspn( p, " ,\t");
-	}
+        char *p = &linebuf[0];
+        for ( size_t f = 0; f < columns; ++f ) {
+                recp[f][i] = strtod( p, &p);
+                if ( (f == columns-1 && *p) || (f < columns-1 && !isspace(*p)) ) {
+                        fprintf( stderr, "Bad data (row %zu, field %zu) at: \"%s\"\n", i, f, p);
+                        throw runtime_error ("Bad data");
+                }
+                p += strspn( p, " ,\t");
+        }
 }
 
 pair<TFloat, TFloat>
 determine_ranges( const valarray<TFloat>& x)
 {
-	pair<TFloat, TFloat> ranges = {x.min(), x.max()};
+        pair<TFloat, TFloat> ranges = {x.min(), x.max()};
 
-	return ranges;
+        return ranges;
 }
 
 
 valarray<TFloat>
 preprocess( const valarray<TFloat>& x_, size_t samplerate,
-	    TFloat* avgmin_p, TFloat* avgmax_p)
+            TFloat* avgmin_p, TFloat* avgmax_p)
 {
-	valarray<TFloat>
-		x = x_ - x_.sum()/x_.size(); // zeromean
-
-	vector<unsigned long>
-		mini, maxi;
-	sigproc::envelope(
-		{x, samplerate}, samplerate/4, .25,
-		(valarray<TFloat>*)nullptr,  // wow, just wow
-		(valarray<TFloat>*)nullptr,
-		&mini, &maxi);
-	// compute avg min and max
-	TFloat avgmin = 0.;
-	for ( size_t i = 0; i < mini.size(); ++i )
-		avgmin += x[mini[i]];
-	avgmin /= mini.size();
-	TFloat avgmax = 0.;
-	for ( size_t i = 0; i < maxi.size(); ++i )
-		avgmax += x[maxi[i]];
-	avgmax /= maxi.size();
-	printf( "avg min/max: %g/%g\n", avgmin, avgmax);
-	*avgmin_p = avgmin;
-	*avgmax_p = avgmax;
-
-	// find outliers
-	for ( size_t i = 0; i < mini.size(); ++i )
-		if ( x[mini[i]] < avgmin * 10 )
-			printf( "outlier (-) at %s:\t%g\n",
-				agh::str::dhms_colon((double)mini[i] / samplerate, 2).c_str(),
-				x[mini[i]]);
-	for ( size_t i = 0; i < maxi.size(); ++i )
-		if ( x[maxi[i]] > avgmax * 10 )
-			printf( "outlier (+) at %s:\t%g\n",
-				agh::str::dhms_colon((double)maxi[i] / samplerate, 2).c_str(),
-				x[maxi[i]]);
-
-	return x;
+        valarray<TFloat>
+                x = x_ - x_.sum()/x_.size(); // zeromean
+
+        vector<unsigned long>
+                mini, maxi;
+        sigproc::envelope(
+                {x, samplerate}, samplerate/4, .25,
+                (valarray<TFloat>*)nullptr,  // wow, just wow
+                (valarray<TFloat>*)nullptr,
+                &mini, &maxi);
+        // compute avg min and max
+        TFloat avgmin = 0.;
+        for ( size_t i = 0; i < mini.size(); ++i )
+                avgmin += x[mini[i]];
+        avgmin /= mini.size();
+        TFloat avgmax = 0.;
+        for ( size_t i = 0; i < maxi.size(); ++i )
+                avgmax += x[maxi[i]];
+        avgmax /= maxi.size();
+        printf( "avg min/max: %g/%g\n", avgmin, avgmax);
+        *avgmin_p = avgmin;
+        *avgmax_p = avgmax;
+
+        // find outliers
+        for ( size_t i = 0; i < mini.size(); ++i )
+                if ( x[mini[i]] < avgmin * 10 )
+                        printf( "outlier (-) at %s:\t%g\n",
+                                agh::str::dhms_colon((double)mini[i] / samplerate, 2).c_str(),
+                                x[mini[i]]);
+        for ( size_t i = 0; i < maxi.size(); ++i )
+                if ( x[maxi[i]] > avgmax * 10 )
+                        printf( "outlier (+) at %s:\t%g\n",
+                                agh::str::dhms_colon((double)maxi[i] / samplerate, 2).c_str(),
+                                x[maxi[i]]);
+
+        return x;
 }
 
 int
 exec_convert( const SOperation::SObject& obj)
 {
-	vector<valarray<TFloat>> Hh;
-	size_t total_samples;
-	double duration;
+        vector<valarray<TFloat>> Hh;
+        size_t total_samples;
+        double duration;
 
       // read data
-	{
-		ifstream ifs (obj.c_str());
-		if ( not ifs.good() )
-			throw runtime_error (agh::str::sasprintf( "Convert: Couldn't open file %s", obj.c_str()) );
-
-		string linebuf;
-		// figure # of fields
-		while ( (getline( ifs, linebuf, '\n'), linebuf[0] == '#') )
-			;
-		Hh.resize( agh::str::tokens( linebuf, " \t,").size());
-
-		size_t i = 0, p = 0;
+        {
+                ifstream ifs (obj.c_str());
+                if ( not ifs.good() )
+                        throw runtime_error (agh::str::sasprintf( "Convert: Couldn't open file %s", obj.c_str()) );
+
+                string linebuf;
+                // figure # of fields
+                while ( (getline( ifs, linebuf, '\n'), linebuf[0] == '#') )
+                        ;
+                Hh.resize( agh::str::tokens( linebuf, " \t,").size());
+
+                size_t i = 0, p = 0;
 #define chunk 1000000
-		while ( true ) {
-			if ( i >= p*chunk ) {
-				++p;
-				for ( size_t f = 0; f < Hh.size(); ++f ) {
-					auto tmp = Hh[f];
-					Hh[f].resize(p * chunk);
-					Hh[f][slice (0, tmp.size(), 1)] = tmp;
-				}
-			}
-
-			sscanf_n_fields( linebuf, Hh.size(), Hh, i); // throws
-			++i;
-
-			while ( (getline( ifs, linebuf, '\n'),
-				 linebuf.empty() || linebuf[0] == '#') )
-				if ( ifs.eof() )
-					goto out;
-		}
-	out:
-		total_samples = i;
-
-		duration = (double)total_samples/obj.samplerate;
-		printf( "Read %'zu samples (%s) in %zu channel(s)\n",
-			total_samples, agh::str::dhms(duration).c_str(), Hh.size());
-	}
+                while ( true ) {
+                        if ( i >= p*chunk ) {
+                                ++p;
+                                for ( size_t f = 0; f < Hh.size(); ++f ) {
+                                        auto tmp = Hh[f];
+                                        Hh[f].resize(p * chunk);
+                                        Hh[f][slice (0, tmp.size(), 1)] = tmp;
+                                }
+                        }
+
+                        sscanf_n_fields( linebuf, Hh.size(), Hh, i); // throws
+                        ++i;
+
+                        while ( (getline( ifs, linebuf, '\n'),
+                                 linebuf.empty() || linebuf[0] == '#') )
+                                if ( ifs.eof() )
+                                        goto out;
+                }
+        out:
+                total_samples = i;
+
+                duration = (double)total_samples/obj.samplerate;
+                printf( "Read %'zu samples (%s) in %zu channel(s)\n",
+                        total_samples, agh::str::dhms(duration).c_str(), Hh.size());
+        }
 
       // zeromean, report glitches, get ranges
-	vector<pair<TFloat, TFloat>>
-		ranges (Hh.size());
-	for ( size_t i = 0; i < Hh.size(); ++i ) {
-		Hh[i] = preprocess( Hh[i], obj.samplerate,
-				    &ranges[i].first, &ranges[i].second);
-		printf( "physical_min/max in channel %zu: %g:%g\n",
-			i, ranges[i].first, ranges[i].second);
-	}
+        vector<pair<TFloat, TFloat>>
+                ranges (Hh.size());
+        for ( size_t i = 0; i < Hh.size(); ++i ) {
+                Hh[i] = preprocess( Hh[i], obj.samplerate,
+                                    &ranges[i].first, &ranges[i].second);
+                printf( "physical_min/max in channel %zu: %g:%g\n",
+                        i, ranges[i].first, ranges[i].second);
+        }
 
       // unify ranges
-	TFloat grand_min = INFINITY, grand_max = -INFINITY;
-	for ( size_t i = 0; i < Hh.size(); ++i ) {
-		if ( grand_min > ranges[i].first )
-			grand_min = ranges[i].first;
-		if ( grand_max < ranges[i].second )
-			grand_max = ranges[i].second;
-	}
-	grand_min = floor(grand_min) * 1.5; // extend a little
-	grand_max =  ceil(grand_max) * 1.5;
-	printf( "Setting common physical_min/max to %g:%g\n",
-		grand_min, grand_max);
-
-	sigfile::CEDFFile F ((obj + ".edf").c_str(),
-			     sigfile::CEDFFile::TSubtype::edf,
-			     0|sigfile::CSource::no_ancillary_files,
-			     make_channel_headers_for_CEDFFile( Hh.size(), "channel%zu", obj.samplerate),
-			     obj.record_size,
-			     ceilf(duration / obj.record_size));
-	for ( size_t f = 0; f < Hh.size(); ++f ) {
-		F[f].set_physical_range( grand_min, grand_max);
-		F.put_signal( f, valarray<TFloat> {Hh[f][slice (0, total_samples, 1)]});
-	}
-
-	printf( "Created edf:\n%s\n"
-		"You may now want to fill out the header of the newly created EDF file.\n"
-		"Use edfhed --set ... to do so, or run edfhed-gtk.\n", F.details( 0|sigfile::CEDFFile::with_channels).c_str());
-
-	return 0;
+        TFloat grand_min = INFINITY, grand_max = -INFINITY;
+        for ( size_t i = 0; i < Hh.size(); ++i ) {
+                if ( grand_min > ranges[i].first )
+                        grand_min = ranges[i].first;
+                if ( grand_max < ranges[i].second )
+                        grand_max = ranges[i].second;
+        }
+        grand_min = floor(grand_min) * 1.5; // extend a little
+        grand_max =  ceil(grand_max) * 1.5;
+        printf( "Setting common physical_min/max to %g:%g\n",
+                grand_min, grand_max);
+
+        sigfile::CEDFFile F ((obj + ".edf").c_str(),
+                             sigfile::CEDFFile::TSubtype::edf,
+                             0|sigfile::CSource::no_ancillary_files,
+                             make_channel_headers_for_CEDFFile( Hh.size(), "channel%zu", obj.samplerate),
+                             obj.record_size,
+                             ceilf(duration / obj.record_size));
+        for ( size_t f = 0; f < Hh.size(); ++f ) {
+                F[f].set_physical_range( grand_min, grand_max);
+                F.put_signal( f, valarray<TFloat> {Hh[f][slice (0, total_samples, 1)]});
+        }
+
+        printf( "Created edf:\n%s\n"
+                "You may now want to fill out the header of the newly created EDF file.\n"
+                "Use edfhed --set ... to do so, or run edfhed-gtk.\n", F.details( 0|sigfile::CEDFFile::with_channels).c_str());
+
+        return 0;
 }
 
 
@@ -359,55 +359,55 @@ exec_convert( const SOperation::SObject& obj)
 int
 exec_prune( const SOperation::SObject& obj)
 {
-	sigfile::CEDFFile F (obj.c_str(), sigfile::CSource::no_ancillary_files);
-
-	list<pair<sigfile::SChannel, size_t>> selected_channels;
-	for ( auto& select_this : obj.channels ) {
-		if ( select_this >= F.n_channels() ) {
-			throw invalid_argument
-				(agh::str::sasprintf(
-					"Prune: Requested channel #%zu (1-based) in file %s which only has %zu channel(s)",
-					select_this, F.filename(), F.n_channels()));
-		}
-		string label (F[select_this].header.label, 16);
-//		strncpy( &label[0], F[select_this].header.label, 16);
-		selected_channels.emplace_back(
-			agh::str::trim( label), // F.channel_by_id( select_this), // that gives a cooked string like "1:<channel1>"
-			F.samplerate( select_this));
-	}
-	printf( "Keeping %zu channel(s)\n", selected_channels.size());
-
-	sigfile::CEDFFile G ((agh::fs::make_fname_base( obj, ".edf", agh::fs::TMakeFnameOption::normal) + "-mod.edf").c_str(),
-			     sigfile::CEDFFile::TSubtype::edf,
-			     sigfile::CSource::no_ancillary_files,
-			     selected_channels,
-			     F.data_record_size,
-			     F.n_data_records);
-
-	G.set_patient_id( F.patient_id());
-	string tmp = F.recording_id();
-	G.set_recording_id( tmp.c_str());
-	tmp = F.comment();
-	G.set_comment( tmp.c_str());
-	G.set_start_time( F.start_time());
-	printf( "Created edf:\n%s\n", G.details( 0|sigfile::CEDFFile::with_channels).c_str());
-
-//	F.resize( data.size() / obj.samplerate / obj.record_size);
-	size_t h = 0;
-	for ( auto& hs : obj.channels ) {
-		G[h].set_physical_range(
-			F[hs].physical_min, F[hs].physical_max);
-		G[h].set_digital_range(
-			F[hs].digital_min, F[hs].digital_max);
-		G[h].scale =
-			F[hs].scale;
-		G.put_signal(
-			h,
-			F.get_signal_original( hs));
-		++h;
-	}
-
-	return 0;
+        sigfile::CEDFFile F (obj.c_str(), sigfile::CSource::no_ancillary_files);
+
+        list<pair<sigfile::SChannel, size_t>> selected_channels;
+        for ( auto& select_this : obj.channels ) {
+                if ( select_this >= F.n_channels() ) {
+                        throw invalid_argument
+                                (agh::str::sasprintf(
+                                        "Prune: Requested channel #%zu (1-based) in file %s which only has %zu channel(s)",
+                                        select_this, F.filename(), F.n_channels()));
+                }
+                string label (F[select_this].header.label, 16);
+//                strncpy( &label[0], F[select_this].header.label, 16);
+                selected_channels.emplace_back(
+                        agh::str::trim( label), // F.channel_by_id( select_this), // that gives a cooked string like "1:<channel1>"
+                        F.samplerate( select_this));
+        }
+        printf( "Keeping %zu channel(s)\n", selected_channels.size());
+
+        sigfile::CEDFFile G ((agh::fs::make_fname_base( obj, ".edf", agh::fs::TMakeFnameOption::normal) + "-mod.edf").c_str(),
+                             sigfile::CEDFFile::TSubtype::edf,
+                             sigfile::CSource::no_ancillary_files,
+                             selected_channels,
+                             F.data_record_size,
+                             F.n_data_records);
+
+        G.set_patient_id( F.patient_id());
+        string tmp = F.recording_id();
+        G.set_recording_id( tmp.c_str());
+        tmp = F.comment();
+        G.set_comment( tmp.c_str());
+        G.set_start_time( F.start_time());
+        printf( "Created edf:\n%s\n", G.details( 0|sigfile::CEDFFile::with_channels).c_str());
+
+//        F.resize( data.size() / obj.samplerate / obj.record_size);
+        size_t h = 0;
+        for ( auto& hs : obj.channels ) {
+                G[h].set_physical_range(
+                        F[hs].physical_min, F[hs].physical_max);
+                G[h].set_digital_range(
+                        F[hs].digital_min, F[hs].digital_max);
+                G[h].scale =
+                        F[hs].scale;
+                G.put_signal(
+                        h,
+                        F.get_signal_original( hs));
+                ++h;
+        }
+
+        return 0;
 }
 
 
@@ -418,33 +418,33 @@ int
 SOperation::
 exec()
 {
-	switch ( operation ) {
-	// case TKind::Split:
-	// 	printf( "Pretend exec split (%s)\n", agh::str::join( operands, ", ").c_str());
-	//     break;
-	// case TKind::Cat:
-	// 	printf( "Pretend exec cat (%s)\n", agh::str::join( operands, ", ").c_str());
-	//     break;
-	case TKind::Convert:
-		return exec_convert( operands.front());
-	    break;
-	case TKind::Prune:
-		return exec_prune( operands.front());
-	    break;
-	// case TKind::Merge:
-	// 	printf( "Pretend exec merge (%s)\n", agh::str::join( operands, ", ").c_str());
-	//     break;
-	// case TKind::Generate:
-	// 	printf( "Generate Not supported\n");
-	//     break;
-	case TKind::Noop:
-	default:
-		printf( "edfcat %s <%s>\n"
-			"Usage: conv|prune OPERANDS\n", VERSION, PACKAGE_BUGREPORT);
-	    break;
-	}
-
-	return 0;
+        switch ( operation ) {
+        // case TKind::Split:
+        //         printf( "Pretend exec split (%s)\n", agh::str::join( operands, ", ").c_str());
+        //     break;
+        // case TKind::Cat:
+        //         printf( "Pretend exec cat (%s)\n", agh::str::join( operands, ", ").c_str());
+        //     break;
+        case TKind::Convert:
+                return exec_convert( operands.front());
+            break;
+        case TKind::Prune:
+                return exec_prune( operands.front());
+            break;
+        // case TKind::Merge:
+        //         printf( "Pretend exec merge (%s)\n", agh::str::join( operands, ", ").c_str());
+        //     break;
+        // case TKind::Generate:
+        //         printf( "Generate Not supported\n");
+        //     break;
+        case TKind::Noop:
+        default:
+                printf( "edfcat %s <%s>\n"
+                        "Usage: conv|prune OPERANDS\n", VERSION, PACKAGE_BUGREPORT);
+            break;
+        }
+
+        return 0;
 }
 
 
@@ -452,17 +452,17 @@ exec()
 int
 main( int argc, const char **argv)
 {
-	try {
-		SOperation Op (argc, argv);
+        try {
+                SOperation Op (argc, argv);
 
-		Op.exec();
+                Op.exec();
 
-	} catch (exception& ex) {
-		printf( "Error: %s\n", ex.what());
-		return 1;
-	}
+        } catch (exception& ex) {
+                printf( "Error: %s\n", ex.what());
+                return 1;
+        }
 
-	return 0;
+        return 0;
 }
 
 
diff --git a/upstream/src/tools/edfhed-gtk.cc b/upstream/src/tools/edfhed-gtk.cc
index b7eb251..fecbb0b 100644
--- a/upstream/src/tools/edfhed-gtk.cc
+++ b/upstream/src/tools/edfhed-gtk.cc
@@ -18,64 +18,64 @@
 void
 pop_ok_message( GtkWindow *parent, const char *str, ...)
 {
-	va_list ap;
-	va_start (ap, str);
-
-	static GString *buf = NULL;
-	if ( buf == NULL )
-		buf = g_string_new("");
-
-	g_string_vprintf( buf, str, ap);
-	va_end (ap);
-
-	GtkWidget *msg =
-		gtk_message_dialog_new_with_markup(
-			parent,
-			(GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
-			GTK_MESSAGE_INFO,
-			GTK_BUTTONS_OK,
-			buf->str, NULL);
-	gtk_dialog_run( (GtkDialog*)msg);
-	gtk_widget_destroy( msg);
+        va_list ap;
+        va_start (ap, str);
+
+        static GString *buf = NULL;
+        if ( buf == NULL )
+                buf = g_string_new("");
+
+        g_string_vprintf( buf, str, ap);
+        va_end (ap);
+
+        GtkWidget *msg =
+                gtk_message_dialog_new_with_markup(
+                        parent,
+                        (GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
+                        GTK_MESSAGE_INFO,
+                        GTK_BUTTONS_OK,
+                        buf->str, NULL);
+        gtk_dialog_run( (GtkDialog*)msg);
+        gtk_widget_destroy( msg);
 }
 
 
-#define AGH_GBGETOBJ(Type, A)				\
-	(A = (Type*)(gtk_builder_get_object( __builder, #A)))
+#define AGH_GBGETOBJ(Type, A)                                \
+        (A = (Type*)(gtk_builder_get_object( __builder, #A)))
 
-#define AGH_GBGETOBJ3(B, Type, A)			\
-	(A = (Type*)(gtk_builder_get_object( B, #A)))
+#define AGH_GBGETOBJ3(B, Type, A)                        \
+        (A = (Type*)(gtk_builder_get_object( B, #A)))
 
 //#include "../ui/globals.hh"
 
 
 
 GtkBuilder
-	*__builder;
+        *__builder;
 
 GtkDialog
-	*wMain;
+        *wMain;
 GtkLabel
-	*lLabel,
-	*lChannelsNum;
+        *lLabel,
+        *lChannelsNum;
 
 enum TEntry : int {
-	PatientID, RecordingID,
-	RecordingDate, RecordingTime, Reserved,
-	ChannelLabel, ChannelPhysicalDim,
-	ChannelPhysicalMin, ChannelPhysicalMax,
-	ChannelDigitalMin, ChannelDigitalMax,
-	ChannelTransducerType, ChannelFilteringInfo,
-	ChannelReserved,
-	ChannelSamplesPerRecord,
-	_n_entries
+        PatientID, RecordingID,
+        RecordingDate, RecordingTime, Reserved,
+        ChannelLabel, ChannelPhysicalDim,
+        ChannelPhysicalMin, ChannelPhysicalMax,
+        ChannelDigitalMin, ChannelDigitalMax,
+        ChannelTransducerType, ChannelFilteringInfo,
+        ChannelReserved,
+        ChannelSamplesPerRecord,
+        _n_entries
 };
 
 GtkEntry
-	*e[_n_entries];
+        *e[_n_entries];
 GtkButton
-	*bNext, *bPrevious,
-	*bWrite;
+        *bNext, *bPrevious,
+        *bWrite;
 
 
 int ui_init();
@@ -90,31 +90,31 @@ sigfile::CEDFFile *Fp;
 
 
 struct SChannelTmp {
-	string	Label, PhysicalDim,
-		PhysicalMin, PhysicalMax,
-		DigitalMin, DigitalMax,
-		TransducerType, FilteringInfo,
-		SamplesPerRecord,
-		Reserved;
-	SChannelTmp( const string& iLabel, const string& iPhysicalDim,
-		     const string& iPhysicalMin, const string& iPhysicalMax,
-		     const string& iDigitalMin, const string& iDigitalMax,
-		     const string& iTransducerType, const string& iFilteringInfo,
-		     const string& iSamplesPerRecord,
-		     const string& iReserved)
-	      : Label (iLabel), PhysicalDim (iPhysicalDim),
-		PhysicalMin (iPhysicalMin), PhysicalMax (iPhysicalMax),
-		DigitalMin (iDigitalMin), DigitalMax (iDigitalMax),
-		TransducerType (iTransducerType), FilteringInfo (iFilteringInfo),
-		SamplesPerRecord (iSamplesPerRecord),
-		Reserved (iReserved)
-		{}
+        string        Label, PhysicalDim,
+                PhysicalMin, PhysicalMax,
+                DigitalMin, DigitalMax,
+                TransducerType, FilteringInfo,
+                SamplesPerRecord,
+                Reserved;
+        SChannelTmp( const string& iLabel, const string& iPhysicalDim,
+                     const string& iPhysicalMin, const string& iPhysicalMax,
+                     const string& iDigitalMin, const string& iDigitalMax,
+                     const string& iTransducerType, const string& iFilteringInfo,
+                     const string& iSamplesPerRecord,
+                     const string& iReserved)
+              : Label (iLabel), PhysicalDim (iPhysicalDim),
+                PhysicalMin (iPhysicalMin), PhysicalMax (iPhysicalMax),
+                DigitalMin (iDigitalMin), DigitalMax (iDigitalMax),
+                TransducerType (iTransducerType), FilteringInfo (iFilteringInfo),
+                SamplesPerRecord (iSamplesPerRecord),
+                Reserved (iReserved)
+                {}
 };
 
 list<SChannelTmp>
-	channels_tmp;
+        channels_tmp;
 list<SChannelTmp>::iterator
-	HTmpi;
+        HTmpi;
 
 static void current_channel_data_to_widgets();
 static void widgets_to_current_channel_data();
@@ -128,75 +128,75 @@ size_t channel_no;
 int
 main( int argc, char **argv)
 {
-	int	c;
-	while ( (c = getopt( argc, argv, "h")) != -1 )
-		switch ( c ) {
-		case 'h':
-			printf( "Usage: %s file.edf\n", argv[0]);
-			return 0;
-		}
-
-	gtk_init( &argc, &argv);
-
-	const char *fname;
-	if ( optind < argc )
-		fname = argv[optind];
-	else {
-		if ( isatty( fileno( stdin)) ) {
-			printf( "Usage: %s file.edf\n", argv[0]);
-			return 0;
-		} else {
-			// pop_ok_message( NULL, "Usage: %s file.edf", argv[0]);
-			GtkWidget *f_chooser = gtk_file_chooser_dialog_new(
-				"edfhed-gtk: Choose a file to edit",
-				NULL,
-				GTK_FILE_CHOOSER_ACTION_OPEN,
-				GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-				GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
-				NULL);
-			GtkFileFilter *file_filter = gtk_file_filter_new();
-			gtk_file_filter_set_name( file_filter, "EDF recordings");
-			gtk_file_filter_add_pattern( file_filter, "*.edf");
-			gtk_file_chooser_add_filter( (GtkFileChooser*)f_chooser, file_filter);
-
-			if ( gtk_dialog_run( GTK_DIALOG (f_chooser)) == GTK_RESPONSE_ACCEPT )
-				fname = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER (f_chooser));
-			else
-				return 0;
-			gtk_widget_destroy( f_chooser);
-		}
-	}
-
-	if ( ui_init() ) {
-		pop_ok_message( NULL, "UI failed to initialise\n");
-		return 2;
-	}
-
-	try {
-		auto F = sigfile::CEDFFile (fname,
-					    sigfile::CSource::no_ancillary_files |
-					    sigfile::CEDFFile::no_field_consistency_check);
-
-		channel_no = 0;
-		Fp = &F;
-
-		edf_data_to_widgets( F);
-		HTmpi = channels_tmp.begin();
-		current_channel_data_to_widgets();
-
-		sensitize_channel_nav_buttons();
-		if ( gtk_dialog_run( wMain) == -5 ) {
-			// something edited but no Next/Prev pressed to trigger this, so do it now
-			widgets_to_current_channel_data();
-			widgets_to_edf_data( F);
-		}
-	} catch (invalid_argument ex) {
-		pop_ok_message( NULL, ex.what());
-	}
-
-	ui_fini();
-
-	return 0;
+        int        c;
+        while ( (c = getopt( argc, argv, "h")) != -1 )
+                switch ( c ) {
+                case 'h':
+                        printf( "Usage: %s file.edf\n", argv[0]);
+                        return 0;
+                }
+
+        gtk_init( &argc, &argv);
+
+        const char *fname;
+        if ( optind < argc )
+                fname = argv[optind];
+        else {
+                if ( isatty( fileno( stdin)) ) {
+                        printf( "Usage: %s file.edf\n", argv[0]);
+                        return 0;
+                } else {
+                        // pop_ok_message( NULL, "Usage: %s file.edf", argv[0]);
+                        GtkWidget *f_chooser = gtk_file_chooser_dialog_new(
+                                "edfhed-gtk: Choose a file to edit",
+                                NULL,
+                                GTK_FILE_CHOOSER_ACTION_OPEN,
+                                GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+                                GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+                                NULL);
+                        GtkFileFilter *file_filter = gtk_file_filter_new();
+                        gtk_file_filter_set_name( file_filter, "EDF recordings");
+                        gtk_file_filter_add_pattern( file_filter, "*.edf");
+                        gtk_file_chooser_add_filter( (GtkFileChooser*)f_chooser, file_filter);
+
+                        if ( gtk_dialog_run( GTK_DIALOG (f_chooser)) == GTK_RESPONSE_ACCEPT )
+                                fname = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER (f_chooser));
+                        else
+                                return 0;
+                        gtk_widget_destroy( f_chooser);
+                }
+        }
+
+        if ( ui_init() ) {
+                pop_ok_message( NULL, "UI failed to initialise\n");
+                return 2;
+        }
+
+        try {
+                auto F = sigfile::CEDFFile (fname,
+                                            sigfile::CSource::no_ancillary_files |
+                                            sigfile::CEDFFile::no_field_consistency_check);
+
+                channel_no = 0;
+                Fp = &F;
+
+                edf_data_to_widgets( F);
+                HTmpi = channels_tmp.begin();
+                current_channel_data_to_widgets();
+
+                sensitize_channel_nav_buttons();
+                if ( gtk_dialog_run( wMain) == -5 ) {
+                        // something edited but no Next/Prev pressed to trigger this, so do it now
+                        widgets_to_current_channel_data();
+                        widgets_to_edf_data( F);
+                }
+        } catch (invalid_argument ex) {
+                pop_ok_message( NULL, ex.what());
+        }
+
+        ui_fini();
+
+        return 0;
 }
 
 
@@ -204,26 +204,26 @@ main( int argc, char **argv)
 static void
 edf_data_to_widgets( const sigfile::CEDFFile& F)
 {
-	gtk_label_set_markup( lLabel, (string ("<b>File:</b> <i>") + F.filename() + "</i>").c_str());
-	gtk_entry_set_text( e[PatientID],     agh::str::trim( string (F.header.patient_id,     80)) . c_str());
-	gtk_entry_set_text( e[RecordingID],   agh::str::trim( string (F.header.recording_id,   80)) . c_str());
-	gtk_entry_set_text( e[RecordingDate], agh::str::trim( string (F.header.recording_date,  8)) . c_str());
-	gtk_entry_set_text( e[RecordingTime], agh::str::trim( string (F.header.recording_time,  8)) . c_str());
-	gtk_entry_set_text( e[Reserved],      agh::str::trim( string (F.header.reserved,       44)) . c_str());
-
-	for ( auto &h : F.channels ) {
-		channels_tmp.emplace_back(
-			agh::str::trim( string (h.header.label, 16)),
-			agh::str::trim( string (h.header.physical_dim, 8)),
-			agh::str::trim( string (h.header.physical_min, 8)),
-			agh::str::trim( string (h.header.physical_max, 8)),
-			agh::str::trim( string (h.header.digital_min,  8)),
-			agh::str::trim( string (h.header.digital_max,  8)),
-			agh::str::trim( string (h.header.transducer_type, 80)),
-			agh::str::trim( string (h.header.filtering_info, 80)),
-			agh::str::trim( string (h.header.samples_per_record, 8)),
-			agh::str::trim( string (h.header.reserved, 32)));
-	}
+        gtk_label_set_markup( lLabel, (string ("<b>File:</b> <i>") + F.filename() + "</i>").c_str());
+        gtk_entry_set_text( e[PatientID],     agh::str::trim( string (F.header.patient_id,     80)) . c_str());
+        gtk_entry_set_text( e[RecordingID],   agh::str::trim( string (F.header.recording_id,   80)) . c_str());
+        gtk_entry_set_text( e[RecordingDate], agh::str::trim( string (F.header.recording_date,  8)) . c_str());
+        gtk_entry_set_text( e[RecordingTime], agh::str::trim( string (F.header.recording_time,  8)) . c_str());
+        gtk_entry_set_text( e[Reserved],      agh::str::trim( string (F.header.reserved,       44)) . c_str());
+
+        for ( auto &h : F.channels ) {
+                channels_tmp.emplace_back(
+                        agh::str::trim( string (h.header.label, 16)),
+                        agh::str::trim( string (h.header.physical_dim, 8)),
+                        agh::str::trim( string (h.header.physical_min, 8)),
+                        agh::str::trim( string (h.header.physical_max, 8)),
+                        agh::str::trim( string (h.header.digital_min,  8)),
+                        agh::str::trim( string (h.header.digital_max,  8)),
+                        agh::str::trim( string (h.header.transducer_type, 80)),
+                        agh::str::trim( string (h.header.filtering_info, 80)),
+                        agh::str::trim( string (h.header.samples_per_record, 8)),
+                        agh::str::trim( string (h.header.reserved, 32)));
+        }
 }
 
 
@@ -231,26 +231,26 @@ edf_data_to_widgets( const sigfile::CEDFFile& F)
 static void
 widgets_to_edf_data( sigfile::CEDFFile& F)
 {
-	memcpy( F.header.patient_id,     agh::str::pad( gtk_entry_get_text( e[PatientID]),     80).c_str(), 80);
-	memcpy( F.header.recording_id,   agh::str::pad( gtk_entry_get_text( e[RecordingID]),   80).c_str(), 80);
-	memcpy( F.header.recording_date, agh::str::pad( gtk_entry_get_text( e[RecordingDate]),  8).c_str(),  8);
-	memcpy( F.header.recording_time, agh::str::pad( gtk_entry_get_text( e[RecordingTime]),  8).c_str(),  8);
-	memcpy( F.header.reserved,       agh::str::pad( gtk_entry_get_text( e[Reserved]),      44).c_str(), 44);
-
-	auto H = channels_tmp.begin();
-	for ( auto& h : F.channels ) {
-		memcpy( h.header.label,			agh::str::pad( H->Label,           16).c_str(), 16);
-		memcpy( h.header.physical_dim,		agh::str::pad( H->PhysicalDim,      8).c_str(),  8);
-		memcpy( h.header.physical_min,		agh::str::pad( H->PhysicalMin,      8).c_str(),  8);
-		memcpy( h.header.physical_max,		agh::str::pad( H->PhysicalMax,      8).c_str(),  8);
-		memcpy( h.header.digital_min,		agh::str::pad( H->DigitalMin,       8).c_str(),  8);
-		memcpy( h.header.digital_max,		agh::str::pad( H->DigitalMax,       8).c_str(),  8);
-		memcpy( h.header.transducer_type,	agh::str::pad( H->TransducerType,  80).c_str(), 80);
-		memcpy( h.header.filtering_info,	agh::str::pad( H->FilteringInfo,   80).c_str(), 80);
-		memcpy( h.header.samples_per_record,	agh::str::pad( H->SamplesPerRecord, 8).c_str(),  8);
-		memcpy( h.header.reserved,		agh::str::pad( H->Reserved,        32).c_str(), 32);
-		++H;
-	}
+        memcpy( F.header.patient_id,     agh::str::pad( gtk_entry_get_text( e[PatientID]),     80).c_str(), 80);
+        memcpy( F.header.recording_id,   agh::str::pad( gtk_entry_get_text( e[RecordingID]),   80).c_str(), 80);
+        memcpy( F.header.recording_date, agh::str::pad( gtk_entry_get_text( e[RecordingDate]),  8).c_str(),  8);
+        memcpy( F.header.recording_time, agh::str::pad( gtk_entry_get_text( e[RecordingTime]),  8).c_str(),  8);
+        memcpy( F.header.reserved,       agh::str::pad( gtk_entry_get_text( e[Reserved]),      44).c_str(), 44);
+
+        auto H = channels_tmp.begin();
+        for ( auto& h : F.channels ) {
+                memcpy( h.header.label,                        agh::str::pad( H->Label,           16).c_str(), 16);
+                memcpy( h.header.physical_dim,                agh::str::pad( H->PhysicalDim,      8).c_str(),  8);
+                memcpy( h.header.physical_min,                agh::str::pad( H->PhysicalMin,      8).c_str(),  8);
+                memcpy( h.header.physical_max,                agh::str::pad( H->PhysicalMax,      8).c_str(),  8);
+                memcpy( h.header.digital_min,                agh::str::pad( H->DigitalMin,       8).c_str(),  8);
+                memcpy( h.header.digital_max,                agh::str::pad( H->DigitalMax,       8).c_str(),  8);
+                memcpy( h.header.transducer_type,        agh::str::pad( H->TransducerType,  80).c_str(), 80);
+                memcpy( h.header.filtering_info,        agh::str::pad( H->FilteringInfo,   80).c_str(), 80);
+                memcpy( h.header.samples_per_record,        agh::str::pad( H->SamplesPerRecord, 8).c_str(),  8);
+                memcpy( h.header.reserved,                agh::str::pad( H->Reserved,        32).c_str(), 32);
+                ++H;
+        }
 }
 
 
@@ -260,75 +260,75 @@ widgets_to_edf_data( sigfile::CEDFFile& F)
 static void
 current_channel_data_to_widgets()
 {
-	GString *tmp = g_string_new("");
-	size_t i = 0;
-	for ( auto& H : channels_tmp ) {
-		gchar *escaped = g_markup_escape_text( agh::str::trim( H.Label).c_str(), -1);
-		if ( i++ == channel_no )
-			g_string_append_printf( tmp, "  <b>%s</b>  ", escaped);
-		else
-			g_string_append_printf( tmp, "  %s  ", escaped);
-		g_free( escaped);
-	}
-	gtk_label_set_markup( lChannelsNum, tmp->str);
-	g_string_free( tmp, TRUE);
-	gtk_entry_set_text( e[ChannelLabel],		agh::str::trim( HTmpi->Label      ) . c_str());
-	gtk_entry_set_text( e[ChannelPhysicalDim],	agh::str::trim( HTmpi->PhysicalDim) . c_str());
-	gtk_entry_set_text( e[ChannelPhysicalMin],	agh::str::trim( HTmpi->PhysicalMin) . c_str());
-	gtk_entry_set_text( e[ChannelPhysicalMax],	agh::str::trim( HTmpi->PhysicalMax) . c_str());
-	gtk_entry_set_text( e[ChannelDigitalMin],	agh::str::trim( HTmpi->DigitalMin ) . c_str());
-	gtk_entry_set_text( e[ChannelDigitalMax],	agh::str::trim( HTmpi->DigitalMax ) . c_str());
-	gtk_entry_set_text( e[ChannelTransducerType],	agh::str::trim( HTmpi->TransducerType) . c_str());
-	gtk_entry_set_text( e[ChannelFilteringInfo],	agh::str::trim( HTmpi->FilteringInfo)  . c_str());
-	gtk_entry_set_text( e[ChannelSamplesPerRecord],	agh::str::trim( HTmpi->SamplesPerRecord) . c_str());
-	gtk_entry_set_text( e[ChannelReserved],		agh::str::trim( HTmpi->Reserved)         . c_str());
+        GString *tmp = g_string_new("");
+        size_t i = 0;
+        for ( auto& H : channels_tmp ) {
+                gchar *escaped = g_markup_escape_text( agh::str::trim( H.Label).c_str(), -1);
+                if ( i++ == channel_no )
+                        g_string_append_printf( tmp, "  <b>%s</b>  ", escaped);
+                else
+                        g_string_append_printf( tmp, "  %s  ", escaped);
+                g_free( escaped);
+        }
+        gtk_label_set_markup( lChannelsNum, tmp->str);
+        g_string_free( tmp, TRUE);
+        gtk_entry_set_text( e[ChannelLabel],                agh::str::trim( HTmpi->Label      ) . c_str());
+        gtk_entry_set_text( e[ChannelPhysicalDim],        agh::str::trim( HTmpi->PhysicalDim) . c_str());
+        gtk_entry_set_text( e[ChannelPhysicalMin],        agh::str::trim( HTmpi->PhysicalMin) . c_str());
+        gtk_entry_set_text( e[ChannelPhysicalMax],        agh::str::trim( HTmpi->PhysicalMax) . c_str());
+        gtk_entry_set_text( e[ChannelDigitalMin],        agh::str::trim( HTmpi->DigitalMin ) . c_str());
+        gtk_entry_set_text( e[ChannelDigitalMax],        agh::str::trim( HTmpi->DigitalMax ) . c_str());
+        gtk_entry_set_text( e[ChannelTransducerType],        agh::str::trim( HTmpi->TransducerType) . c_str());
+        gtk_entry_set_text( e[ChannelFilteringInfo],        agh::str::trim( HTmpi->FilteringInfo)  . c_str());
+        gtk_entry_set_text( e[ChannelSamplesPerRecord],        agh::str::trim( HTmpi->SamplesPerRecord) . c_str());
+        gtk_entry_set_text( e[ChannelReserved],                agh::str::trim( HTmpi->Reserved)         . c_str());
 }
 
 static void
 widgets_to_current_channel_data()
 {
-	HTmpi->Label		= gtk_entry_get_text( e[ChannelLabel]);
-	HTmpi->PhysicalDim	= gtk_entry_get_text( e[ChannelPhysicalDim]);
-	HTmpi->PhysicalMin	= gtk_entry_get_text( e[ChannelPhysicalMin]);
-	HTmpi->PhysicalMax	= gtk_entry_get_text( e[ChannelPhysicalMax]);
-	HTmpi->DigitalMin	= gtk_entry_get_text( e[ChannelDigitalMin]);
-	HTmpi->DigitalMax	= gtk_entry_get_text( e[ChannelDigitalMax]);
-	HTmpi->TransducerType	= gtk_entry_get_text( e[ChannelTransducerType]);
-	HTmpi->FilteringInfo	= gtk_entry_get_text( e[ChannelFilteringInfo]);
-	HTmpi->SamplesPerRecord	= gtk_entry_get_text( e[ChannelSamplesPerRecord]);
-	HTmpi->Reserved		= gtk_entry_get_text( e[ChannelReserved]);
+        HTmpi->Label                = gtk_entry_get_text( e[ChannelLabel]);
+        HTmpi->PhysicalDim        = gtk_entry_get_text( e[ChannelPhysicalDim]);
+        HTmpi->PhysicalMin        = gtk_entry_get_text( e[ChannelPhysicalMin]);
+        HTmpi->PhysicalMax        = gtk_entry_get_text( e[ChannelPhysicalMax]);
+        HTmpi->DigitalMin        = gtk_entry_get_text( e[ChannelDigitalMin]);
+        HTmpi->DigitalMax        = gtk_entry_get_text( e[ChannelDigitalMax]);
+        HTmpi->TransducerType        = gtk_entry_get_text( e[ChannelTransducerType]);
+        HTmpi->FilteringInfo        = gtk_entry_get_text( e[ChannelFilteringInfo]);
+        HTmpi->SamplesPerRecord        = gtk_entry_get_text( e[ChannelSamplesPerRecord]);
+        HTmpi->Reserved                = gtk_entry_get_text( e[ChannelReserved]);
 }
 
 
 static bool
 validate_all_widgets()
 {
-	const char *str, *p;
-	struct tm ts;
-	str = gtk_entry_get_text( e[RecordingDate]);
-	p = strptime( str, "%d.%m.%y", &ts);
-	if ( strlen(str) != 8 || p == NULL || *p != '\0' )
-		return false;
-	str = gtk_entry_get_text( e[RecordingTime]);
-	p = strptime( str, "%H.%M.%S", &ts);
-	if ( strlen(str) != 8 || p == NULL || *p != '\0' )
-		return false;
-
-	char *tail;
-	double p_min, p_max;
-	int d_min, d_max;
-	if ( (p_min = strtod( gtk_entry_get_text( e[ChannelPhysicalMin]), &tail), *tail != '\0') )
-		return false;
-	if ( (p_max = strtod( gtk_entry_get_text( e[ChannelPhysicalMax]), &tail), *tail != '\0') )
-		return false;
-	if ( (d_min = strtoul( gtk_entry_get_text( e[ChannelDigitalMin]), &tail, 10), *tail != '\0') )
-		return false;
-	if ( (d_max = strtoul( gtk_entry_get_text( e[ChannelDigitalMax]), &tail, 10), *tail != '\0') )
-		return false;
-	if ( p_min >= p_max || d_min >= d_max )
-		return false;
-
-	return true;
+        const char *str, *p;
+        struct tm ts;
+        str = gtk_entry_get_text( e[RecordingDate]);
+        p = strptime( str, "%d.%m.%y", &ts);
+        if ( strlen(str) != 8 || p == NULL || *p != '\0' )
+                return false;
+        str = gtk_entry_get_text( e[RecordingTime]);
+        p = strptime( str, "%H.%M.%S", &ts);
+        if ( strlen(str) != 8 || p == NULL || *p != '\0' )
+                return false;
+
+        char *tail;
+        double p_min, p_max;
+        int d_min, d_max;
+        if ( (p_min = strtod( gtk_entry_get_text( e[ChannelPhysicalMin]), &tail), *tail != '\0') )
+                return false;
+        if ( (p_max = strtod( gtk_entry_get_text( e[ChannelPhysicalMax]), &tail), *tail != '\0') )
+                return false;
+        if ( (d_min = strtoul( gtk_entry_get_text( e[ChannelDigitalMin]), &tail, 10), *tail != '\0') )
+                return false;
+        if ( (d_max = strtoul( gtk_entry_get_text( e[ChannelDigitalMax]), &tail, 10), *tail != '\0') )
+                return false;
+        if ( p_min >= p_max || d_min >= d_max )
+                return false;
+
+        return true;
 }
 
 
@@ -336,51 +336,51 @@ validate_all_widgets()
 extern "C" void
 bNext_clicked_cb( GtkButton*, gpointer)
 {
-	if ( next(HTmpi) != channels_tmp.end() ) {
-		widgets_to_current_channel_data();
-		++HTmpi;
-		++channel_no;
-		current_channel_data_to_widgets();
-	}
-	sensitize_channel_nav_buttons();
+        if ( next(HTmpi) != channels_tmp.end() ) {
+                widgets_to_current_channel_data();
+                ++HTmpi;
+                ++channel_no;
+                current_channel_data_to_widgets();
+        }
+        sensitize_channel_nav_buttons();
 }
 
 extern "C" void
 bPrevious_clicked_cb( GtkButton*, gpointer)
 {
-	if ( HTmpi != channels_tmp.begin() ) {
-		widgets_to_current_channel_data();
-		--HTmpi;
-		--channel_no;
-		current_channel_data_to_widgets();
-	}
-	sensitize_channel_nav_buttons();
+        if ( HTmpi != channels_tmp.begin() ) {
+                widgets_to_current_channel_data();
+                --HTmpi;
+                --channel_no;
+                current_channel_data_to_widgets();
+        }
+        sensitize_channel_nav_buttons();
 }
 
 
 extern "C" void
 inserted_text_cb( GtkEntryBuffer *,
-		  guint           ,
-		  gchar          *,
-		  guint           ,
-		  gpointer        )
+                  guint           ,
+                  gchar          *,
+                  guint           ,
+                  gpointer        )
 {
-	gtk_widget_set_sensitive( (GtkWidget*)bWrite, validate_all_widgets());
+        gtk_widget_set_sensitive( (GtkWidget*)bWrite, validate_all_widgets());
 }
 extern "C" void
 deleted_text_cb( GtkEntryBuffer *,
-		 guint           ,
-		 guint           ,
-		 gpointer        )
+                 guint           ,
+                 guint           ,
+                 gpointer        )
 {
-	gtk_widget_set_sensitive( (GtkWidget*)bWrite, validate_all_widgets());
+        gtk_widget_set_sensitive( (GtkWidget*)bWrite, validate_all_widgets());
 }
 
 void
 sensitize_channel_nav_buttons()
 {
-	gtk_widget_set_sensitive( (GtkWidget*)bNext, not (next(HTmpi) == channels_tmp.end()));
-	gtk_widget_set_sensitive( (GtkWidget*)bPrevious, not (HTmpi == channels_tmp.begin()));
+        gtk_widget_set_sensitive( (GtkWidget*)bNext, not (next(HTmpi) == channels_tmp.end()));
+        gtk_widget_set_sensitive( (GtkWidget*)bPrevious, not (HTmpi == channels_tmp.begin()));
 }
 
 
@@ -388,57 +388,57 @@ int
 ui_init()
 {
       // load glade
-	__builder = gtk_builder_new();
-	if ( !gtk_builder_add_from_file( __builder, PACKAGE_DATADIR "/" PACKAGE "/edfhed.glade", NULL) ) {
-		pop_ok_message( NULL, "Failed to load UI description file.");
-		return -1;
-	}
-
-	if ( !AGH_GBGETOBJ (GtkDialog,  wMain) ||
-	     !AGH_GBGETOBJ (GtkLabel,   lLabel) ||
-	     !AGH_GBGETOBJ (GtkEntry,	e[PatientID]) ||
-	     !AGH_GBGETOBJ (GtkEntry,	e[RecordingID]) ||
-	     !AGH_GBGETOBJ (GtkEntry,	e[RecordingDate]) ||
-	     !AGH_GBGETOBJ (GtkEntry,	e[RecordingTime]) ||
-	     !AGH_GBGETOBJ (GtkEntry,	e[Reserved]) ||
-	     !AGH_GBGETOBJ (GtkLabel,   lChannelsNum) ||
-	     !AGH_GBGETOBJ (GtkEntry,   e[ChannelLabel]) ||
-	     !AGH_GBGETOBJ (GtkEntry,   e[ChannelPhysicalDim]) ||
-	     !AGH_GBGETOBJ (GtkEntry,   e[ChannelPhysicalMin]) ||
-	     !AGH_GBGETOBJ (GtkEntry,   e[ChannelPhysicalMax]) ||
-	     !AGH_GBGETOBJ (GtkEntry,   e[ChannelDigitalMin]) ||
-	     !AGH_GBGETOBJ (GtkEntry,   e[ChannelDigitalMax]) ||
-	     !AGH_GBGETOBJ (GtkEntry,   e[ChannelTransducerType]) ||
-	     !AGH_GBGETOBJ (GtkEntry,   e[ChannelFilteringInfo]) ||
-	     !AGH_GBGETOBJ (GtkEntry,   e[ChannelReserved]) ||
-	     !AGH_GBGETOBJ (GtkEntry,   e[ChannelSamplesPerRecord]) ||
-	     !AGH_GBGETOBJ (GtkButton,	bNext) ||
-	     !AGH_GBGETOBJ (GtkButton,	bPrevious) ||
-	     !AGH_GBGETOBJ (GtkButton,	bWrite) )
-		return -1;
-
-	gtk_builder_connect_signals( __builder, NULL);
-
-	for ( int i = 0; i < _n_entries; ++i ) {
+        __builder = gtk_builder_new();
+        if ( !gtk_builder_add_from_file( __builder, PACKAGE_DATADIR "/" PACKAGE "/edfhed.glade", NULL) ) {
+                pop_ok_message( NULL, "Failed to load UI description file.");
+                return -1;
+        }
+
+        if ( !AGH_GBGETOBJ (GtkDialog,  wMain) ||
+             !AGH_GBGETOBJ (GtkLabel,   lLabel) ||
+             !AGH_GBGETOBJ (GtkEntry,        e[PatientID]) ||
+             !AGH_GBGETOBJ (GtkEntry,        e[RecordingID]) ||
+             !AGH_GBGETOBJ (GtkEntry,        e[RecordingDate]) ||
+             !AGH_GBGETOBJ (GtkEntry,        e[RecordingTime]) ||
+             !AGH_GBGETOBJ (GtkEntry,        e[Reserved]) ||
+             !AGH_GBGETOBJ (GtkLabel,   lChannelsNum) ||
+             !AGH_GBGETOBJ (GtkEntry,   e[ChannelLabel]) ||
+             !AGH_GBGETOBJ (GtkEntry,   e[ChannelPhysicalDim]) ||
+             !AGH_GBGETOBJ (GtkEntry,   e[ChannelPhysicalMin]) ||
+             !AGH_GBGETOBJ (GtkEntry,   e[ChannelPhysicalMax]) ||
+             !AGH_GBGETOBJ (GtkEntry,   e[ChannelDigitalMin]) ||
+             !AGH_GBGETOBJ (GtkEntry,   e[ChannelDigitalMax]) ||
+             !AGH_GBGETOBJ (GtkEntry,   e[ChannelTransducerType]) ||
+             !AGH_GBGETOBJ (GtkEntry,   e[ChannelFilteringInfo]) ||
+             !AGH_GBGETOBJ (GtkEntry,   e[ChannelReserved]) ||
+             !AGH_GBGETOBJ (GtkEntry,   e[ChannelSamplesPerRecord]) ||
+             !AGH_GBGETOBJ (GtkButton,        bNext) ||
+             !AGH_GBGETOBJ (GtkButton,        bPrevious) ||
+             !AGH_GBGETOBJ (GtkButton,        bWrite) )
+                return -1;
+
+        gtk_builder_connect_signals( __builder, NULL);
+
+        for ( int i = 0; i < _n_entries; ++i ) {
 #pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
-		g_signal_connect( gtk_entry_get_buffer( e[i]),
-				  "deleted-text", (GCallback)deleted_text_cb,
-				  (gpointer)i);
-		g_signal_connect( gtk_entry_get_buffer( e[i]),
-				  "inserted-text", (GCallback)inserted_text_cb,
-				  (gpointer)i);
+                g_signal_connect( gtk_entry_get_buffer( e[i]),
+                                  "deleted-text", (GCallback)deleted_text_cb,
+                                  (gpointer)i);
+                g_signal_connect( gtk_entry_get_buffer( e[i]),
+                                  "inserted-text", (GCallback)inserted_text_cb,
+                                  (gpointer)i);
 #pragma GCC diagnostic warning "-Wint-to-pointer-cast"
-	}
+        }
 
-	return 0;
+        return 0;
 }
 
 
 void
 ui_fini()
 {
-	// gtk_widget_destroy
-	g_object_unref( __builder);
+        // gtk_widget_destroy
+        g_object_unref( __builder);
 }
 
 
diff --git a/upstream/src/tools/edfhed.cc b/upstream/src/tools/edfhed.cc
index 09fb6b0..4e5de4c 100644
--- a/upstream/src/tools/edfhed.cc
+++ b/upstream/src/tools/edfhed.cc
@@ -35,8 +35,8 @@
 #include "config.h"
 
 const char
-	*argp_program_version = "edfhed " VERSION,
-	*argp_program_bug_address = "<" PACKAGE_BUGREPORT ">";
+        *argp_program_version = "edfhed " VERSION,
+        *argp_program_bug_address = "<" PACKAGE_BUGREPORT ">";
 
 static char doc[] =
        "edfhed -- EDF file header viewer and non-interctive editor";
@@ -44,12 +44,12 @@ static char doc[] =
 #pragma GCC diagnostic ignored "-Wmissing-field-initializers"
 #pragma GCC diagnostic push
 static struct argp_option options[] = {
-       {"no-channels",		'b', 0,	0, "Only dump general header fields (no channel details)"},
-       {"with-annotations",	'a', 0,	0, "List embedded annotations"},
-       {"set",			's', "[CH:]FIELD:VALUE", 0, "Set FIELD to VALUE (possibly in channel CH)" },
-       {"id-from-tree",		'R', 0,	0, "Set 'recording_id' field to Subject/Session/Episode given current file location"},
-       {"from-mtime",		'T', 0,	0, "Set 'recording_date' and 'recording_time' fields to file modification date/time"},
-       {"touch-mtime",		't', 0,	0, "Parse 'recording_date' and 'recording_time' and set file modification timestamp"},
+       {"no-channels",             'b', 0,        	    0, "Only dump general header fields (no channel details)"},
+       {"with-annotations",        'a', 0,        	    0, "List embedded annotations"},
+       {"set",                     's', "[CH:]FIELD:VALUE", 0, "Set FIELD to VALUE (possibly in channel CH)" },
+       {"id-from-tree",            'R', 0,                  0, "Set 'recording_id' field to Subject/Session/Episode given current file location"},
+       {"from-mtime",              'T', 0,                  0, "Set 'recording_date' and 'recording_time' fields to file modification date/time"},
+       {"touch-mtime",             't', 0,                  0, "Parse 'recording_date' and 'recording_time' and set file modification timestamp"},
        { 0 }
      };
 #pragma GCC diagnostic pop
@@ -59,118 +59,118 @@ static char args_doc[] = "FILE.edf ...";
 static error_t parse_opt( int, char*, struct argp_state*);
 
 static struct argp argp = {
-	options,
-	parse_opt,
-	args_doc,
-	doc
+        options,
+        parse_opt,
+        args_doc,
+        doc
 };
 
 struct SSettable {
-	enum TField {
-		// note that some fields are not not included
-		version_number,		//  [ 8],
-		patient_id,		//  [80],  // maps to subject name
-		recording_id,		//  [80],  // maps to episode_name (session_name)
-		recording_date,		//  [ 8],
-		recording_time,		//  [ 8],
-		reserved,		//  [44],
-
-		ch_label,		//  [16],  // maps to channel
-		ch_transducer_type,	//  [80],
-		ch_physical_dim,	//  [ 8],
-		ch_physical_min,	//  [ 8],
-		ch_physical_max,	//  [ 8],
-		ch_digital_min,		//  [ 8],
-		ch_digital_max,		//  [ 8],
-		ch_filtering_info,	//  [80],
-		ch_reserved,		//  [32];
-	};
-	TField which;
-	int channel;
-
-	SSettable( const char* pv)
-		{
-			if ( from_string( pv) != 0 )
-				throw invalid_argument( pv);
-		}
-	SSettable() = delete;
-
-	string value;
-	int from_string( const char *pv)
-		{
-			int h = -1;
-			channel = h;
-			char p[21], v[81];  // make it 20
-			if ( 3 == sscanf( pv, "%u:%20[a-z_]:%80s", &h, p, v) && h != -1 ) {
-				channel = h - 1;  // base 0
-				if ( strcmp( p, "label") == 0 ) {
-					sigfile::SChannel X (p);
-					if ( X.type() != sigfile::SChannel::TType::eeg )
-						printf( "Note: Channel label \"%s\" does not follow System 10-20\n", v);
-					which = ch_label;
-				} else if ( strcmp( p, "transducer_type") == 0 ) {
-					which = ch_transducer_type;
-				} else if ( strcmp( p, "physical_dim") == 0 ) {
-					which = ch_physical_dim;
-				} else if ( strcmp( p, "physical_min") == 0 ) {
-					stod(v);
-					which = ch_physical_min;
-				} else if ( strcmp( p, "physical_max") == 0 ) {
-					stod(v);
-					which = ch_physical_max;
-				} else if ( strcmp( p, "digital_min") == 0 ) {
-					stoi(v);
-					which = ch_digital_min;
-				} else if ( strcmp( p, "digital_max") == 0 ) {
-					stoi(v);
-					which = ch_digital_max;
-				} else if ( strcmp( p, "filtering_info") == 0 ) {
-					which = ch_filtering_info;
-				} else if ( strcmp( p, "reserved") == 0 ) {
-					which = ch_reserved;
-				} else
-					return -3;
-			} else if ( 2 == sscanf( pv, "%20[a-z_]:%80s", p, v) ) {
-				if      ( strcmp( p, "version_number") == 0 )
-					which = version_number;
-				else if ( strcmp( p, "patient_id") == 0 )
-					which = patient_id;
-				else if ( strcmp( p, "recording_id") == 0 )
-					which = recording_id;
-				else if ( strcmp( p, "recording_date") == 0 )
-					which = recording_date;
-				else if ( strcmp( p, "recording_time") == 0 )
-					which = recording_time;
-				else if ( strcmp( p, "reserved") == 0 )
-					which = reserved;
-				else
-					return -2;
-			} else {
-				return -1;
-			}
-
-			value.assign( v);
-			return 0;
-		}
+        enum TField {
+                // note that some fields are not not included
+                version_number,                //  [ 8],
+                patient_id,                //  [80],  // maps to subject name
+                recording_id,                //  [80],  // maps to episode_name (session_name)
+                recording_date,                //  [ 8],
+                recording_time,                //  [ 8],
+                reserved,                //  [44],
+
+                ch_label,                //  [16],  // maps to channel
+                ch_transducer_type,        //  [80],
+                ch_physical_dim,        //  [ 8],
+                ch_physical_min,        //  [ 8],
+                ch_physical_max,        //  [ 8],
+                ch_digital_min,                //  [ 8],
+                ch_digital_max,                //  [ 8],
+                ch_filtering_info,        //  [80],
+                ch_reserved,                //  [32];
+        };
+        TField which;
+        int channel;
+
+        SSettable( const char* pv)
+                {
+                        if ( from_string( pv) != 0 )
+                                throw invalid_argument( pv);
+                }
+        SSettable() = delete;
+
+        string value;
+        int from_string( const char *pv)
+                {
+                        int h = -1;
+                        channel = h;
+                        char p[21], v[81];  // make it 20
+                        if ( 3 == sscanf( pv, "%u:%20[a-z_]:%80s", &h, p, v) && h != -1 ) {
+                                channel = h - 1;  // base 0
+                                if ( strcmp( p, "label") == 0 ) {
+                                        sigfile::SChannel X (p);
+                                        if ( X.type() != sigfile::SChannel::TType::eeg )
+                                                printf( "Note: Channel label \"%s\" does not follow System 10-20\n", v);
+                                        which = ch_label;
+                                } else if ( strcmp( p, "transducer_type") == 0 ) {
+                                        which = ch_transducer_type;
+                                } else if ( strcmp( p, "physical_dim") == 0 ) {
+                                        which = ch_physical_dim;
+                                } else if ( strcmp( p, "physical_min") == 0 ) {
+                                        stod(v);
+                                        which = ch_physical_min;
+                                } else if ( strcmp( p, "physical_max") == 0 ) {
+                                        stod(v);
+                                        which = ch_physical_max;
+                                } else if ( strcmp( p, "digital_min") == 0 ) {
+                                        stoi(v);
+                                        which = ch_digital_min;
+                                } else if ( strcmp( p, "digital_max") == 0 ) {
+                                        stoi(v);
+                                        which = ch_digital_max;
+                                } else if ( strcmp( p, "filtering_info") == 0 ) {
+                                        which = ch_filtering_info;
+                                } else if ( strcmp( p, "reserved") == 0 ) {
+                                        which = ch_reserved;
+                                } else
+                                        return -3;
+                        } else if ( 2 == sscanf( pv, "%20[a-z_]:%80s", p, v) ) {
+                                if      ( strcmp( p, "version_number") == 0 )
+                                        which = version_number;
+                                else if ( strcmp( p, "patient_id") == 0 )
+                                        which = patient_id;
+                                else if ( strcmp( p, "recording_id") == 0 )
+                                        which = recording_id;
+                                else if ( strcmp( p, "recording_date") == 0 )
+                                        which = recording_date;
+                                else if ( strcmp( p, "recording_time") == 0 )
+                                        which = recording_time;
+                                else if ( strcmp( p, "reserved") == 0 )
+                                        which = reserved;
+                                else
+                                        return -2;
+                        } else {
+                                return -1;
+                        }
+
+                        value.assign( v);
+                        return 0;
+                }
 };
 
 struct SArguments {
-	std::vector<const char*>
-		files;
-	std::vector<SSettable>
-		settables;
-	bool	header_only:1,
-		with_annotations:1,
-		from_tree:1,
-		from_timestamp:1,
-		to_timestamp:1;
-	SArguments()
-	      : header_only (false),
-		with_annotations (false),
-		from_tree (false),
-		from_timestamp (false),
-		to_timestamp (false)
-		{}
+        std::vector<const char*>
+                files;
+        std::vector<SSettable>
+                settables;
+        bool        header_only:1,
+                with_annotations:1,
+                from_tree:1,
+                from_timestamp:1,
+                to_timestamp:1;
+        SArguments()
+              : header_only (false),
+                with_annotations (false),
+                from_tree (false),
+                from_timestamp (false),
+                to_timestamp (false)
+                {}
 };
 
 
@@ -178,53 +178,53 @@ struct SArguments {
 static error_t
 parse_opt( int key, char *arg, struct argp_state *state)
 {
-	auto& Q = *(SArguments*)state->input;
-
-	switch ( key ) {
-	case 'b':
-		Q.header_only = true;
-		break;
-	case 'a':
-		Q.with_annotations = true;
-		break;
-	case 'R':
-		Q.from_tree = true;
-		break;
-	case 'T':
-		Q.from_timestamp = true;
-		break;
-	case 't':
-		Q.to_timestamp = true;
-		break;
-	case 's':
-		try {
-			// screw google C++ guidelines
-			Q.settables.emplace_back( arg);
-		} catch (...) {
-			cerr << "Bad field or value: " << arg << endl
-			     << "Valid fields are:\n"
-				"\tversion_number, patient_id, recording_id,\n"
-				"\trecording_date, recording_time, reserved;\n"
-				"(with prepended <ch>:)\n"
-				"\tlabel, transducer_type, physical_dim,\n"
-				"\tphysical_min, physical_max, digital_min, digital_max,\n"
-				"\tfiltering_info, reserved\n";
-			exit(1);
-		}
-		break;
-
-	case ARGP_KEY_ARG:
-		Q.files.push_back( arg);
-		break;
-
-	case ARGP_KEY_END:
-		if ( state->arg_num < 1 )
-			argp_usage( state);
-		break;
-	default:
-		return (error_t)ARGP_ERR_UNKNOWN;
-	}
-	return (error_t)0;
+        auto& Q = *(SArguments*)state->input;
+
+        switch ( key ) {
+        case 'b':
+                Q.header_only = true;
+                break;
+        case 'a':
+                Q.with_annotations = true;
+                break;
+        case 'R':
+                Q.from_tree = true;
+                break;
+        case 'T':
+                Q.from_timestamp = true;
+                break;
+        case 't':
+                Q.to_timestamp = true;
+                break;
+        case 's':
+                try {
+                        // screw google C++ guidelines
+                        Q.settables.emplace_back( arg);
+                } catch (...) {
+                        cerr << "Bad field or value: " << arg << endl
+                             << "Valid fields are:\n"
+                                "\tversion_number, patient_id, recording_id,\n"
+                                "\trecording_date, recording_time, reserved;\n"
+                                "(with prepended <ch>:)\n"
+                                "\tlabel, transducer_type, physical_dim,\n"
+                                "\tphysical_min, physical_max, digital_min, digital_max,\n"
+                                "\tfiltering_info, reserved\n";
+                        exit(1);
+                }
+                break;
+
+        case ARGP_KEY_ARG:
+                Q.files.push_back( arg);
+                break;
+
+        case ARGP_KEY_END:
+                if ( state->arg_num < 1 )
+                        argp_usage( state);
+                break;
+        default:
+                return (error_t)ARGP_ERR_UNKNOWN;
+        }
+        return (error_t)0;
 }
 
 
@@ -232,196 +232,196 @@ parse_opt( int key, char *arg, struct argp_state *state)
 static int
 set_recording_datetime_from_mtime( sigfile::CEDFFile& F)
 {
-	struct stat ss;
-	if ( stat( F.filename(), &ss) != 0 ) {
-		perror( (string ("Error statting ") + F.filename()).c_str());
-		return errno;
-	} else {
-		struct tm *t = localtime( &ss.st_mtime);
-		if ( t ) {
-			char date_buf[9], time_buf[9];
-			int fixed_year = t->tm_year;
-			if ( fixed_year > 99 )
-				fixed_year -= 100;
-			snprintf( date_buf, 9, "%02d.%02d.%02d",
-				  t->tm_mday, t->tm_mon+1, fixed_year);
-			snprintf( time_buf, 9, "%02d.%02d.%02d",
-				  t->tm_hour, t->tm_min, t->tm_sec);
-			memcpy( F.header.recording_date,
-				date_buf, 8);
-			memcpy( F.header.recording_time,
-				time_buf, 8);
-			printf( "%s %s\n", date_buf, time_buf);
-			return 0;
-		} else {
-			fprintf( stderr, "Could not parse statted mtime of %s\n", F.filename());
-			return -1;
-		}
-	}
+        struct stat ss;
+        if ( stat( F.filename(), &ss) != 0 ) {
+                perror( (string ("Error statting ") + F.filename()).c_str());
+                return errno;
+        } else {
+                struct tm *t = localtime( &ss.st_mtime);
+                if ( t ) {
+                        char date_buf[9], time_buf[9];
+                        int fixed_year = t->tm_year;
+                        if ( fixed_year > 99 )
+                                fixed_year -= 100;
+                        snprintf( date_buf, 9, "%02d.%02d.%02d",
+                                  t->tm_mday, t->tm_mon+1, fixed_year);
+                        snprintf( time_buf, 9, "%02d.%02d.%02d",
+                                  t->tm_hour, t->tm_min, t->tm_sec);
+                        memcpy( F.header.recording_date,
+                                date_buf, 8);
+                        memcpy( F.header.recording_time,
+                                time_buf, 8);
+                        printf( "%s %s\n", date_buf, time_buf);
+                        return 0;
+                } else {
+                        fprintf( stderr, "Could not parse statted mtime of %s\n", F.filename());
+                        return -1;
+                }
+        }
 }
 
 
 static int
 set_mtime_from_recording_datetime( sigfile::CEDFFile& F)
 {
-	if ( F.status() & sigfile::CSource::bad_datetime ) {
-		fprintf( stderr, "Error: Bad recording_date or _time fields; not setting file mtime");
-		return -1;
-	}
-
-	struct utimbuf tmb;
-	tmb.modtime = tmb.actime = F.start_time();
-	if ( utime( F.filename(), &tmb) ) {
-		perror("Error setting mtime:");
-		return errno;
-	}
-	return 0;
+        if ( F.status() & sigfile::CSource::bad_datetime ) {
+                fprintf( stderr, "Error: Bad recording_date or _time fields; not setting file mtime");
+                return -1;
+        }
+
+        struct utimbuf tmb;
+        tmb.modtime = tmb.actime = F.start_time();
+        if ( utime( F.filename(), &tmb) ) {
+                perror("Error setting mtime:");
+                return errno;
+        }
+        return 0;
 }
 
 
 static int
 set_session_and_episode_from_tree( sigfile::CEDFFile& F)
 {
-	// filename can be anything, including a symlink
-	bool	is_path_absolute = (F.filename()[0] == '/');
-	list<string> pe = agh::fs::path_elements( string (is_path_absolute ? "" : "./") + F.filename());
-	string	episode = agh::fs::make_fname_base( pe.back(), ".edf", agh::fs::TMakeFnameOption::normal);
-
-	string	in_dir = string (is_path_absolute ? "/" : "") + agh::str::join( list<string> (pe.begin(), prev(pe.end())), "/") + "/.";
-	// a symlink from ./filename.edf would resolve somewhere else,
-	// losing the right path elements, so only canonicalize_file_name
-	// on the dir it is in
-	char *c = canonicalize_file_name( in_dir.c_str());
-	pe = agh::fs::path_elements( c);
-	free(c);
-	if ( pe.size() < 2 ) {
-		fprintf( stderr, "Too few path elements (expecting Subject/Session/Episode.edf)\n");
-		return -1;
-	}
-	string	session = pe.back(),
-		subject = (pe.pop_back(), pe.back());
-	// assign
-	if ( subject.size() > 80 ) {
-		fprintf( stderr, "Refuse to set patient_id as path element \"%s\" is longer than 80 characters\n",
-			 subject.c_str());
-		return -2;
-	}
-	if ( session.size() + 1 + episode.size() > 80 ) {
-		fprintf( stderr, "Refuse to set recording_id as path elements \"%s/%s\" combined are longer than 80 characters\n",
-			 session.c_str(), episode.c_str());
-		return -2;
-	}
-	memcpy( F.header.patient_id,
-		agh::str::pad( subject.c_str(), 80).c_str(), 80);
-	memcpy( F.header.recording_id,
-		agh::str::pad( (session + '/' + episode).c_str(), 80).c_str(), 80);
-	return 0;
+        // filename can be anything, including a symlink
+        bool        is_path_absolute = (F.filename()[0] == '/');
+        list<string> pe = agh::fs::path_elements( string (is_path_absolute ? "" : "./") + F.filename());
+        string        episode = agh::fs::make_fname_base( pe.back(), ".edf", agh::fs::TMakeFnameOption::normal);
+
+        string        in_dir = string (is_path_absolute ? "/" : "") + agh::str::join( list<string> (pe.begin(), prev(pe.end())), "/") + "/.";
+        // a symlink from ./filename.edf would resolve somewhere else,
+        // losing the right path elements, so only canonicalize_file_name
+        // on the dir it is in
+        char *c = canonicalize_file_name( in_dir.c_str());
+        pe = agh::fs::path_elements( c);
+        free(c);
+        if ( pe.size() < 2 ) {
+                fprintf( stderr, "Too few path elements (expecting Subject/Session/Episode.edf)\n");
+                return -1;
+        }
+        string        session = pe.back(),
+                subject = (pe.pop_back(), pe.back());
+        // assign
+        if ( subject.size() > 80 ) {
+                fprintf( stderr, "Refuse to set patient_id as path element \"%s\" is longer than 80 characters\n",
+                         subject.c_str());
+                return -2;
+        }
+        if ( session.size() + 1 + episode.size() > 80 ) {
+                fprintf( stderr, "Refuse to set recording_id as path elements \"%s/%s\" combined are longer than 80 characters\n",
+                         session.c_str(), episode.c_str());
+                return -2;
+        }
+        memcpy( F.header.patient_id,
+                agh::str::pad( subject.c_str(), 80).c_str(), 80);
+        memcpy( F.header.recording_id,
+                agh::str::pad( (session + '/' + episode).c_str(), 80).c_str(), 80);
+        return 0;
 }
 
 int
 main( int argc, char **argv)
 {
-	SArguments Opts;
-	argp_parse( &argp, argc, argv, 0, NULL, (void*)&Opts);
-
-	for ( auto &fname : Opts.files )
-		try {
-			auto F = sigfile::CEDFFile (fname,
-						    sigfile::CSource::no_ancillary_files |
-						    sigfile::CEDFFile::no_field_consistency_check);
-			if ( Opts.settables.empty() &&
-			     not Opts.from_timestamp && not Opts.from_tree && not Opts.to_timestamp ) {
-				cout << F.details(
-					0
-					| (Opts.header_only ? 0 : sigfile::CEDFFile::with_channels)
-					| (Opts.with_annotations ? sigfile::CEDFFile::with_annotations : 0))
-				     << endl;
-			} else {
-				if ( Opts.to_timestamp ) {
-					set_mtime_from_recording_datetime( F);
-				}
-				if ( Opts.from_timestamp ) {
-					set_recording_datetime_from_mtime( F);
-				}
-				if ( Opts.from_tree ) {
-					set_session_and_episode_from_tree( F);
-				}
-				for ( auto& S : Opts.settables ) {
-					switch ( S.which ) {
-					case SSettable::TField::version_number:
-						memcpy( F.header.version_number,
-							agh::str::pad( S.value.c_str(),  8).c_str(),  8);
-						break;
-					case SSettable::TField::patient_id:
-						memcpy( F.header.patient_id,
-							agh::str::pad( S.value.c_str(), 80).c_str(), 80);
-						break;
-					case SSettable::TField::recording_id:
-						memcpy( F.header.recording_id,
-							agh::str::pad( S.value.c_str(), 80).c_str(), 80);
-						break;
-					case SSettable::TField::recording_date:
-						memcpy( F.header.recording_date,
-							agh::str::pad( S.value.c_str(),  8).c_str(),  8);
-						break;
-					case SSettable::TField::recording_time:
-						memcpy( F.header.recording_time,
-							agh::str::pad( S.value.c_str(),  8).c_str(),  8);
-						break;
-					case SSettable::TField::reserved:
-						memcpy( F.header.reserved,
-							agh::str::pad( S.value.c_str(), 44).c_str(), 44);
-						break;
-
-					case SSettable::TField::ch_label:
-						memcpy( F[S.channel].header.label,
-							agh::str::pad( S.value.c_str(), 16).c_str(), 16);
-						break;
-					case SSettable::TField::ch_transducer_type:
-						memcpy( F[S.channel].header.transducer_type,
-							agh::str::pad( S.value.c_str(), 80).c_str(), 80);
-						break;
-					case SSettable::TField::ch_physical_dim:
-						memcpy( F[S.channel].header.physical_dim,
-							agh::str::pad( S.value.c_str(),  8).c_str(),  8);
-						break;
-					case SSettable::TField::ch_physical_min:
-						memcpy( F[S.channel].header.physical_min,
-							agh::str::pad( S.value.c_str(),  8).c_str(),  8);
-						break;
-					case SSettable::TField::ch_physical_max:
-						memcpy( F[S.channel].header.physical_max,
-							agh::str::pad( S.value.c_str(),  8).c_str(),  8);
-						break;
-					case SSettable::TField::ch_digital_min:
-						memcpy( F[S.channel].header.digital_min,
-							agh::str::pad( S.value.c_str(),  8).c_str(),  8);
-						break;
-					case SSettable::TField::ch_digital_max:
-						memcpy( F[S.channel].header.digital_max,
-							agh::str::pad( S.value.c_str(),  8).c_str(),  8);
-						break;
-					case SSettable::TField::ch_filtering_info:
-						memcpy( F[S.channel].header.filtering_info,
-							agh::str::pad( S.value.c_str(), 80).c_str(), 80);
-						break;
-					case SSettable::TField::ch_reserved:
-						memcpy( F[S.channel].header.reserved,
-							agh::str::pad( S.value.c_str(), 32).c_str(), 32);
-						break;
-					}
-				}
-			}
-
-		} catch (invalid_argument ex) {
-			cerr << ex.what() << endl;
-			return -2;
-		} catch (out_of_range ex) {
-			cerr << ex.what() << endl;
-			return -2;
-		}
-
-	return 0;
+        SArguments Opts;
+        argp_parse( &argp, argc, argv, 0, NULL, (void*)&Opts);
+
+        for ( auto &fname : Opts.files )
+                try {
+                        auto F = sigfile::CEDFFile (fname,
+                                                    sigfile::CSource::no_ancillary_files |
+                                                    sigfile::CEDFFile::no_field_consistency_check);
+                        if ( Opts.settables.empty() &&
+                             not Opts.from_timestamp && not Opts.from_tree && not Opts.to_timestamp ) {
+                                cout << F.details(
+                                        0
+                                        | (Opts.header_only ? 0 : sigfile::CEDFFile::with_channels)
+                                        | (Opts.with_annotations ? sigfile::CEDFFile::with_annotations : 0))
+                                     << endl;
+                        } else {
+                                if ( Opts.to_timestamp ) {
+                                        set_mtime_from_recording_datetime( F);
+                                }
+                                if ( Opts.from_timestamp ) {
+                                        set_recording_datetime_from_mtime( F);
+                                }
+                                if ( Opts.from_tree ) {
+                                        set_session_and_episode_from_tree( F);
+                                }
+                                for ( auto& S : Opts.settables ) {
+                                        switch ( S.which ) {
+                                        case SSettable::TField::version_number:
+                                                memcpy( F.header.version_number,
+                                                        agh::str::pad( S.value.c_str(),  8).c_str(),  8);
+                                                break;
+                                        case SSettable::TField::patient_id:
+                                                memcpy( F.header.patient_id,
+                                                        agh::str::pad( S.value.c_str(), 80).c_str(), 80);
+                                                break;
+                                        case SSettable::TField::recording_id:
+                                                memcpy( F.header.recording_id,
+                                                        agh::str::pad( S.value.c_str(), 80).c_str(), 80);
+                                                break;
+                                        case SSettable::TField::recording_date:
+                                                memcpy( F.header.recording_date,
+                                                        agh::str::pad( S.value.c_str(),  8).c_str(),  8);
+                                                break;
+                                        case SSettable::TField::recording_time:
+                                                memcpy( F.header.recording_time,
+                                                        agh::str::pad( S.value.c_str(),  8).c_str(),  8);
+                                                break;
+                                        case SSettable::TField::reserved:
+                                                memcpy( F.header.reserved,
+                                                        agh::str::pad( S.value.c_str(), 44).c_str(), 44);
+                                                break;
+
+                                        case SSettable::TField::ch_label:
+                                                memcpy( F[S.channel].header.label,
+                                                        agh::str::pad( S.value.c_str(), 16).c_str(), 16);
+                                                break;
+                                        case SSettable::TField::ch_transducer_type:
+                                                memcpy( F[S.channel].header.transducer_type,
+                                                        agh::str::pad( S.value.c_str(), 80).c_str(), 80);
+                                                break;
+                                        case SSettable::TField::ch_physical_dim:
+                                                memcpy( F[S.channel].header.physical_dim,
+                                                        agh::str::pad( S.value.c_str(),  8).c_str(),  8);
+                                                break;
+                                        case SSettable::TField::ch_physical_min:
+                                                memcpy( F[S.channel].header.physical_min,
+                                                        agh::str::pad( S.value.c_str(),  8).c_str(),  8);
+                                                break;
+                                        case SSettable::TField::ch_physical_max:
+                                                memcpy( F[S.channel].header.physical_max,
+                                                        agh::str::pad( S.value.c_str(),  8).c_str(),  8);
+                                                break;
+                                        case SSettable::TField::ch_digital_min:
+                                                memcpy( F[S.channel].header.digital_min,
+                                                        agh::str::pad( S.value.c_str(),  8).c_str(),  8);
+                                                break;
+                                        case SSettable::TField::ch_digital_max:
+                                                memcpy( F[S.channel].header.digital_max,
+                                                        agh::str::pad( S.value.c_str(),  8).c_str(),  8);
+                                                break;
+                                        case SSettable::TField::ch_filtering_info:
+                                                memcpy( F[S.channel].header.filtering_info,
+                                                        agh::str::pad( S.value.c_str(), 80).c_str(), 80);
+                                                break;
+                                        case SSettable::TField::ch_reserved:
+                                                memcpy( F[S.channel].header.reserved,
+                                                        agh::str::pad( S.value.c_str(), 32).c_str(), 32);
+                                                break;
+                                        }
+                                }
+                        }
+
+                } catch (invalid_argument ex) {
+                        cerr << ex.what() << endl;
+                        return -2;
+                } catch (out_of_range ex) {
+                        cerr << ex.what() << endl;
+                        return -2;
+                }
+
+        return 0;
 }
 
 

-- 
Alioth's /git/debian-med/git-commit-notice on /srv/git.debian.org/git/debian-med/aghermann.git



More information about the debian-med-commit mailing list