The following commit has been merged in the master branch:
commit 72d1a3255ced25be0f485990217e6471417ffb30
Author: Andrei Zavada <[email protected]>
Date:   Thu Dec 20 14:34:06 2012 +0200

    edfcat: determine from input data and set physical_min/max fields

diff --git a/ChangeLog b/ChangeLog
index daa4acd..fc3cd99 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,8 @@
-v.0.7.6 (2012-12-xx)
+v.0.7.6 (2012-12-20)
        * Don't forget to save some .expdesign.conf settings.
        * Purge cached profiles on version upgrade.
+       * Correctly set OMP max threads.
+       * edfcat conv: set physical_min/max.
 
 v.0.7.5.1 (2012-12-04)
        * Fix Ububtu build.
diff --git a/data/dialogs.glade b/data/dialogs.glade
index f01e4e8..e330e51 100644
--- a/data/dialogs.glade
+++ b/data/dialogs.glade
@@ -328,7 +328,7 @@
                     <property name="xalign">0</property>
                     <property name="xpad">5</property>
                     <property name="ypad">15</property>
-                    <property name="label" 
translatable="yes">&lt;b&gt;&lt;big&gt;&lt;big&gt;Aghermann 
0.7.5.1&lt;/big&gt;&lt;/big&gt;&lt;/b&gt; Bye-bye StrikeAd
+                    <property name="label" 
translatable="yes">&lt;b&gt;&lt;big&gt;&lt;big&gt;Aghermann 
0.7.6&lt;/big&gt;&lt;/big&gt;&lt;/b&gt;
 &lt;a 
href="http://johnhommer.com/academic/code/aghermann"&gt;johnhommer.com/academic/code/aghermann&lt;/a&gt;</property>
                     <property name="use_markup">True</property>
                   </object>
@@ -424,7 +424,14 @@ With bug reports, either send yours to &lt;a 
href="mailto:aghermann-users@lists.
                             <property name="yalign">0</property>
                             <property name="xpad">10</property>
                             <property name="ypad">10</property>
-                            <property name="label">&lt;big&gt;&lt;b&gt;v. 
0.7.5.1&lt;/b&gt;&lt;/big&gt; (2012-12-04)
+                            <property name="label">&lt;big&gt;&lt;b&gt;v. 
0.7.6&lt;/b&gt;&lt;/big&gt; (2012-12-20)
+&lt;span font="monospace"&gt;
+       * Don't forget to save some .expdesign.conf settings.
+       * Purge cached profiles on version upgrade.
+       * Correctly set OMP max threads.
+       * edfcat conv: set physical_min/max.
+&lt;/span&gt;
+&lt;big&gt;&lt;b&gt;v. 0.7.5.1&lt;/b&gt;&lt;/big&gt; (2012-12-04)
 &lt;span font="monospace"&gt;
        * Fix Ubuntu build.
 &lt;/span&gt;
@@ -435,10 +442,7 @@ With bug reports, either send yours to &lt;a 
href="mailto:aghermann-users@lists.
        * Fix SF Find dialog wrt search in a changed
          field channel.
 &lt;/span&gt;
-&lt;big&gt;&lt;b&gt;v. 0.7.4&lt;/b&gt;&lt;/big&gt;
-&lt;span font="monospace"&gt;
-       * PSD: don't apply windowing function twice (deeply sorry about that!).
-&lt;/span&gt;
+
 (for older entries, see &lt;a 
href="http://johnhommer.com/academic/code/aghermann"&gt;full 
changelog&lt;/a&gt;)</property>
                             <property name="use_markup">True</property>
                             <property name="wrap">True</property>
diff --git a/man/edfcat.1.in b/man/edfcat.1.in
index 2c28f37..097f978 100644
--- a/man/edfcat.1.in
+++ b/man/edfcat.1.in
@@ -14,7 +14,13 @@ samplerate), and (2) channel pruning.
 .TP
 conv \fBFILE.ascii\fR \fBSAMPLERATE\fR \fBRECORD_SIZE\fR
 Convert samples in \fBFILE.ascii\fR into \fBFILE.ascii.edf\fR.
-Multiple columns in the source file will be converted as individual channels.
+Multiple columns in the source file will be converted as individual
+channels.
+
+On success, physical_min/max in each channel will be set to the
+absolute min/max of all channel data, widened symmetrically to
+whichever boundary is farther from 0 (thus, a range of \-2:3 becomes
+\-3:3, as will \-3:2).
 .TP
 prune \fBFILE.edf\fR \fBN1[,N2,...]\fR
 Create a copy of source file (FILE-mod.edf) only keeping channels
diff --git a/src/common/alg.hh b/src/common/alg.hh
index d692698..692ce22 100644
--- a/src/common/alg.hh
+++ b/src/common/alg.hh
@@ -114,7 +114,12 @@ struct SSpan {
 
 
 
-
+template <typename T>
+int
+sign( T x)
+{
+       return (x > 0) ? 1 : (x == 0) ? 0 : -1;
+}
 
 
 template <typename T>
diff --git a/src/tools/edfcat.cc b/src/tools/edfcat.cc
index b687bd7..c3e14a0 100644
--- a/src/tools/edfcat.cc
+++ b/src/tools/edfcat.cc
@@ -261,16 +261,42 @@ out:
        double length = (double)total_samples/obj.samplerate;
        printf( "Read %zu samples (%g sec) in %zu channel(s)\n", total_samples, 
length, columns);
 
+      // determine physical min/max
+       vector<pair<double, double>> phys_ranges (columns);
+       double grand_min = INFINITY, grand_max = -INFINITY;
+       printf( "Physical min/max in channels:\n");
+       for ( i = 0; i < columns; ++i ) {
+               phys_ranges[i] = {data[i].min(), data[i].max()};
+               printf( "%zu\t%g\t%g\n",
+                       i+1, phys_ranges[i].first, phys_ranges[i].second);
+               if ( grand_min > phys_ranges[i].first )
+                       grand_min = phys_ranges[i].first;
+               if ( grand_max < phys_ranges[i].second )
+                       grand_max = phys_ranges[i].second;
+       }
+       grand_min = (grand_min < 0.) ? floor(grand_min) : ceil(grand_min); // 
away from 0
+       grand_max = (grand_max < 0.) ? floor(grand_max) : ceil(grand_max);
+       if ( agh::alg::sign(grand_max) != agh::alg::sign(grand_min) ) {
+               if ( -grand_min > grand_max )
+                       grand_max = -grand_min;
+               else
+                       grand_min = -grand_max;
+       }
+       printf( "Setting physical_min/max to %g:%g\n",
+               grand_min, grand_max);
+
        sigfile::CEDFFile F ((obj + ".edf").c_str(),
                             sigfile::CSource::no_ancillary_files,
                             make_channel_headers_for_CEDFFile( columns, 
"channel%zu", obj.samplerate),
                             obj.record_size,
                             ceilf(length / obj.record_size));
-//     F.resize( data.size() / obj.samplerate / obj.record_size);
-       for ( size_t f = 0; f < columns; ++f )
+       for ( size_t f = 0; f < columns; ++f ) {
                F.put_signal( f, valarray<TFloat> {data[f][slice (0, 
total_samples, 1)]});
+               F[f].set_physical_range( grand_min, grand_max);
+       }
+
        printf( "Created edf:\n%s\n"
-               "\nYou may now want to fill out the header of the newly created 
EDF file.\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().c_str());
 
        return 0;

-- 
Sleep experiment manager

_______________________________________________
debian-med-commit mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/debian-med-commit

Reply via email to