[med-svn] [SCM] aghermann branch, master, updated. 551e213a23b59b71cba6a9c3a282d1b60e21b854

Andrei Zavada johnhommer at gmail.com
Sun Apr 21 23:18:06 UTC 2013


The following commit has been merged in the master branch:
commit 2eb683d3a09655f75b246625221c9ae608585d8f
Author: Andrei Zavada <johnhommer at gmail.com>
Date:   Thu Apr 18 18:46:57 2013 +0300

    use time- (not sample-) based annotations instead (WIP); collect embedded annotations

diff --git a/src/common/string.hh b/src/common/string.hh
index 61d598e..144f679 100644
--- a/src/common/string.hh
+++ b/src/common/string.hh
@@ -44,6 +44,12 @@ join( const C& l, const char* sep)
 }
 
 list<string> tokens( const string& s_, const char* sep);
+inline
+list<string> tokens( const string& s_, char sep)
+{
+	return tokens( s_, string (sep, 1).c_str());
+}
+
 
 
 void decompose_double( double value, double *mantissa, int *exponent);
diff --git a/src/expdesign/primaries.hh b/src/expdesign/primaries.hh
index 85e416b..9881ee5 100644
--- a/src/expdesign/primaries.hh
+++ b/src/expdesign/primaries.hh
@@ -137,12 +137,12 @@ class CSubject : public SSubjectId {
 			}
 
 		struct SAnnotation
