Sync biosiglite with upstream

parent 160eab76
......@@ -47,8 +47,6 @@ extern "C" {
extern int VERBOSE_LEVEL; // used for debugging, variable is always defined
#endif
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define max(a,b) (((a) > (b)) ? (a) : (b))
/*
Including ZLIB enables reading gzipped files (they are decompressed on-the-fly)
......@@ -110,7 +108,7 @@ char *getlogin (void);
#define BIOSIG_VERSION_MAJOR 1
#define BIOSIG_VERSION_MINOR 9
#define BIOSIG_PATCHLEVEL 2
#define BIOSIG_PATCHLEVEL 3
// for backward compatibility
#define BIOSIG_VERSION_STEPPING BIOSIG_PATCHLEVEL
#define BIOSIG_VERSION (BIOSIG_VERSION_MAJOR * 10000 + BIOSIG_VERSION_MINOR * 100 + BIOSIG_PATCHLEVEL)
......@@ -139,7 +137,7 @@ char *getlogin (void);
#include "gdftime.h"
/*
* pack structures to fullfil following requirements:
* pack structures to fulfil following requirements:
* (1) Matlab v7.3+ requires 8 byte alignment
* (2) in order to use mingw-compiled libbiosig with MS' VisualStudio,
* the structurs must be packed in a MS compatible way.
......@@ -228,7 +226,8 @@ enum FileFormat {
TDMS, TIFF, TMS32, TMSiLOG, TRC, UNIPRO, VRML, VTK,
WAV, WCP, WG1, WinEEG, WMF, XML, XPM,
Z, ZIP, ZIP2, RHD2000,
invalid=0xffff
EBNEURO, SigViewerEventsCSV, XDF,
LastPlaceHolder, invalid=0xffff
};
......
This diff is collapsed.
/*
Copyright (C) 2005-2012 Alois Schloegl <alois.schloegl@gmail.com>
Copyright (C) 2005-2019 Alois Schloegl <alois.schloegl@gmail.com>
This file is part of the "BioSig for C/C++" repository
(biosig4c++) at http://biosig.sf.net/
BioSig is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 3
......
/*
% Copyright (C) 2005-2012,2015 Alois Schloegl <alois.schloegl@ist.ac.at>
% This file is part of the "BioSig for C/C++" repository
% (biosig4c++) at http://biosig.sf.net/
Copyright (C) 2005-2019 Alois Schloegl <alois.schloegl@ist.ac.at>
This file is part of the "BioSig for C/C++" repository
(biosig4c++) at http://biosig.sf.net/
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
......
......@@ -29,7 +29,7 @@
#include <stdlib.h>
#include <string.h>
#include "../biosig-dev.h"
#include "../biosig.h"
#define ABFLONG int32_t
#include "axon_structs.h" // ABF2
......
/*
Copyright (C) 2010,2011,2012,2015,2016 Alois Schloegl <alois.schloegl@ist.ac.at>
Copyright (C) 2010-2019 Alois Schloegl <alois.schloegl@ist.ac.at>
This file is part of the "BioSig for C/C++" repository
(biosig4c++) at http://biosig.sf.net/
(biosig4c++) at http://biosig.sourceforge.io/
BioSig is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
......@@ -26,7 +26,7 @@
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include "../biosig-dev.h"
#include "../biosig.h"
#define min(a,b) (((a) < (b)) ? (a) : (b))
......
......@@ -897,12 +897,12 @@ void sopen_itx_read (HDRTYPE* hdr) {
}
if (VERBOSE_LEVEL>7)
fprintf(stdout,"%s (line %i): scaning %s,v%4.2f format (supported: %i)\n",__FILE__,__LINE__,GetFileTypeString(hdr->TYPE),hdr->VERSION,flagSupported);
fprintf(stdout,"%s (line %i): scanning %s,v%4.2f format (supported: %i)\n",__FILE__,__LINE__,GetFileTypeString(hdr->TYPE),hdr->VERSION,flagSupported);
if (!flagSupported) {
clear_sweepnames(sweepname_list);
biosigERROR(hdr, hdr->AS.B4C_ERRNUM,
"This ITX format is not supported. Possible reasons: not generated by Heka-Patchmaster, corrupted, physical units do not match between sweeos, or do not fullfil some other requirements");
"This ITX format is not supported. Possible reasons: not generated by Heka-Patchmaster, corrupted, physical units do not match between sweeps, or do not fulfil some other requirements");
return;
}
......
......@@ -617,7 +617,7 @@ int sopen_SCP_read(HDRTYPE* hdr) {
/**** SECTION 0 ****/
len = leu32p(PtrCurSect+4);
NSections = min((len-16)/10,_NUM_SECTION);
NSections = (len-16)/10;
if (memcmp(ptr+16, "SCPECG\0\0", 8)) {
fprintf(stderr,"Warning SOPEN (SCP): Bytes 11-16 of Section 0 do not contain SCPECG - this violates ISO/DIS 11073-91064 Section 5.3.2.\n" );
......@@ -632,18 +632,25 @@ int sopen_SCP_read(HDRTYPE* hdr) {
section[K].index = 0;
}
for (K=1; K<NSections; K++) {
for (K = 1; K < NSections; K++) {
// this is needed because fields are not always sorted
curSect = leu32p(ptr+6+16+K*10);
len = leu32p(ptr+6+16+K*10+2);
if (VERBOSE_LEVEL > 7)
fprintf(stdout,"%s (line %i): #%d section %d/%d %d %d\n",__FILE__,__LINE__,K,curSect,NSections,leu32p(ptr+6+16+K*10+2),leu32p(ptr+6+16+K*10+6)-1);
if (curSect < _NUM_SECTION) {
if (section[curSect].ID >= 0) {
biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "SCP Section must not be defined twice");
return -1;
}
section[curSect].ID = curSect;
section[curSect].length = leu32p(ptr+6+16+K*10+2);
section[curSect].length = len;
section[curSect].index = leu32p(ptr+6+16+K*10+6)-1;
}
else if (len > 0)
fprintf(stderr,"Warning SOPEN (SCP) : vendor specific section %d is not supported\n",curSect);
}
if (section[1].length) {
......@@ -678,7 +685,7 @@ int sopen_SCP_read(HDRTYPE* hdr) {
}
}
for (K=1; K<NSections; K++) {
for (K=1; K<_NUM_SECTION; K++) {
curSect = section[K].ID;
len = section[K].length;
......@@ -740,7 +747,7 @@ int sopen_SCP_read(HDRTYPE* hdr) {
tag = *(PtrCurSect+curSectPos);
len1 = leu16p(PtrCurSect+curSectPos+1);
if (VERBOSE_LEVEL > 7)
fprintf(stdout,"SCP(r): Section 1 Tag %i Len %i\n",tag,len1);
fprintf(stdout,"SCP(r): Section 1 Tag %i Len %i <%s>\n",tag,len1, (char*)PtrCurSect+curSectPos);
curSectPos += 3;
if (curSectPos+len1 > len) {
......@@ -902,8 +909,6 @@ int sopen_SCP_read(HDRTYPE* hdr) {
if (VERBOSE_LEVEL>7)
fprintf(stdout,"%s (line %i): Version %i\n",__FILE__,__LINE__,aECG->Section1.Tag14.VERSION);
}
else if (tag==15) {
/* Analyzing Device ID Number */
......@@ -1043,6 +1048,9 @@ int sopen_SCP_read(HDRTYPE* hdr) {
NHT = leu16p(PtrCurSect+curSectPos);
curSectPos += 2;
if (VERBOSE_LEVEL > 7) fprintf(stdout,"SCP(r): Section 2 NHT=%d\n", NHT);
if (NHT==19999) {
en1064.FLAG.HUFFMAN = 1;
Huffman = (huffman_t*)malloc(sizeof(huffman_t));
......@@ -1055,6 +1063,7 @@ int sopen_SCP_read(HDRTYPE* hdr) {
if (VERBOSE_LEVEL==9)
for (k1=0; k1<Huffman[k2].NCT; k1++)
fprintf(stdout,"%3i: %2i %2i %1i %3i %6u \n",k1,Huffman[k2].Table[k1].PrefixLength,Huffman[k2].Table[k1].CodeLength,Huffman[k2].Table[k1].TableModeSwitch,Huffman[k2].Table[k1].BaseValue,Huffman[k2].Table[k1].BaseCode);
if (!checkTree(HTrees[0])) // ### OPTIONAL, not needed ###
fprintf(stderr,"Warning: invalid Huffman Tree\n");
#endif
......@@ -1127,8 +1136,7 @@ int sopen_SCP_read(HDRTYPE* hdr) {
hdr->CHANNEL[i].SPR = en1064.Section3.lead[i].end - en1064.Section3.lead[i].start + 1;
if (VERBOSE_LEVEL>7)
fprintf(stdout,"%s (line %i): SCP Section %i #%i SPR=%d/%d\n",__FILE__,__LINE__,curSect,i,hdr->CHANNEL[i].SPR,hdr->SPR);
fprintf(stdout,"%s (line %i): SCP Section %i #%i SPR=%d/%d [%d..%d]\n",__FILE__,__LINE__,curSect, i, hdr->CHANNEL[i].SPR, hdr->SPR, en1064.Section3.lead[i].end, en1064.Section3.lead[i].start );
hdr->SPR = lcm(hdr->SPR,hdr->CHANNEL[i].SPR);
hdr->CHANNEL[i].LeadIdCode = LeadIdCode;
hdr->CHANNEL[i].Label[0]= 0;
......@@ -1486,6 +1494,9 @@ int sopen_SCP_read(HDRTYPE* hdr) {
#if (BIOSIG_VERSION >= 10500)
hdr->SCP.Section8Length = leu32p(PtrCurSect+4)-curSectPos;
hdr->SCP.Section8 = PtrCurSect+curSectPos;
if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %p %d %d %d\n", __func__, __LINE__, hdr->AS.Header, hdr->SCP.Section8Length, (int)curSectPos, (int)(hdr->SCP.Section8-hdr->AS.Header));
#else
aECG->Section8.Confirmed = *(char*)(PtrCurSect+curSectPos);
aECG->Section8.t.tm_year = leu16p(PtrCurSect+curSectPos+1)-1900;
......
......@@ -28,20 +28,23 @@
#include <string.h>
#include <sys/stat.h>
#include "../biosig-dev.h"
#include "../biosig.h"
// these functions are stubs
/*************************************************************************
use DCMTK for reading DICOM files
*************************************************************************/
#ifdef WITH_DCMTK
#undef WITH_DICOM
#undef WITH_GDCM
#undef WITH_DICOM // disable internal DICOM implementation
#undef WITH_GDCM // disable interface to GDCM
EXTERN_C int sopen_dicom_read(HDRTYPE* hdr) {
fprintf(stdout,"DCMTK is used to read dicom files.\n");
extern "C" int sopen_dcmtk_read(HDRTYPE* hdr);
extern "C" int sopen_dicom_read(HDRTYPE* hdr) {
return sopen_dcmtk_read(hdr);
}
#endif
#endif // DCMTK
#ifdef HAVE_HDF
#include <hdf5.h>
......@@ -51,6 +54,9 @@ EXTERN_C int sopen_dicom_read(HDRTYPE* hdr) {
#endif
/*************************************************************************
use GDCM for reading DICOM files
*************************************************************************/
#ifdef WITH_GDCM
#undef WITH_DICOM
......@@ -98,7 +104,7 @@ EXTERN_C int sopen_dicom_read(HDRTYPE* hdr) {
EXTERN_C int sopen_dicom_read(HDRTYPE* hdr) {
fprintf(stdout,"GDCM is used to read dicom files.\n");
fprintf(stdout,"%s ( line %d): GDCM is used to read dicom files.\n",__func__,__LINE__);
gdcm::Reader reader;
const gdcm::DataElement *de;
......@@ -375,6 +381,9 @@ int sopen_unipro_read(HDRTYPE* hdr) {
}
/*************************************************************************
use internal implementation for reading DICOM files
*************************************************************************/
#ifdef WITH_DICOM
int sopen_dicom_read(HDRTYPE* hdr) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment