[Debian-med-packaging] Bug#1010001: libbiosig3: incorrect sample rate when reading IBW files

Alois Schlögl alois.schloegl at gmail.com
Fri Apr 22 07:44:08 BST 2022


Package: libbiosig3
Version: 2.1.2-4
Severity: normal
Tags: patch
X-Debbugs-Cc: alois.schloegl at gmail.com

Dear Maintainer,

   libbiosig supports reading many different data formats, including the IgorBinaryWaveform (IBW) format. 
   When reading this data, an incorrect sampling rate (e.g. 25 Hz instead of 25 kHz)  
   is returned, because the scaling of the scaling of physical units for the sampling interval 
   milli-seconds is not correctly considered. This affacts all tools using libbiosig,
   including biosig-tools, mexSLOAD and mexSOPEN in octave-biosig, sigviewer, stimfit,
   and all other language bindings. 

   The attached patch fixes this bug, and fixes als uninitialized data in the event table. 
   I suggest to backport this to the current stable release.  


-- System Information:
Debian Release: 11.3
  APT prefers stable-security
  APT policy: (500, 'stable-security'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.10.0-13-amd64 (SMP w/8 CPU threads)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US:en
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages libbiosig3 depends on:
ii  libc6              2.31-13+deb11u3
ii  libdcmtk15         3.6.5-1
ii  libgcc-s1          10.2.1-6
ii  libstdc++6         10.2.1-6
ii  libtinyxml2.6.2v5  2.6.2-4

libbiosig3 recommends no packages.

libbiosig3 suggests no packages.

-- no debconf information
-------------- next part --------------
diff --git a/biosig4c++/t210/sopen_igor.c b/biosig4c++/t210/sopen_igor.c
index deb82631..c4d1ced6 100644
--- a/biosig4c++/t210/sopen_igor.c
+++ b/biosig4c++/t210/sopen_igor.c
@@ -383,7 +383,7 @@ void sopen_ibw_read (HDRTYPE* hdr) {
 	int16_t type = 0;			// See types (e.g. NT_FP64) above. Zero for text waves.
 
 	hdr->NS = 1;
-	hdr->SampleRate = 1;
+	hdr->SampleRate = 1.0;
 	hdr->CHANNEL = (CHANNEL_TYPE*) realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE));
 
 	// Read some of the WaveHeader fields.
@@ -407,7 +407,7 @@ void sopen_ibw_read (HDRTYPE* hdr) {
 				hdr->CHANNEL[0].DigMin = (w2->botFullScale-w2->hsB) / w2->hsA;
 */
 #else
-				hdr->SampleRate = 1.0 / w2->hsA;
+				hdr->SampleRate /= w2->hsA * PhysDimScale(PhysDimCode(w2->xUnits));
 				hdr->CHANNEL[0].PhysMax = w2->topFullScale;
 				hdr->CHANNEL[0].PhysMin = w2->botFullScale;
 #endif
@@ -446,6 +446,8 @@ void sopen_ibw_read (HDRTYPE* hdr) {
 					for (n = 0; n < hdr->EVENT.N; n++) {
 						hdr->EVENT.TYP[n] = 0x7ffe;
 						hdr->EVENT.POS[n] = (n+1)*w5->nDim[0];
+						hdr->EVENT.DUR[n] = 0;
+						hdr->EVENT.CHN[n] = 0;
 					}
 				}
 
@@ -458,7 +460,10 @@ void sopen_ibw_read (HDRTYPE* hdr) {
 				hdr->CHANNEL[0].PhysDimCode = PhysDimCode(w5->dataUnits);
 				hdr->CHANNEL[0].SPR = hdr->SPR = 1;
 				hdr->NRec        = w5->npnts;
-				hdr->SampleRate /= w5->sfA[0];
+				hdr->SampleRate /= w5->sfA[0] * PhysDimScale(PhysDimCode(w5->dimUnits[0]));
+
+				if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): %g.x+%g \n",__FILE__,__LINE__,w5->sfA[0],w5->sfB[0]);
+				if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): |%s|%s|%s|%s|\n",__FILE__,__LINE__,w5->dimUnits[0],w5->dimUnits[1],w5->dimUnits[2],w5->dimUnits[3]);
 
 #ifdef IGOROLD
 				hdr->CHANNEL[0].Cal = 1.0;
@@ -916,6 +921,8 @@ void sopen_itx_read (HDRTYPE* hdr) {
 		hdr->EVENT.SampleRate = hdr->SampleRate;
 		hdr->EVENT.POS = (uint32_t*) realloc(hdr->EVENT.POS, hdr->EVENT.N * sizeof(*hdr->EVENT.POS));
 		hdr->EVENT.TYP = (uint16_t*) realloc(hdr->EVENT.TYP, hdr->EVENT.N * sizeof(*hdr->EVENT.TYP));
+		hdr->EVENT.CHN = (uint16_t*) realloc(hdr->EVENT.TYP, hdr->EVENT.N * sizeof(*hdr->EVENT.TYP));
+		hdr->EVENT.DUR = (uint32_t*) realloc(hdr->EVENT.POS, hdr->EVENT.N * sizeof(*hdr->EVENT.POS));
 #if (BIOSIG_VERSION >= 10500)
 		hdr->EVENT.TimeStamp = (gdf_time*)realloc(hdr->EVENT.TimeStamp, hdr->EVENT.N*sizeof(gdf_time));
 #endif
@@ -979,6 +986,8 @@ void sopen_itx_read (HDRTYPE* hdr) {
 				if (sweepNo > 0 && chanNo==0) {
 					hdr->EVENT.POS[sweepNo-1] = SPR;
 					hdr->EVENT.TYP[sweepNo-1] = 0x7ffe;
+					hdr->EVENT.DUR[sweepNo-1] = 0;
+					hdr->EVENT.CHN[sweepNo-1] = 0;
 #if (BIOSIG_VERSION >= 10500)
 					hdr->EVENT.TimeStamp[sweepNo-1] = 0;
 #endif


More information about the Debian-med-packaging mailing list