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

Andrei Zavada johnhommer at gmail.com
Sun Jul 7 23:03:59 UTC 2013


The following commit has been merged in the master branch:
commit 60cd3d4ff7c9d04374d83ebe7f78187467ce6492
Author: Andrei Zavada <johnhommer at gmail.com>
Date:   Fri Jun 21 01:42:11 2013 +0300

    WIP (make pagesize double; increment profile computations in steps)

diff --git a/src/aghermann/expdesign/primaries.cc b/src/aghermann/expdesign/primaries.cc
index 1a75b7c..1990ba0 100644
--- a/src/aghermann/expdesign/primaries.cc
+++ b/src/aghermann/expdesign/primaries.cc
@@ -62,6 +62,7 @@ CExpDesign (const string& session_dir_,
 		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.)),
@@ -83,7 +84,6 @@ CExpDesign (const string& session_dir_,
 		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>("fft_param.pagesize",	&fft_params.pagesize,				SValidator<size_t>::SVFRangeIn( 4, 120)),
 		SValidator<size_t>("mc_param.smooth_side",	&mc_params.smooth_side,				SValidator<size_t>::SVFRangeIn( 0, 5)),
 	}),
 	config_keys_b ({
diff --git a/src/aghermann/expdesign/tree-scanner.cc b/src/aghermann/expdesign/tree-scanner.cc
index b1994b8..4468c30 100644
--- a/src/aghermann/expdesign/tree-scanner.cc
+++ b/src/aghermann/expdesign/tree-scanner.cc
@@ -275,7 +275,7 @@ edf_file_processor( const char *fname, const struct stat*, int flag, struct FTW
 			only_progress_fun( fname, agh::fs::__n_edf_files, __cur_edf_file);
 			try {
 				using namespace sigfile;
-				CTypedSource F {fname, __expdesign->fft_params.pagesize};
+				CTypedSource F {fname, (size_t)roundf(__expdesign->fft_params.pagesize)};
 				string st = F().explain_status();
 				if ( not st.empty() )
 					__expdesign->log_message( "In %s:\n%s\n", fname, st.c_str());
diff --git a/src/aghermann/ui/mw/populate.cc b/src/aghermann/ui/mw/populate.cc
index b239754..9428f51 100644
--- a/src/aghermann/ui/mw/populate.cc
+++ b/src/aghermann/ui/mw/populate.cc
@@ -548,7 +548,7 @@ populate_1()
 
 	gtk_label_set_markup(
 		lMsmtProfilePSDExtra,
-		snprintf_buf( "<small>%zusec/%gHz/%s</small>",
+		snprintf_buf( "<small>%gsec/%gHz/%s</small>",
 			      ED->fft_params.pagesize,
 			      ED->fft_params.binsize,
 			      sigproc::welch_window_type_names[ED->fft_params.welch_window_type]));
diff --git a/src/aghermann/ui/sf/channel.cc b/src/aghermann/ui/sf/channel.cc
index 0e27f77..9ba2926 100644
--- a/src/aghermann/ui/sf/channel.cc
+++ b/src/aghermann/ui/sf/channel.cc
@@ -615,7 +615,9 @@ _put_selection()
 		auto sssu =
 			metrics::mc::do_sssu_reduction(
 				valarray<TFloat> {signal_filtered[ slice (selection_start, (selection_end - selection_start), 1) ]},
-				samplerate(), (selection_end - selection_start) / samplerate(),
+				samplerate(),
+				(selection_end - selection_start) / samplerate(),
+				(selection_end - selection_start) / samplerate(),
 				P.mc_gain, P.iir_backpolate,
 				P.f0, P.fc, P.bandwidth);
 		selection_SS = sssu.first[0];
diff --git a/src/libmetrics/mc-artifacts.ii b/src/libmetrics/mc-artifacts.ii
index 237dee1..f35ee38 100644
--- a/src/libmetrics/mc-artifacts.ii
+++ b/src/libmetrics/mc-artifacts.ii
@@ -21,7 +21,7 @@ detect_artifacts( const valarray<T>& signal, size_t sr,
 	auto	sssu
 		= do_sssu_reduction(
 			signal,
-			sr, P.scope,
+			sr, P.scope, P.scope,
 			P.mc_gain, P.iir_backpolate,
 			P.f0, P.fc, P.bandwidth);
 	valarray<T>
diff --git a/src/libmetrics/mc.cc b/src/libmetrics/mc.cc
index ee46e95..2324c8a 100644
--- a/src/libmetrics/mc.cc
+++ b/src/libmetrics/mc.cc
@@ -26,7 +26,7 @@ metrics::mc::CProfile::
 CProfile (const sigfile::CTypedSource& F, const int sig_no,
 	  const SPPack &params)
       : metrics::CProfile (F, sig_no,
-			   params.pagesize, pagesize.step,
+			   params.pagesize, params.step,
 			   params.compute_n_bins(F().samplerate(sig_no))),
 	Pp (params)
 	// *_filter's initialized at compute time
@@ -80,18 +80,16 @@ go_compute()
 	for ( size_t b = 0; b < bins(); ++b ) {
 		auto su_ss = metrics::mc::do_sssu_reduction(
 			S, samplerate(),
-			Pp.scope,
+			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
-		// collapse into our pages
-		for ( size_t p = 0; p < pages(); ++p ) {
-			auto range = slice (p * Pp.scope, Pp.pagesize/Pp.scope, 1);
+
+		for ( size_t p = 0; p < pages(); ++p )
 			nmth_bin(p, b) =
-				agh::alg::value_within( suss[range].sum(), (TFloat)0., (TFloat)INFINITY);
-		}
+				agh::alg::value_within( suss[p], (TFloat)0., (TFloat)INFINITY);
 	}
 
 	return 0;
@@ -175,7 +173,7 @@ template
 pair<valarray<TFloat>, valarray<TFloat>>
 metrics::mc::
 do_sssu_reduction( const valarray<TFloat>&,
-		   size_t, double, double, double,
+		   size_t, double, double, double, double,
 		   double, double, double);
 
 const size_t sssu_hist_size = 100;
diff --git a/src/libmetrics/mc.hh b/src/libmetrics/mc.hh
index 35e123c..4739d43 100644
--- a/src/libmetrics/mc.hh
+++ b/src/libmetrics/mc.hh
@@ -154,7 +154,7 @@ class CProfile
 template <typename T>
 pair<valarray<T>, valarray<T>>
 do_sssu_reduction( const valarray<T>&,
-		   size_t, double, double, double,
+		   size_t, double, double, double, double,
 		   double, double, double);
 
 extern const size_t sssu_hist_size;
@@ -162,13 +162,14 @@ 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,
+		   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,
+		   size_t samplerate,
+		   double scope, double inc,
 		   double mc_gain, double iir_backpolate,
 		   double f0, double fc,
 		   double bandwidth)
@@ -183,8 +184,9 @@ do_sssu_reduction( const valarray<T>& S,
 			   f0, fc,
 			   bandwidth);
 
-	size_t	integrate_samples = scope * samplerate,
-		lpages = S.size() / integrate_samples;
+	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);
@@ -193,13 +195,13 @@ do_sssu_reduction( const valarray<T>& S,
 		ss (lpages),
 		su (lpages);
 	for ( size_t p = 0; p < lpages; ++p ) {
-		auto range = slice (p * integrate_samples, integrate_samples, 1);
+		auto range = slice (p * inc_samples, scope_samples, 1);
 		su[p] =
 			(valarray<T> {due_filtered[range]} * valarray<T> {se_filtered[range]})
-			.sum() / integrate_samples;
+			.sum() / scope_samples;
 		ss[p] =
 			pow(valarray<T> {se_filtered[range]}, (T)2.)
-			.sum() / samplerate / integrate_samples;
+			.sum() / samplerate / scope_samples;
 	}
 
 	return {su, ss};
diff --git a/src/libmetrics/psd.hh b/src/libmetrics/psd.hh
index 0d1c15c..a7a3189 100644
--- a/src/libmetrics/psd.hh
+++ b/src/libmetrics/psd.hh
@@ -93,24 +93,29 @@ struct SPPack
 
 	void check() const
 		{
+			metrics::SPPack::check();
+
+			if ( welch_window_type > sigproc::TWinType::TWinType_total )
 #ifdef _OPENMP
 #pragma omp single
 #endif
-			{
-				metrics::SPPack::check();
+				throw invalid_argument ("Invalid window type");
 
-				if ( welch_window_type > sigproc::TWinType::TWinType_total )
-					throw invalid_argument ("Invalid window type");
+			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");
 
-				if ( plan_type != metrics::psd::TFFTWPlanType::estimate &&
-				     plan_type != metrics::psd::TFFTWPlanType::measure )
-					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;
-				throw invalid_argument ("Invalid binsize");
-			}
+#ifdef _OPENMP
+#pragma omp single
+#endif
+			throw invalid_argument ("Invalid binsize");
 		}
 
 	void reset()
diff --git a/src/libmetrics/swu.cc b/src/libmetrics/swu.cc
index eb5d267..1883603 100644
--- a/src/libmetrics/swu.cc
+++ b/src/libmetrics/swu.cc
@@ -60,7 +60,7 @@ mirror_fname() const
 		  agh::fs::make_fname_base (_using_F().filename(), "", true).c_str(),
 		  _using_F().channel_by_id(_using_sig_no).name(),
 		  _using_F().dirty_signature( _using_sig_no),
-		  Pp.pagesize, p.step, Pp.min_upswing_duration,
+		  Pp.pagesize, Pp.step, Pp.min_upswing_duration,
 		  sizeof(TFloat));
 }
 

-- 
Sleep experiment manager



More information about the debian-med-commit mailing list