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

andrei zavada jh at johnhommer.com
Sun Feb 3 12:53:05 UTC 2013


The following commit has been merged in the master branch:
commit a3253261212192045791776e9157e137162629c6
Author: andrei zavada <jh at johnhommer.com>
Date:   Wed Jan 30 19:33:12 2013 +0000

    extend annotations to have a type, incl. phasic events; load them safely

diff --git a/src/libsigfile/edf.cc b/src/libsigfile/edf.cc
index d96a4ae..b0ac3c1 100644
--- a/src/libsigfile/edf.cc
+++ b/src/libsigfile/edf.cc
@@ -173,16 +173,19 @@ CEDFFile (const char *fname_, int flags_)
 		ifstream fd (make_fname_annotations( H.label));
 		if ( not fd.good() )
 			continue;
-		size_t aa, az;
+		int type = -1;
+		size_t aa = -1, az = -1;
 		string an;
-		while ( true ) {
-			fd >> aa >> az;
+		while ( fd.good() and not fd.eof() ) {
+			fd >> type >> aa >> az;
 			getline( fd, an, EOA);
-			if ( fd.good() && !fd.eof() ) {
-				H.annotations.emplace_back(
+			if ( aa < az and az < n_data_records * H.samples_per_record
+			     and type < SAnnotation::TType_total and type >= 0 )
+			     H.annotations.emplace_back(
 					aa, az,
-					agh::str::trim(an));
-			} else
+					agh::str::trim(an),
+					(SAnnotation::TType)type);
+			else
 				break;
 		}
 		H.annotations.sort();
@@ -407,7 +410,7 @@ write_ancillary_files()
 		if ( I.annotations.size() ) {
 			ofstream thomas (make_fname_annotations( I.label), ios_base::trunc);
 			for ( auto &A : I.annotations )
-				thomas << A.span.a << ' ' << A.span.z << ' ' << A.label << EOA << endl;
+				thomas << (int)A.type << ' ' << A.span.a << ' ' << A.span.z << ' ' << A.label << EOA << endl;
 		} else
 			if ( unlink( make_fname_annotations( I.label).c_str()) ) {}
 	}
diff --git a/src/libsigfile/edf.hh b/src/libsigfile/edf.hh
index a8f0cdd..581d3c2 100644
--- a/src/libsigfile/edf.hh
+++ b/src/libsigfile/edf.hh
@@ -54,7 +54,8 @@ class CEDFFile
 		}
 	enum {
 		no_mmap				= 1<<3,
-		no_field_consistency_check	= 1<<4
+		no_cache			= 1<<4, // just considering
+		no_field_consistency_check	= 1<<5,
 	};
 	// open existing
 	CEDFFile (const char *fname, int flags = 0);
diff --git a/src/libsigfile/source-base.hh b/src/libsigfile/source-base.hh
index a20f73e..6cbe838 100644
--- a/src/libsigfile/source-base.hh
+++ b/src/libsigfile/source-base.hh
@@ -114,17 +114,23 @@ struct SArtifacts {
 struct SAnnotation {
 	agh::alg::SSpan<size_t> span;
 	string label;
-	// enum class TOrigin : bool { internal, external };
-	// TOrigin origin;
+	enum TType {
+		plain,
+		phasic_event_spindle,
+		phasic_event_K_complex,
+		eyeblink,
+		TType_total
+	};
+	TType type;;
 
-	SAnnotation( size_t aa, size_t az, const string& l)
+	SAnnotation( size_t aa, size_t az, const string& l, TType t = TType::plain)
 	      : span {aa, az}, label (l)
 //		  origin (_origin)
 		{}
 
 	bool operator==( const SAnnotation& rv) const
 		{
-			return span == rv.span && label == rv.label; // && origin == rv.origin;
+			return span == rv.span && label == rv.label && type == rv.type;
 		}
 	bool operator<( const SAnnotation& rv) const
 		{

-- 
Sleep experiment manager



More information about the debian-med-commit mailing list