[med-svn] [SCM] aghermann branch, master, updated. 3603e7ef1289f9ec79a3eb415b6d141166e9498a
Andrei Zavada
johnhommer at gmail.com
Sun Jul 14 22:28:24 UTC 2013
The following commit has been merged in the master branch:
commit 004d57ff90777c6630da1656b2277d34c530f7cc
Author: Andrei Zavada <johnhommer at gmail.com>
Date: Mon Jul 15 01:14:39 2013 +0300
properly rename metrics::pages() to steps(), correctly compute steps()
diff --git a/src/aghermann/ui/sf/channel.cc b/src/aghermann/ui/sf/channel.cc
index e15cd0d..154c580 100644
--- a/src/aghermann/ui/sf/channel.cc
+++ b/src/aghermann/ui/sf/channel.cc
@@ -227,7 +227,7 @@ get_psd_in_bands()
{
crecording.psd_profile.compute();
if ( resample_power ) {
- auto xi = vector<size_t> (crecording.psd_profile.pages());
+ auto xi = vector<size_t> (crecording.psd_profile.steps());
for ( size_t i = 0; i < xi.size(); ++i )
xi[i] = i;
for ( size_t b = 0; b <= psd.uppermost_band; ++b ) {
diff --git a/src/libmetrics/mc.cc b/src/libmetrics/mc.cc
index edf2031..82b3fed 100644
--- a/src/libmetrics/mc.cc
+++ b/src/libmetrics/mc.cc
@@ -75,7 +75,7 @@ int
metrics::mc::CProfile::
go_compute()
{
- _data.resize( pages() * _bins);
+ _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(
@@ -87,7 +87,7 @@ go_compute()
Pp.bandwidth);
auto suss = su_ss.first - su_ss.second; // make it positive
- for ( size_t p = 0; p < pages(); ++p )
+ for ( size_t p = 0; p < steps(); ++p )
nmth_bin(p, b) =
agh::alg::value_within( suss[p], (TFloat)0., (TFloat)INFINITY);
}
@@ -124,12 +124,12 @@ export_tsv( const string& fname) const
_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(),
- pages(), Pp.pagesize, Pp.step, Pp.freq_from, Pp.freq_from + Pp.bandwidth * bins(), Pp.bandwidth);
+ 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 < pages(); ++p ) {
+ for ( p = 0; p < steps(); ++p ) {
fprintf( f, "%zu", p);
for ( bin = 0; bin < _bins; ++bin )
fprintf( f, "\t%g", nmth_bin( p, bin));
@@ -158,9 +158,9 @@ export_tsv( size_t bin,
_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(),
- pages(), Pp.pagesize, Pp.step, Pp.freq_from, Pp.freq_from + (bin+1) * Pp.bandwidth);
+ steps(), Pp.pagesize, Pp.step, Pp.freq_from, Pp.freq_from + (bin+1) * Pp.bandwidth);
- for ( size_t p = 0; p < pages(); ++p )
+ for ( size_t p = 0; p < steps(); ++p )
fprintf( f, "%zu\t%g\n", p, nmth_bin(p, bin));
fclose( f);
diff --git a/src/libmetrics/page-metrics-base.cc b/src/libmetrics/page-metrics-base.cc
index cd2ac81..6de2003 100644
--- a/src/libmetrics/page-metrics-base.cc
+++ b/src/libmetrics/page-metrics-base.cc
@@ -50,9 +50,9 @@ samplerate() const
size_t
metrics::CProfile::
-pages() const
+steps() const
{
- return _using_F().recording_time() / Pp.step;
+ return (_using_F().recording_time() - Pp.pagesize) / Pp.step;
}
@@ -187,7 +187,7 @@ mirror_back( const string& fname)
try {
if ( (fd = open( fname.c_str(), O_RDONLY)) == -1 )
throw -1;
- _data.resize( pages() * _bins);
+ _data.resize( steps() * _bins);
if ( read( fd, &_data[0], _data.size() * sizeof(TFloat))
!= (ssize_t)(_data.size() * sizeof(TFloat)) )
throw -2;
@@ -231,7 +231,7 @@ export_tsv( const string& fname) const
for ( bin = 0; bin < _bins; ++bin )
fprintf( f, "%zu%c", bin, bin+1 == _bins ? '\n' : '\t');
- for ( p = 0; p < pages(); ++p ) {
+ for ( p = 0; p < steps(); ++p ) {
fprintf( f, "%zu", p);
for ( bin = 0; bin < _bins; ++bin )
fprintf( f, "\t%g", nmth_bin( p, bin));
diff --git a/src/libmetrics/page-metrics-base.hh b/src/libmetrics/page-metrics-base.hh
index 0fffa3d..219ce0a 100644
--- a/src/libmetrics/page-metrics-base.hh
+++ b/src/libmetrics/page-metrics-base.hh
@@ -107,7 +107,7 @@ class CProfile {
return _bins;
}
- size_t pages() const;
+ size_t steps() const; // overlapping pages
size_t samplerate() const;
// accessors
@@ -136,7 +136,7 @@ class CProfile {
// in a bin
valarray<TFloat> course( size_t m) const
{
- return _data[ slice(m, pages(), _bins) ];
+ return _data[ slice(m, steps(), _bins) ];
}
valarray<TFloat> spectrum( size_t p) const
diff --git a/src/libmetrics/psd.cc b/src/libmetrics/psd.cc
index 9a1399a..ed45f6f 100644
--- a/src/libmetrics/psd.cc
+++ b/src/libmetrics/psd.cc
@@ -93,7 +93,7 @@ int
metrics::psd::CProfile::
go_compute()
{
- _data.resize( pages() * _bins);
+ _data.resize( steps() * _bins);
size_t sr = samplerate();
size_t spp = sr * Pp.pagesize,
@@ -165,7 +165,8 @@ go_compute()
W[ slice(window/2, spp-window, 1) ] = wfun( window/2, window);
}
- for ( p = 0; p < pages(); ++p ) {
+ 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];
@@ -226,12 +227,12 @@ export_tsv( const string& fname) const
_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(),
- pages(), Pp.pagesize, Pp.step, _bins*Pp.binsize, Pp.binsize);
+ 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 < pages(); ++p ) {
+ for ( p = 0; p < steps(); ++p ) {
fprintf( f, "%zu", p);
for ( bin = 0; bin < _bins; ++bin )
fprintf( f, "\t%g", nmth_bin( p, bin));
@@ -262,10 +263,10 @@ export_tsv( float from, float upto,
_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(),
- pages(), Pp.pagesize, Pp.step, from, upto);
+ steps(), Pp.pagesize, Pp.step, from, upto);
valarray<TFloat> crs = course( from, upto);
- for ( size_t p = 0; p < pages(); ++p )
+ for ( size_t p = 0; p < steps(); ++p )
fprintf( f, "%zu\t%g\n", p, crs[p]);
fclose( f);
diff --git a/src/libmetrics/psd.hh b/src/libmetrics/psd.hh
index b51bba9..76732da 100644
--- a/src/libmetrics/psd.hh
+++ b/src/libmetrics/psd.hh
@@ -146,7 +146,7 @@ class CProfile
// in a frequency range
valarray<TFloat> course( double from, double upto) const
{
- valarray<TFloat> acc (0., pages());
+ 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 )
diff --git a/src/libmetrics/swu.cc b/src/libmetrics/swu.cc
index bebd01a..a5d7969 100644
--- a/src/libmetrics/swu.cc
+++ b/src/libmetrics/swu.cc
@@ -69,12 +69,12 @@ int
metrics::swu::CProfile::
go_compute()
{
- _data.resize( pages() * _bins);
+ _data.resize( steps() * _bins);
auto dS = sigproc::derivative(
_using_F().get_signal_filtered( _using_sig_no));
- for ( size_t p = 0; p < pages(); ++p ) {
+ for ( size_t p = 0; p < steps(); ++p ) {
auto a = p * (samplerate() * Pp.step),
z = a + (samplerate() * Pp.pagesize);
auto la = a, lz = a;
@@ -131,9 +131,9 @@ export_tsv( const string& fname) const
_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(),
- pages(), Pp.pagesize, Pp.step);
+ steps(), Pp.pagesize, Pp.step);
- for ( size_t p = 0; p < pages(); ++p )
+ for ( size_t p = 0; p < steps(); ++p )
fprintf( f, "%zu\t%g\n", p, nmth_bin( p, 0));
fclose( f);
--
Sleep experiment manager
More information about the debian-med-commit
mailing list