[med-svn] [SCM] aghermann branch, master, updated. c0bd21ca8eb529ade7e0c7aad22951a308a8dc8f
Andrei Zavada
johnhommer at gmail.com
Wed May 1 00:09:46 UTC 2013
The following commit has been merged in the master branch:
commit 8c8e6a54ab3301e8ecee31cfba38994b21d3b921
Author: Andrei Zavada <johnhommer at gmail.com>
Date: Tue Apr 30 17:25:37 2013 +0300
rip out fancy CSource channel access, only leave [int]
diff --git a/src/libsigfile/Makefile.am b/src/libsigfile/Makefile.am
index 395af14..8ddffb1 100644
--- a/src/libsigfile/Makefile.am
+++ b/src/libsigfile/Makefile.am
@@ -24,7 +24,7 @@ libsigfile_la_SOURCES := \
source.cc \
source.hh \
edf.cc \
- edf.ii \
+ edf-io.cc \
edf.hh \
page.cc \
page.hh
diff --git a/src/libsigfile/edf.ii b/src/libsigfile/edf-io.cc
similarity index 81%
rename from src/libsigfile/edf.ii
rename to src/libsigfile/edf-io.cc
index 5b2bc95..80e3b95 100644
--- a/src/libsigfile/edf.ii
+++ b/src/libsigfile/edf-io.cc
@@ -1,30 +1,23 @@
/*
- * File name: libsigfile/edf.ii
+ * File name: libsigfile/edf-io.cc
* Project: Aghermann
* Author: Andrei Zavada <johnhommer at gmail.com>
* Initial version: 2011-11-21
*
- * Purpose: CEDFFile (big) templated methods
+ * Purpose: CEDFFile bulk data io
*
* License: GPL
*/
+#include "edf.hh"
-extern template valarray<TFloat> CEDFFile::get_region_original_( const int&, size_t, size_t) const;
-extern template valarray<TFloat> CEDFFile::get_region_original_( const SChannel&, size_t, size_t) const;
-extern template valarray<TFloat> CEDFFile::get_region_filtered_( const int&, size_t, size_t) const;
-extern template valarray<TFloat> CEDFFile::get_region_filtered_( const SChannel&, size_t, size_t) const;
-extern template int CEDFFile::put_region_( const int&, const valarray<TFloat>&, size_t) const;
-extern template int CEDFFile::put_region_( const SChannel&, const valarray<TFloat>&, size_t) const;
-extern template int CEDFFile::export_original_( const int&, const string&) const;
-extern template int CEDFFile::export_original_( const SChannel&, const string&) const;
+using namespace std;
+using sigfile::CEDFFile;
-
-template <typename A>
valarray<TFloat>
CEDFFile::
-get_region_original_( const A& h,
- const size_t sa, const size_t sz) const
+get_region_original( const int h,
+ const size_t sa, const size_t sz) const
{
if ( unlikely (_status & (TStatus::bad_header | TStatus::bad_version)) )
throw invalid_argument("CEDFFile::get_region_original(): broken source");
@@ -65,11 +58,10 @@ get_region_original_( const A& h,
-template <typename Th>
valarray<TFloat>
CEDFFile::
-get_region_filtered_( const Th& h,
- const size_t smpla, const size_t smplz) const
+get_region_filtered( const int h,
+ const size_t smpla, const size_t smplz) const
{
valarray<TFloat> recp =
get_region_original( h, smpla, smplz);
@@ -160,12 +152,11 @@ get_region_filtered_( const Th& h,
-template <typename A>
int
CEDFFile::
-put_region_( const A& h,
- const valarray<TFloat>& src,
- const size_t offset) const
+put_region( const int h,
+ const valarray<TFloat>& src,
+ const size_t offset) const
{
if ( unlikely (_status & (TStatus::bad_header | TStatus::bad_version)) )
throw invalid_argument("CEDFFile::put_region_(): broken source");
@@ -212,21 +203,19 @@ put_region_( const A& h,
-template <typename Th>
int
CEDFFile::
-put_signal_( const Th& h,
- const valarray<TFloat>& src) const
+put_signal( const int h,
+ const valarray<TFloat>& src) const
{
- return put_region_( h, src, (size_t)0);
+ return put_region( h, src, (size_t)0);
}
-template <typename Th>
int
CEDFFile::
-export_original_( const Th& h,
- const string& fname) const
+export_original( const int h,
+ const string& fname) const
{
valarray<TFloat> signal = get_signal_original( h);
FILE *fd = fopen( fname.c_str(), "w");
@@ -240,11 +229,10 @@ export_original_( const Th& h,
}
-template <typename Th>
int
CEDFFile::
-export_filtered_( const Th& h,
- const string& fname) const
+export_filtered( const int h,
+ const string& fname) const
{
valarray<TFloat> signal = get_signal_filtered( h);
FILE *fd = fopen( fname.c_str(), "w");
diff --git a/src/libsigfile/edf.cc b/src/libsigfile/edf.cc
index d1f7f5d..2add6ca 100644
--- a/src/libsigfile/edf.cc
+++ b/src/libsigfile/edf.cc
@@ -38,15 +38,6 @@ using agh::str::tokens_trimmed;
using sigfile::CEDFFile;
-template valarray<TFloat> CEDFFile::get_region_original_( const int&, size_t, size_t) const;
-template valarray<TFloat> CEDFFile::get_region_original_( const SChannel&, size_t, size_t) const;
-template valarray<TFloat> CEDFFile::get_region_filtered_( const int&, size_t, size_t) const;
-template valarray<TFloat> CEDFFile::get_region_filtered_( const SChannel&, size_t, size_t) const;
-template int CEDFFile::put_region_( const int&, const valarray<TFloat>&, size_t) const;
-template int CEDFFile::put_region_( const SChannel&, const valarray<TFloat>&, size_t) const;
-template int CEDFFile::export_original_( const int&, const string&) const;
-template int CEDFFile::export_original_( const SChannel&, const string&) const;
-
int
CEDFFile::
set_patient_id( const string& s)
diff --git a/src/libsigfile/edf.hh b/src/libsigfile/edf.hh
index 904549d..6c1e0de 100644
--- a/src/libsigfile/edf.hh
+++ b/src/libsigfile/edf.hh
@@ -150,36 +150,22 @@ class CEDFFile
return -1;
}
const SChannel&
- channel_by_id( int h) const
- {
- return channels[h].ucd; // throws
- }
+ channel_by_id( const int h) const
+ { return channels[h].ucd; }
SChannel::TType
- signal_type( int h) const
- { return (*this)[h].ucd.type(); }
- SChannel::TType
- signal_type( const SChannel& h) const
+ signal_type( const int h) const
{ return (*this)[h].ucd.type(); }
size_t
- samplerate( int h) const
- { return (*this)[h].samples_per_record / data_record_size; }
- size_t
- samplerate( const SChannel& h) const
+ samplerate( const int h) const
{ return (*this)[h].samples_per_record / data_record_size; }
list<SAnnotation>&
- annotations( int h)
- { return (*this)[h].annotations; }
- list<SAnnotation>&
- annotations( const SChannel& h)
- { return (*this)[h].annotations; }
- const list<SAnnotation>&
- annotations( int h) const
+ annotations( const int h)
{ return (*this)[h].annotations; }
const list<SAnnotation>&
- annotations( const SChannel& h) const
+ annotations( const int h) const
{ return (*this)[h].annotations; }
list<SAnnotation>&
@@ -193,174 +179,85 @@ class CEDFFile
SArtifacts&
artifacts( int h)
{ return (*this)[h].artifacts; }
- SArtifacts&
- artifacts( const SChannel& h)
- { return (*this)[h].artifacts; }
const SArtifacts&
artifacts( int h) const
{ return (*this)[h].artifacts; }
- const SArtifacts&
- artifacts( const SChannel& h) const
- { return (*this)[h].artifacts; }
// filters
SFilterPack&
- filters( int h)
- { return (*this)[h].filters; }
- SFilterPack&
- filters( const SChannel& h)
+ filters( const int h)
{ return (*this)[h].filters; }
const SFilterPack&
- filters( int h) const
- { return (*this)[h].filters; }
- const SFilterPack&
- filters( const SChannel& h) const
+ filters( const int h) const
{ return (*this)[h].filters; }
// signal data extractors
- template <class Th> // accommodates int or const SChannel& as Th
- valarray<TFloat>
- get_region_original_( const Th& h, size_t smpla, size_t smplz) const;
valarray<TFloat>
- get_region_original( const int& h, size_t smpla, size_t smplz) const
- { return get_region_original_( h, smpla, smplz); }
+ get_region_original( int h, size_t smpla, size_t smplz) const;
valarray<TFloat>
- get_region_original( const SChannel& h, size_t smpla, size_t smplz) const
- { return get_region_original_( h, smpla, smplz); }
-
- template <class Th>
- valarray<TFloat>
- get_region_original_( const Th& h,
- float timea, float timez) const
+ get_region_original( const int h,
+ const float timea, const float timez) const
{
size_t sr = samplerate(h);
- return get_region_original_(
+ return get_region_original(
h, (size_t)(timea * sr), (size_t)(timez * sr));
}
- valarray<TFloat>
- get_region_original( const int& h,
- float timea, float timez) const
- { return get_region_original_( h, timea, timez); }
- valarray<TFloat>
- get_region_original( const SChannel& h,
- float timea, float timez) const
- { return get_region_original_( h, timea, timez); }
- template <class Th>
valarray<TFloat>
- get_signal_original_( const Th& h) const
- { return get_region_original_(
+ get_signal_original( const int h) const
+ { return get_region_original(
h, 0, n_data_records * (*this)[h].samples_per_record); }
- valarray<TFloat>
- get_signal_original( const int& h) const
- { return get_signal_original_( h); }
- valarray<TFloat>
- get_signal_original( const SChannel& h) const
- { return get_signal_original_( h); }
- template <class Th>
- valarray<TFloat>
- get_region_filtered_( const Th& h,
- size_t smpla, size_t smplz) const;
valarray<TFloat>
- get_region_filtered( const int& h,
- size_t smpla, size_t smplz) const
- { return get_region_filtered_( h, smpla, smplz); }
- valarray<TFloat>
- get_region_filtered( const SChannel& h,
- size_t smpla, size_t smplz) const
- { return get_region_filtered_( h, smpla, smplz); }
+ get_region_filtered( int h,
+ size_t smpla, size_t smplz) const;
- template <class Th>
valarray<TFloat>
- get_region_filtered_( const Th& h,
- float timea, float timez) const
+ get_region_filtered( const int h,
+ float timea, float timez) const
{
size_t sr = samplerate(h);
- return get_region_filtered_(
+ return get_region_filtered(
h, (size_t)(timea * sr), (size_t)(timez * sr));
}
valarray<TFloat>
- get_region_filtered( const int& h,
- float timea, float timez) const
- { return get_region_filtered_( h, timea, timez); }
- valarray<TFloat>
- get_region_filtered( const SChannel& h,
- float timea, float timez) const
- { return get_region_filtered_( h, timea, timez); }
- template <class Th>
- valarray<TFloat>
- get_signal_filtered_( const Th& h) const
- { return get_region_filtered_(
+ get_signal_filtered( const int h) const
+ { return get_region_filtered(
h, 0, n_data_records * (*this)[h].samples_per_record); }
// put signal
- template <class Th>
- int
- put_region_( const Th& h, const valarray<TFloat>& src, size_t offset) const;
- int
- put_region( const int& h, const valarray<TFloat>& src, size_t offset) const
- { return put_region_( h, src, offset); }
- int
- put_region( const SChannel& h, const valarray<TFloat>& src, size_t offset) const
- { return put_region_( h, src, offset); }
-
- template <class Th>
- int
- put_region_( const Th& h, const valarray<TFloat>& src, float offset) const
- { return put_region_( h, src, (size_t)(offset * samplerate(h))); }
int
- put_region( const int& h, const valarray<TFloat>& src, float offset) const
- { return put_region_( h, src, offset); }
+ put_region( int h, const valarray<TFloat>& src, size_t offset) const;
int
- put_region( const SChannel& h, const valarray<TFloat>& src, float offset) const
- { return put_region_( h, src, offset); }
+ put_region( const int h, const valarray<TFloat>& src, float offset) const
+ { return put_region( h, src, (size_t)(offset * samplerate(h))); }
- template <class Th>
- int
- put_signal_( const Th& h, const valarray<TFloat>& src) const;
int
- put_signal( const int& h, const valarray<TFloat>& src) const
- { return put_signal_( h, src); }
- int
- put_signal( const SChannel& h, const valarray<TFloat>& src) const
- { return put_signal_( h, src); }
+ put_signal( int h, const valarray<TFloat>& src) const;
// signal data info
pair<TFloat, TFloat>
- get_real_original_signal_range( const SChannel& h) const
- { return get_real_original_signal_range( channel_id(h)); }
- pair<TFloat, TFloat>
- get_real_original_signal_range( const int& h) const
+ 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 SChannel& h) const
- { return get_max_original_signal_range( channel_id(h)); }
- pair<TFloat, TFloat>
- get_max_original_signal_range( const int& h) const
+ 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 SChannel& h) const
- { return get_real_filtered_signal_range( channel_id(h)); }
- pair<TFloat, TFloat>
- get_real_filtered_signal_range( const int& h) const
+ 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 SChannel& h) const
- { return get_max_filtered_signal_range( channel_id(h)); }
- pair<TFloat, TFloat>
- get_max_filtered_signal_range( const int& h) const
+ get_max_filtered_signal_range( const int h) const
{
auto x = get_signal_filtered( h);
return {x.min(), x.max()}; // an approximate
@@ -372,21 +269,14 @@ class CEDFFile
// export
int
- export_original( const int& h, const string& fname) const
- { return export_original_( h, fname); }
+ export_original( int h, const string& fname) const;
int
- export_filtered( const int& h, const string& fname) const
- { return export_filtered_( h, fname); }
+ export_filtered( int h, const string& fname) const;
+
int
- export_original( const SChannel& h, const string& fname) const
- { return export_original_( h, fname); }
+ export_original_( int h, const string& fname) const;
int
- export_filtered( const SChannel& h, const string& fname) const
- { return export_filtered_( h, fname); }
- template <class Th>
- int export_original_( const Th& h, const string& fname) const;
- template <class Th>
- int export_filtered_( const Th& h, const string& fname) const;
+ export_filtered_( int h, const string& fname) const;
// reporting & misc
@@ -572,10 +462,6 @@ class CEDFFile
};
-
-
-#include "edf.ii"
-
} // namespace sigfile
diff --git a/src/libsigfile/source-base.hh b/src/libsigfile/source-base.hh
index f9d5464..d761b96 100644
--- a/src/libsigfile/source-base.hh
+++ b/src/libsigfile/source-base.hh
@@ -241,20 +241,13 @@ class CSource {
virtual int channel_id( const SChannel&) const = 0;
virtual const SChannel& channel_by_id( int) const = 0;
virtual SChannel::TType
- signal_type( const SChannel&) const = 0;
- virtual SChannel::TType
signal_type( int) const = 0;
- virtual size_t samplerate( const SChannel&) const = 0;
virtual size_t samplerate( int) const = 0;
// the following methods are pass-through:
// 1. annotations
// (a) per-channel
virtual list<SAnnotation>&
- annotations( const SChannel&) = 0;
- virtual const list<SAnnotation>&
- annotations( const SChannel&) const = 0;
- virtual list<SAnnotation>&
annotations( int) = 0;
virtual const list<SAnnotation>&
annotations( int) const = 0;
@@ -267,22 +260,14 @@ class CSource {
// artifacts
virtual SArtifacts&
- artifacts( const SChannel&) = 0;
- virtual SArtifacts&
artifacts( int) = 0;
virtual const SArtifacts&
- artifacts( const SChannel&) const = 0;
- virtual const SArtifacts&
artifacts( int) const = 0;
// filters
virtual SFilterPack&
- filters( const SChannel&) = 0;
- virtual SFilterPack&
filters( int) = 0;
virtual const SFilterPack&
- filters( const SChannel&) const = 0;
- virtual const SFilterPack&
filters( int) const = 0;
template <typename T>
@@ -303,15 +288,12 @@ class CSource {
// get samples
// original
virtual valarray<TFloat>
- get_region_original( const SChannel&, size_t, size_t) const = 0;
- virtual valarray<TFloat>
- get_region_original( const int&, size_t, size_t) const = 0;
+ get_region_original( int, size_t, size_t) const = 0;
- template <typename T>
valarray<TFloat>
- get_region_original( const T& h,
- float seconds_off_start,
- float seconds_off_end) const
+ get_region_original( const int h,
+ const float seconds_off_start,
+ const float seconds_off_end) const
{
size_t sr = samplerate(h);
return get_region_original(
@@ -320,9 +302,8 @@ class CSource {
seconds_off_end * sr);
}
- template <typename T>
valarray<TFloat>
- get_signal_original( const T& h) const
+ get_signal_original( const int h) const
{
return get_region_original(
h,
@@ -331,15 +312,12 @@ class CSource {
// filtered
virtual valarray<TFloat>
- get_region_filtered( const SChannel& h, size_t, size_t) const = 0;
- virtual valarray<TFloat>
- get_region_filtered( const int& h, size_t, size_t) const = 0;
+ get_region_filtered( int h, size_t, size_t) const = 0;
- template <typename T>
valarray<TFloat>
- get_region_filtered( const T& h,
- float seconds_off_start,
- float seconds_off_end) const
+ get_region_filtered( const int h,
+ const float seconds_off_start,
+ const float seconds_off_end) const
{
size_t sr = samplerate(h);
return get_region_filtered(
@@ -348,9 +326,8 @@ class CSource {
seconds_off_end * sr);
}
- template <typename T>
valarray<TFloat>
- get_signal_filtered( const T& h) const
+ get_signal_filtered( const int h) const
{
return get_region_filtered(
h,
@@ -359,69 +336,35 @@ class CSource {
// put samples
virtual int
- put_region( const int& h,
- const valarray<TFloat>& src,
- size_t offset) const = 0;
- virtual int
- put_region( const SChannel& h,
+ put_region( int h,
const valarray<TFloat>& src,
size_t offset) const = 0;
int
- put_signal( const int& h,
- const valarray<TFloat>& src)
- {
- return put_region( h, src, 0);
- }
- int
- put_signal( const SChannel& h,
+ put_signal( int h,
const valarray<TFloat>& src)
{
return put_region( h, src, 0);
}
// signal data info
- template <typename T>
- pair<TFloat, TFloat>
- get_real_original_signal_range( const T& h) const;
virtual pair<TFloat, TFloat>
- get_real_original_signal_range( const int&) const = 0;
- virtual pair<TFloat, TFloat>
- get_real_original_signal_range( const SChannel&) const = 0;
+ get_real_original_signal_range( int) const = 0;
- template <typename T>
- pair<TFloat, TFloat>
- get_max_original_signal_range( const T& h) const;
virtual pair<TFloat, TFloat>
- get_max_original_signal_range( const int&) const = 0;
- virtual pair<TFloat, TFloat>
- get_max_original_signal_range( const SChannel&) const = 0;
+ get_max_original_signal_range( int) const = 0;
- template <typename T>
- pair<TFloat, TFloat>
- get_real_filtered_signal_range( const T& h) const;
virtual pair<TFloat, TFloat>
- get_real_filtered_signal_range( const int&) const = 0;
- virtual pair<TFloat, TFloat>
- get_real_filtered_signal_range( const SChannel&) const = 0;
+ get_real_filtered_signal_range( int) const = 0;
- template <typename T>
- pair<TFloat, TFloat>
- get_max_filtered_signal_range( const T& h) const;
virtual pair<TFloat, TFloat>
- get_max_filtered_signal_range( const int&) const = 0;
- virtual pair<TFloat, TFloat>
- get_max_filtered_signal_range( const SChannel&) const = 0;
+ get_max_filtered_signal_range( int) const = 0;
// export
virtual int
- export_original( const int&, const string& fname) const = 0;
- virtual int
- export_original( const SChannel&, const string& fname) const = 0;
+ export_original( int, const string& fname) const = 0;
virtual int
- export_filtered( const int&, const string& fname) const = 0;
- virtual int
- export_filtered( const SChannel&, const string& fname) const = 0;
+ export_filtered( int, const string& fname) const = 0;
// filenames
string make_fname_artifacts( const SChannel& channel) const
@@ -439,7 +382,6 @@ class CSource {
-
} // namespace sigfile
#endif // _SIGFILE_SOURCE_BASE_H
diff --git a/src/ui/mw/mainmenu_cb.cc b/src/ui/mw/mainmenu_cb.cc
index 1a4ea99..5137a77 100644
--- a/src/ui/mw/mainmenu_cb.cc
+++ b/src/ui/mw/mainmenu_cb.cc
@@ -286,7 +286,7 @@ iExpGloballyDetectArtifacts_activate_cb(
{
auto& F = R.F();
for ( auto& H : F.channel_list() ) {
- auto& af = F.artifacts(H);
+ auto& af = F.artifacts(F.channel_id(H));
af.clear_all();
}
};
@@ -363,7 +363,7 @@ iExpGloballySetFilters_activate_cb(
for ( auto &E : D.second.episodes )
for ( auto &F : E.sources )
for ( auto &H : F().channel_list() ) {
- auto& ff = F().filters(H);
+ auto& ff = F().filters(F().channel_id(H));
ff.low_pass_cutoff = LPC;
ff.low_pass_order = LPO;
ff.high_pass_cutoff = HPC;
diff --git a/src/ui/sf/channel.cc b/src/ui/sf/channel.cc
index e4ecbc3..a443a46 100644
--- a/src/ui/sf/channel.cc
+++ b/src/ui/sf/channel.cc
@@ -35,9 +35,9 @@ SChannel (agh::CRecording& r,
: name (r.channel()),
crecording (r),
_h (r.F().channel_id(name)),
- filters (r.F().filters(name)),
- annotations (r.F().annotations(name)),
- artifacts (r.F().artifacts(name)),
+ filters (r.F().filters( _h)),
+ annotations (r.F().annotations(_h)),
+ artifacts (r.F().artifacts(_h)),
_p (parent),
signal_lowpass ({signal_filtered, samplerate()}),
signal_bandpass ({signal_filtered, samplerate()}),
diff --git a/src/ui/sf/ica.cc b/src/ui/sf/ica.cc
index 054d36f..49cb581 100644
--- a/src/ui/sf/ica.cc
+++ b/src/ui/sf/ica.cc
@@ -72,7 +72,7 @@ setup_ica()
checking_total_samples = this_ts;
src.emplace_back(
- bind (&sigfile::CSource::get_signal_original<int>, &H.crecording.F(), H.h()));
+ bind (&sigfile::CSource::get_signal_original, &H.crecording.F(), H.h()));
}
ica = new ica::CFastICA (src, channels.front().crecording.total_samples());
diff --git a/src/ui/sf/montage.cc b/src/ui/sf/montage.cc
index f796a1e..af1bd39 100644
--- a/src/ui/sf/montage.cc
+++ b/src/ui/sf/montage.cc
@@ -447,7 +447,7 @@ draw_page( cairo_t *cr,
evpz = cvpe - cvpa;
// artifacts (changed bg)
{
- auto& Aa = crecording.F().artifacts(name);
+ auto& Aa = crecording.F().artifacts(crecording.h());
if ( not Aa.obj.empty() ) {
_p._p.CwB[SExpDesignUI::TColour::sf_artifact].set_source_rgba(
cr, .4); // do some gradients perhaps?
diff --git a/src/ui/sf/montage_cb.cc b/src/ui/sf/montage_cb.cc
index 63a9a3b..ce054ce 100644
--- a/src/ui/sf/montage_cb.cc
+++ b/src/ui/sf/montage_cb.cc
@@ -856,7 +856,7 @@ iSFPageExportSignal_activate_cb(
auto& r = SF.using_channel->crecording;
string fname_base = r.F().filename();
snprintf_buf( "%s-filt.tsv", fname_base.c_str());
- r.F().export_filtered( SF.using_channel->name, __buf__);
+ r.F().export_filtered( SF.using_channel->h(), __buf__);
snprintf_buf( "%s-orig.tsv", fname_base.c_str());
r.F().export_original( SF.using_channel->h(), __buf__);
snprintf_buf( "Wrote \"%s-{filt,orig}.tsv\"",
--
Sleep experiment manager
More information about the debian-med-commit
mailing list