-		      : public sigfile::SAnnotation {
+		      : public sigfile::SAnnotation<double> {
 			const sigfile::CSource& _source;
 			int _h;
 			SAnnotation( const sigfile::CSource& _si, int _hi,
-				     const sigfile::SAnnotation& _a)
-			      : sigfile::SAnnotation (_a),
+				     const sigfile::SAnnotation<double>& _a)
+			      : sigfile::SAnnotation<double> (_a),
 				_source (_si), _h (_hi)
 				{}
 			SAnnotation( const SAnnotation&) = default;
diff --git a/src/libsigfile/channel.cc b/src/libsigfile/channel.cc
index c31d83a..bad547c 100644
--- a/src/libsigfile/channel.cc
+++ b/src/libsigfile/channel.cc
@@ -36,6 +36,7 @@ const char* sigfile::SChannel::system1020_channels[sigfile::SChannel::n_channels
 
 
 const char* sigfile::SChannel::kemp_signal_types[sigfile::SChannel::n_kemp_signal_types] = {
+	"EDF Annotations",
 	"EEG", "EOG", "EMG", "ECG", "ERG",
 	"NC",  "MEG", "MCG", "EP",
 	"Temp", "Resp", "SaO2",
diff --git a/src/libsigfile/channel.hh b/src/libsigfile/channel.hh
index dca6fc8..41ffc08 100644
--- a/src/libsigfile/channel.hh
+++ b/src/libsigfile/channel.hh
@@ -51,7 +51,7 @@ struct SChannel
 	static const size_t last_eeg_no = 74;
 	static const size_t last_eog_no = 76;
 	static const size_t last_emg_no = 77;
-	static const size_t n_kemp_signal_types = 17;
+	static const size_t n_kemp_signal_types = 18;
 	static const char* system1020_channels[n_channels];
 	static const char* kemp_signal_types[n_kemp_signal_types];
 	static bool channel_follows_system1020( const char* channel)
diff --git a/src/libsigfile/edf.cc b/src/libsigfile/edf.cc
index 07b611c..bc9ca10 100644
--- a/src/libsigfile/edf.cc
+++ b/src/libsigfile/edf.cc
@@ -216,11 +216,11 @@ CEDFFile (const string& fname_, int flags_)
 				fd >> type >> aa >> az;
 				getline( fd, an, EOA);
 				if ( aa < az and az < n_data_records * H.samples_per_record
-				     and type < SAnnotation::TType_total and type >= 0 )
+				     and type < SAnnotation<size_t>::TType_total and type >= 0 )
 					H.annotations.emplace_back(
 						aa, az,
 						trim(an),
-						(SAnnotation::TType)type);
+						(SAnnotation<double>::TType)type);
 				else {
 					fprintf( stderr, "Bad annotation: (%d %zu %zu %50s)\n", type, aa, az, an.c_str());
 					break;
@@ -844,16 +844,38 @@ _extract_embedded_annotations()
 	size_t alen = AH.samples_per_record * 2;
 
 	for ( size_t r = 0; r < n_data_records; ++r ) {
-		char* this_a =
+		char   *this_a =
 			(char*)_mmapping + header_length
 			+ r * _total_samples_per_record * 2	// full records before
 			+ AH._at;				// offset to our samples
+		string	abuf (this_a, alen); // NULL-terminated, possibly at pos <alen
+
+		time_t	record_start = _start_time + r * data_record_size;
+
+		float	offset,
+			duration;
+		const char
+		       *offset_p = abuf.c_str(),
+		       *duration_p,
+		       *tals_p;
+		while ( (tals_p = index( offset_p, 21)) ) {
+			if ( (duration = 0.,
+			      (duration_p = index( offset_p, 20))) &&
+			     duration_p < tals_p ) {
+				offset = stof( string (offset_p, duration_p - offset_p));
+				duration = stof( string (duration_p, tals_p - duration_p));
+			} else
+				offset = stof( string (offset_p, tals_p - offset_p));
+
+			auto tals = tokens( tals_p, (char)20);
+			for ( auto& t : tals )
+				common_annotations.emplace_back(
+					record_start + offset,
+					record_start + offset + duration,
+					t,
+					SAnnotation<double>::TType::plain);
+		}
 	}
-//			H.samples_per_record * 2);	// our precious ones
-
-	size_t ai = 0;
-	char *ax, *ay;
-//	while ( sscanf( abuf+ai, "%c%g\x20%g\x21", 
 
 	return 0;
 }
diff --git a/src/libsigfile/edf.hh b/src/libsigfile/edf.hh
index 9943fd1..c893aa7 100644
--- a/src/libsigfile/edf.hh
+++ b/src/libsigfile/edf.hh
@@ -171,19 +171,26 @@ class CEDFFile
 	samplerate( const string& h) const
 		{ return (*this)[h].samples_per_record / data_record_size; }
 
-	list<SAnnotation>&
+	list<SAnnotation<double>>&
 	annotations( int h)
 		{ return (*this)[h].annotations; }
-	list<SAnnotation>&
+	list<SAnnotation<double>>&
 	annotations( const string& h)
 		{ return (*this)[h].annotations; }
-	const list<SAnnotation>&
+	const list<SAnnotation<double>>&
 	annotations( int h) const
 		{ return (*this)[h].annotations; }
-	const list<SAnnotation>&
+	const list<SAnnotation<double>>&
 	annotations( const string& h) const
 		{ return (*this)[h].annotations; }
 
+	list<SAnnotation<double>>&
+	annotations()
+		{ return common_annotations; }
+	const list<SAnnotation<double>>&
+	annotations() const
+		{ return common_annotations; }
+
 	// artifacts
 	SArtifacts&
 	artifacts( int h)
@@ -446,7 +453,7 @@ class CEDFFile
 				return label == h;
 			}
 
-		list<SAnnotation>
+		list<SAnnotation<double>>
 			annotations;
 		SArtifacts
 			artifacts;
@@ -460,6 +467,9 @@ class CEDFFile
 		channels;
 	static size_t max_channels;
 
+	list<SAnnotation<double>> // timepoints in seconds
+		common_annotations;
+
       // signal accessors
 	SSignal& operator[]( size_t i)
 		{
diff --git a/src/libsigfile/source-base.hh b/src/libsigfile/source-base.hh
index e35b693..66eefca 100644
--- a/src/libsigfile/source-base.hh
+++ b/src/libsigfile/source-base.hh
@@ -72,18 +72,18 @@ struct SArtifacts {
 		dampen_window_type (dwt_)
 		{}
 
-	list<agh::alg::SSpan<size_t>>
+	list<agh::alg::SSpan<double>>
 		obj;
 	float	factor;
 	sigproc::TWinType
 		dampen_window_type;
 
-	list<agh::alg::SSpan<size_t>>&
+	list<agh::alg::SSpan<double>>&
 	operator() ()
 		{
 			return obj;
 		}
-	const list<agh::alg::SSpan<size_t>>&
+	const list<agh::alg::SSpan<double>>&
 	operator() () const
 		{
 			return obj;
@@ -113,8 +113,9 @@ struct SArtifacts {
 
 
 
+template <typename T>
 struct SAnnotation {
-	agh::alg::SSpan<size_t> span;
+	agh::alg::SSpan<T> span;
 	string label;
 	enum TType {
 		plain,
@@ -123,9 +124,9 @@ struct SAnnotation {
 		eyeblink,
 		TType_total
 	};
-	TType type;;
+	TType type;
 
-	SAnnotation( size_t aa, size_t az, const string& l, TType t = TType::plain)
+	SAnnotation( T aa, T az, const string& l, TType t = TType::plain)
 	      : span {aa, az},
 		label (l),
 		type (t)
@@ -141,11 +142,12 @@ struct SAnnotation {
 		}
 };
 
+template <typename T>
 inline void
-mark_annotation( list<SAnnotation>& annotations,
-		 size_t aa, size_t az,
+mark_annotation( list<SAnnotation<T>>& annotations,
+		 T aa, T az,
 		 const string& label,
-		 SAnnotation::TType t = SAnnotation::TType::plain)
+		 sigfile::SAnnotation<double>::TType t = SAnnotation<T>::TType::plain)
 {
 	annotations.emplace_back( aa, az, label, t);
 	annotations.sort();
@@ -250,16 +252,23 @@ class CSource {
 	virtual size_t samplerate( int)			const = 0;
 
 	// the following methods are pass-through:
-	// annotations
-	virtual list<SAnnotation>&
+	// 1. annotations
+	// (a) per-channel
+	virtual list<SAnnotation<double>>&
 	annotations( const string&)		      = 0;
-	virtual const list<SAnnotation>&
+	virtual const list<SAnnotation<double>>&
 	annotations( const string&) const	      = 0;
-	virtual list<SAnnotation>&
+	virtual list<SAnnotation<double>>&
 	annotations( int)			      = 0;
-	virtual const list<SAnnotation>&
+	virtual const list<SAnnotation<double>>&
 	annotations( int) const			      = 0;
 
+	// (b) common
+	virtual list<SAnnotation<double>>&
+	annotations()				      = 0;
+	virtual const list<SAnnotation<double>>&
+	annotations()				const = 0;
+
 	// artifacts
 	virtual SArtifacts&
 	artifacts( const string&)		      = 0;
diff --git a/src/metrics/page-metrics-base.cc b/src/metrics/page-metrics-base.cc
index 082bfb8..cd949b3 100644
--- a/src/metrics/page-metrics-base.cc
+++ b/src/metrics/page-metrics-base.cc
@@ -80,20 +80,19 @@ list<agh::alg::SSpan<size_t>>
 metrics::CProfile::
 artifacts_in_samples() const
 {
-	return _using_F().artifacts( _using_sig_no)();
+	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;
 }
 
 
-list<agh::alg::SSpan<float>>
+list<agh::alg::SSpan<double>>
 metrics::CProfile::
 artifacts_in_seconds() const
 {
-	list<agh::alg::SSpan<float>> ret;
-	auto af_ = artifacts_in_samples();
-	size_t sr = _using_F().samplerate(_using_sig_no);
-	for ( auto &A : af_ )
-		ret.emplace_back( A.a / (float)sr, A.z / (float)sr);
-	return ret;
+	return _using_F().artifacts( _using_sig_no)();
 }
 
 
diff --git a/src/metrics/page-metrics-base.hh b/src/metrics/page-metrics-base.hh
index 2a315d8..c63341f 100644
--- a/src/metrics/page-metrics-base.hh
+++ b/src/metrics/page-metrics-base.hh
@@ -146,7 +146,7 @@ class CProfile {
     public:
       // artifacts
 	list<agh::alg::SSpan<size_t>> artifacts_in_samples() const;
-	list<agh::alg::SSpan<float>> artifacts_in_seconds() const;
+	list<agh::alg::SSpan<double>> artifacts_in_seconds() const;
 
 	virtual int export_tsv( const string& fname) const;
 
diff --git a/src/ui/mw/populate.cc b/src/ui/mw/populate.cc
index 2fdca87..adfc6df 100644
--- a/src/ui/mw/populate.cc
+++ b/src/ui/mw/populate.cc
@@ -258,7 +258,7 @@ __reconnect_sessions_combo()
 
 namespace {
 const char*
-annotation_type_s( sigfile::SAnnotation::TType t)
+annotation_type_s( sigfile::SAnnotation<double>::TType t)
 {
 	static const char* types[] = {"", "S", "K", "E"};
 	return types[t];
@@ -318,7 +318,7 @@ populate_mGlobalAnnotations()
 
 						for ( auto &A : annotations )
 							if ( (only_plain_global_annotations and
-							      A.type == sigfile::SAnnotation::plain) or
+							      A.type == sigfile::SAnnotation<double>::plain) or
 							     not only_plain_global_annotations ) {
 								global_annotations.emplace_front( J, D.first, E, A);
 
diff --git a/src/ui/sf/channel.cc b/src/ui/sf/channel.cc
index e27c1d4..978dd5d 100644
--- a/src/ui/sf/channel.cc
+++ b/src/ui/sf/channel.cc
@@ -188,19 +188,18 @@ get_signal_filtered()
 
 
 
-list<sigfile::SAnnotation*>
+list<sigfile::SAnnotation<double>*>
 aghui::SScoringFacility::SChannel::
 in_annotations( double time) const
 {
 	// select this channel's annotations
 	auto& annotations = crecording.F().annotations(name);
-	list<sigfile::SAnnotation*>
+	list<sigfile::SAnnotation<double>*>
 		ret;
-	size_t pos = time * crecording.F().samplerate(name);
 	for ( auto &A : annotations )
 		if ( agh::alg::overlap(
 			     A.span.a, A.span.z,
-			     pos, pos) )
+			     time, time) )
 			ret.push_back( &A);
 	return ret;
 }
@@ -461,9 +460,9 @@ aghui::SScoringFacility::SChannel::
 mark_region_as_artifact( bool do_mark)
 {
 	if ( do_mark )
-		crecording.F().artifacts(_h).mark_artifact( selection_start, selection_end);
+		crecording.F().artifacts(_h).mark_artifact( selection_start_time, selection_end_time);
 	else
-		crecording.F().artifacts(_h).clear_artifact( selection_start, selection_end);
+		crecording.F().artifacts(_h).clear_artifact( selection_start_time, selection_end_time);
 
 	calculate_dirty_percent();
 
@@ -483,11 +482,11 @@ mark_region_as_artifact( bool do_mark)
 
 void
 aghui::SScoringFacility::SChannel::
-mark_region_as_annotation( const string& label, sigfile::SAnnotation::TType type)
+mark_region_as_annotation( const string& label, sigfile::SAnnotation<double>::TType type)
 {
 	sigfile::mark_annotation(
 		crecording.F().annotations(_h),
-		selection_start, selection_end,
+		selection_start_time, selection_end_time,
 		label,
 		type);
 }
diff --git a/src/ui/sf/d/patterns.cc b/src/ui/sf/d/patterns.cc
index d4ceb5f..7471588 100644
--- a/src/ui/sf/d/patterns.cc
+++ b/src/ui/sf/d/patterns.cc
@@ -132,12 +132,13 @@ find_occurrences()
 
 void
 aghui::SScoringFacility::SPatternsDialog::
-occurrences_to_annotations( sigfile::SAnnotation::TType t)
+occurrences_to_annotations( sigfile::SAnnotation<double>::TType t)
 {
 	for ( size_t o = 0; o < occurrences.size(); ++o )
 		sigfile::mark_annotation(
 			field_channel->annotations,
-			occurrences[o], occurrences[o] + current_pattern->pattern_size_essential(),
+			((double)occurrences[o]) / field_channel->samplerate(),
+			((double)occurrences[o] + current_pattern->pattern_size_essential()) / field_channel->samplerate(),
 			(snprintf_buf("%s (%zu)", current_pattern->name.c_str(), o+1), __buf__),
 			t);
 }
diff --git a/src/ui/sf/d/patterns.hh b/src/ui/sf/d/patterns.hh
index d7669bf..22cc407 100644
--- a/src/ui/sf/d/patterns.hh
+++ b/src/ui/sf/d/patterns.hh
@@ -141,9 +141,9 @@ struct SScoringFacility::SPatternsDialog
 	SScoringFacility::SChannel
 		*field_channel,
 		*field_channel_saved;
-	list<sigfile::SAnnotation>
+	list<sigfile::SAnnotation<double>>
 		saved_annotations;
-	void occurrences_to_annotations( sigfile::SAnnotation::TType = sigfile::SAnnotation::TType::plain);
+	void occurrences_to_annotations( sigfile::SAnnotation<double>::TType = sigfile::SAnnotation<double>::TType::plain);
 	void save_annotations();
 	void restore_annotations();
 
diff --git a/src/ui/sf/d/patterns_cb.cc b/src/ui/sf/d/patterns_cb.cc
index 354668f..85709ce 100644
--- a/src/ui/sf/d/patterns_cb.cc
+++ b/src/ui/sf/d/patterns_cb.cc
@@ -266,7 +266,7 @@ iSFFDMarkPhasicEventSpindles_activate_cb( GtkMenuItem*, gpointer userdata)
 	auto& FD = *(SScoringFacility::SPatternsDialog*)userdata;
 
 	FD.restore_annotations();
-	FD.occurrences_to_annotations( sigfile::SAnnotation::TType::phasic_event_spindle);
+	FD.occurrences_to_annotations( sigfile::SAnnotation<double>::TType::phasic_event_spindle);
 	FD.occurrences.clear();
 	FD._p.queue_redraw_all();
 
@@ -279,7 +279,7 @@ iSFFDMarkPhasicEventKComplexes_activate_cb( GtkMenuItem*, gpointer userdata)
 	auto& FD = *(SScoringFacility::SPatternsDialog*)userdata;
 
 	FD.restore_annotations();
-	FD.occurrences_to_annotations( sigfile::SAnnotation::TType::phasic_event_K_complex);
+	FD.occurrences_to_annotations( sigfile::SAnnotation<double>::TType::phasic_event_K_complex);
 	FD.occurrences.clear();
 	FD._p.queue_redraw_all();
 
diff --git a/src/ui/sf/montage-overlays.cc b/src/ui/sf/montage-overlays.cc
index 86d858c..5dd6d40 100644
--- a/src/ui/sf/montage-overlays.cc
+++ b/src/ui/sf/montage-overlays.cc
@@ -268,9 +268,9 @@ draw_overlays( cairo_t* cr,
 		_p._p.CwB[SExpDesignUI::TColour::sf_phasic_spindle].set_source_rgba( cr);
 		cairo_set_line_width( cr, 1);
 		for ( auto& A : annotations )
-			if ( A.type == sigfile::SAnnotation::TType::phasic_event_spindle ) {
-				auto x = (float)(A.span.z + A.span.a)/2 / samplerate()
-					/ ((float)_p.total_pages() * _p.pagesize());
+			if ( A.type == sigfile::SAnnotation<double>::TType::phasic_event_spindle ) {
+				auto x = (double)(A.span.z + A.span.a)/2 / samplerate()
+					/ ((double)_p.total_pages() * _p.pagesize());
 				cairo_move_to( cr, x * _p.da_wd - 2,  pbot - 8);
 				cairo_rel_line_to( cr,  2, -5);
 				cairo_rel_line_to( cr,  2,  5);
@@ -285,7 +285,7 @@ draw_overlays( cairo_t* cr,
 		_p._p.CwB[SExpDesignUI::TColour::sf_phasic_Kcomplex].set_source_rgba( cr);
 		cairo_set_line_width( cr, 8);
 		for ( auto& A : annotations )
-			if ( A.type == sigfile::SAnnotation::TType::phasic_event_K_complex ) {
+			if ( A.type == sigfile::SAnnotation<double>::TType::phasic_event_K_complex ) {
 				auto x = (float)(A.span.z + A.span.a)/2 / samplerate()
 					/ ((float)_p.total_pages() * _p.pagesize());
 				cairo_move_to( cr, x * _p.da_wd - 1, pbot - ptop - 8);
diff --git a/src/ui/sf/montage.cc b/src/ui/sf/montage.cc
index 93565f6..e0904c5 100644
--- a/src/ui/sf/montage.cc
+++ b/src/ui/sf/montage.cc
@@ -68,7 +68,7 @@ struct SChHolder {
 
 
 
-sigfile::SAnnotation*
+sigfile::SAnnotation<double>*
 aghui::SScoringFacility::
 interactively_choose_annotation() const
 {
@@ -492,7 +492,7 @@ draw_page( cairo_t *cr,
 				auto	wa = (float)(aa % evpz) / evpz * wd,
 					ww = (float)(ae - aa) / evpz * wd;
 
-				if ( A.type == sigfile::SAnnotation::TType::plain ) {
+				if ( A.type == sigfile::SAnnotation<double>::TType::plain ) {
 					int disp = ptop +
 						((last_z > (int)A.span.a)
 						 ? ++overlap_count * 5
@@ -515,7 +515,7 @@ draw_page( cairo_t *cr,
 					cairo_move_to( cr, (float)(aa % evpz) / evpz * wd, disp + 12);
 					cairo_show_text( cr, A.label.c_str());
 
-				} else if ( A.type == sigfile::SAnnotation::TType::phasic_event_spindle
+				} else if ( A.type == sigfile::SAnnotation<double>::TType::phasic_event_spindle
 					    and draw_phasic_spindle ) {
 					cairo_pattern_t *cp = cairo_pattern_create_linear( wa, 0., wa + ww, 0.);
 					_p._p.CwB[SExpDesignUI::TColour::sf_phasic_spindle].pattern_add_color_stop_rgba( cp, 0., 0.);
@@ -528,7 +528,7 @@ draw_page( cairo_t *cr,
 					cairo_stroke( cr);
 					cairo_pattern_destroy( cp);
 
-				} else if ( A.type == sigfile::SAnnotation::TType::phasic_event_K_complex
+				} else if ( A.type == sigfile::SAnnotation<double>::TType::phasic_event_K_complex
 					    and draw_phasic_Kcomplex ) {
 					cairo_pattern_t *cp = cairo_pattern_create_linear( 0., ptop, 0., pbot);
 					_p._p.CwB[SExpDesignUI::TColour::sf_phasic_Kcomplex].pattern_add_color_stop_rgba( cp, 0., 0.);
@@ -541,7 +541,7 @@ draw_page( cairo_t *cr,
 					cairo_stroke( cr);
 					cairo_pattern_destroy( cp);
 
-				} else if ( A.type == sigfile::SAnnotation::TType::eyeblink
+				} else if ( A.type == sigfile::SAnnotation<double>::TType::eyeblink
 					    and draw_phasic_eyeblink ) {
 					cairo_pattern_t *cp = cairo_pattern_create_linear( 0., ptop, 0., pbot);
 					_p._p.CwB[SExpDesignUI::TColour::sf_phasic_eyeblink].pattern_add_color_stop_rgba( cp, 0., 0.);
diff --git a/src/ui/sf/montage_cb.cc b/src/ui/sf/montage_cb.cc
index ef78cdc..182803d 100644
--- a/src/ui/sf/montage_cb.cc
+++ b/src/ui/sf/montage_cb.cc
@@ -849,7 +849,7 @@ void
 iSFPageAnnotationEdit_activate_cb( GtkMenuItem *menuitem, gpointer userdata)
 {
 	auto& SF = *(SScoringFacility*)userdata;
-	sigfile::SAnnotation *which =
+	sigfile::SAnnotation<double> *which =
 		(SF.over_annotations.size() == 1)
 		? SF.over_annotations.front()
 		: SF.interactively_choose_annotation();
@@ -858,16 +858,16 @@ iSFPageAnnotationEdit_activate_cb( GtkMenuItem *menuitem, gpointer userdata)
 
 	gtk_entry_set_text( SF.eSFAnnotationLabel, which->label.c_str());
 	switch ( which->type ) {
-	case sigfile::SAnnotation::TType::phasic_event_spindle:
+	case sigfile::SAnnotation<double>::TType::phasic_event_spindle:
 		gtk_toggle_button_set_active( (GtkToggleButton*)SF.eSFAnnotationTypeSpindle, TRUE);
 		break;
-	case sigfile::SAnnotation::TType::phasic_event_K_complex:
+	case sigfile::SAnnotation<double>::TType::phasic_event_K_complex:
 		gtk_toggle_button_set_active( (GtkToggleButton*)SF.eSFAnnotationTypeKComplex, TRUE);
 		break;
-	case sigfile::SAnnotation::TType::eyeblink:
+	case sigfile::SAnnotation<double>::TType::eyeblink:
 		gtk_toggle_button_set_active( (GtkToggleButton*)SF.eSFAnnotationTypeBlink, TRUE);
 		break;
-	case sigfile::SAnnotation::TType::plain:
+	case sigfile::SAnnotation<double>::TType::plain:
 	default:
 		gtk_toggle_button_set_active( (GtkToggleButton*)SF.eSFAnnotationTypePlain, TRUE);
 		break;
@@ -878,12 +878,12 @@ iSFPageAnnotationEdit_activate_cb( GtkMenuItem *menuitem, gpointer userdata)
 		const char* new_label = gtk_entry_get_text( SF.eSFAnnotationLabel);
 		auto new_type =
 			gtk_toggle_button_get_active( (GtkToggleButton*)SF.eSFAnnotationTypeSpindle)
-			? sigfile::SAnnotation::TType::phasic_event_spindle
+			? sigfile::SAnnotation<double>::TType::phasic_event_spindle
 			: gtk_toggle_button_get_active( (GtkToggleButton*)SF.eSFAnnotationTypeKComplex)
-			? sigfile::SAnnotation::TType::phasic_event_K_complex
+			? sigfile::SAnnotation<double>::TType::phasic_event_K_complex
 			: gtk_toggle_button_get_active( (GtkToggleButton*)SF.eSFAnnotationTypeBlink)
-			? sigfile::SAnnotation::TType::eyeblink
-			: sigfile::SAnnotation::TType::plain;
+			? sigfile::SAnnotation<double>::TType::eyeblink
+			: sigfile::SAnnotation<double>::TType::plain;
 
 		if ( strlen(new_label) > 0 ) {
 			which->label = new_label;
@@ -1031,12 +1031,12 @@ iSFPageSelectionAnnotate_activate_cb( GtkMenuItem *menuitem, gpointer userdata)
 
 		auto type =
 			gtk_toggle_button_get_active( (GtkToggleButton*)SF.eSFAnnotationTypeSpindle)
-			? sigfile::SAnnotation::TType::phasic_event_spindle
+			? sigfile::SAnnotation<double>::TType::phasic_event_spindle
 			: gtk_toggle_button_get_active( (GtkToggleButton*)SF.eSFAnnotationTypeKComplex)
-			? sigfile::SAnnotation::TType::phasic_event_K_complex
+			? sigfile::SAnnotation<double>::TType::phasic_event_K_complex
 			: gtk_toggle_button_get_active( (GtkToggleButton*)SF.eSFAnnotationTypeBlink)
-			? sigfile::SAnnotation::TType::eyeblink
-			: sigfile::SAnnotation::TType::plain;
+			? sigfile::SAnnotation<double>::TType::eyeblink
+			: sigfile::SAnnotation<double>::TType::plain;
 
 		SF.using_channel->mark_region_as_annotation( new_ann, type);
 
diff --git a/src/ui/sf/sf.cc b/src/ui/sf/sf.cc
index b11893b..8588f7f 100644
--- a/src/ui/sf/sf.cc
+++ b/src/ui/sf/sf.cc
@@ -540,8 +540,8 @@ page_has_artifacts( size_t p, bool search_all) const
 		if ( ! search_all && H.hidden )
 			continue;
 		else {
-			size_t spp = vpagesize() * H.samplerate();
-			if ( ((agh::alg::SSpan<size_t> (p, p+1)) * spp) . dirty( H.artifacts()) > 0. )
+			if ( ((agh::alg::SSpan<double> ((double)p, (double)p+1)) * (double)vpagesize())
+			     . dirty( H.artifacts()) > 0. )
 				return true;
 		}
 	return false;
diff --git a/src/ui/sf/sf.hh b/src/ui/sf/sf.hh
index 4ebb220..ede128b 100644
--- a/src/ui/sf/sf.hh
+++ b/src/ui/sf/sf.hh
@@ -83,7 +83,7 @@ class SScoringFacility
 		int	_h;
 		sigfile::SFilterPack&
 			filters;
-		list<sigfile::SAnnotation>&
+		list<sigfile::SAnnotation<double>>&
 			annotations;
 		sigfile::SArtifacts&
 			artifacts;
@@ -114,7 +114,7 @@ class SScoringFacility
 		mark_flat_regions_as_artifacts( double at_least_this_long, double pad);
 
 	      // annotations
-		list<sigfile::SAnnotation*>
+		list<sigfile::SAnnotation<double>*>
 		in_annotations( double time) const;
 
 	      // signal metrics
@@ -199,7 +199,7 @@ class SScoringFacility
 
 	      // region
 		void mark_region_as_artifact( bool do_mark);
-		void mark_region_as_annotation( const string&, sigfile::SAnnotation::TType);
+		void mark_region_as_annotation( const string&, sigfile::SAnnotation<double>::TType);
 		void mark_region_as_pattern();
 
 	      // ctor, dtor
@@ -313,6 +313,10 @@ class SScoringFacility
 	void
 	update_all_channels_profile_display_scale();
 
+      // common annotations
+	list<sigfile::SAnnotation<double>>
+		common_annotations;
+
       // timeline
 	time_t start_time() const
 		{
@@ -546,9 +550,9 @@ class SScoringFacility
 				else ++i;
 			return -1;
 		}
-	list<sigfile::SAnnotation*>
+	list<sigfile::SAnnotation<double>*>
 		over_annotations;
-	sigfile::SAnnotation*
+	sigfile::SAnnotation<double>*
 	interactively_choose_annotation() const;
 
     private:

-- 
Sleep experiment manager



More information about the debian-med-commit mailing list