[med-svn] [Git][med-team/edflib][upstream] New upstream version 1.22

Étienne Mollier (@emollier) gitlab at salsa.debian.org
Sun Jul 17 16:30:31 BST 2022



Étienne Mollier pushed to branch upstream at Debian Med / edflib


Commits:
57ba90a4 by Étienne Mollier at 2022-07-17T16:50:46+02:00
New upstream version 1.22
- - - - -


3 changed files:

- edflib.c
- edflib.h
- unittest/unittest.c


Changes:

=====================================
edflib.c
=====================================
@@ -35,10 +35,10 @@
 
 #include "edflib.h"
 
-#define EDFLIB_VERSION  (121)
+#define EDFLIB_VERSION  (122)
 #define EDFLIB_MAXFILES  (64)
 
-#if defined(__APPLE__) || defined(__MACH__) || defined(__APPLE_CC__) || defined(__HAIKU__)
+#if defined(__APPLE__) || defined(__MACH__) || defined(__APPLE_CC__) || defined(__HAIKU__) || defined(__ANDROID__)
 
 #define fopeno fopen
 
@@ -106,6 +106,9 @@ struct edfhdrblock{
         char      plus_patientcode[81];
         char      plus_gender[16];
         char      plus_birthdate[16];
+        int       plus_birthdate_day;
+        int       plus_birthdate_month;
+        int       plus_birthdate_year;
         char      plus_patient_name[81];
         char      plus_patient_additional[81];
         char      plus_startdate[16];
@@ -148,6 +151,7 @@ struct edfhdrblock{
 
 static struct edf_annotationblock{
         long long onset;
+        long long duration_l;
         char duration[16];
         char annotation[EDFLIB_MAX_ANNOTATION_LEN + 1];
        } *annotationslist[EDFLIB_MAXFILES];
@@ -370,6 +374,9 @@ int edfopen_file_readonly(const char *path, struct edf_hdr_struct *edfhdr, int r
     edfhdr->patientcode[0] = 0;
     edfhdr->gender[0] = 0;
     edfhdr->birthdate[0] = 0;
+    edfhdr->birthdate_day = 0;
+    edfhdr->birthdate_month = 0;
+    edfhdr->birthdate_year = 0;
     edfhdr->patient_name[0] = 0;
     edfhdr->patient_additional[0] = 0;
     edfhdr->admincode[0] = 0;
@@ -384,6 +391,9 @@ int edfopen_file_readonly(const char *path, struct edf_hdr_struct *edfhdr, int r
     edflib_strlcpy(edfhdr->patientcode, hdr->plus_patientcode, 81);
     edflib_strlcpy(edfhdr->gender, hdr->plus_gender, 16);
     edflib_strlcpy(edfhdr->birthdate, hdr->plus_birthdate, 16);
+    edfhdr->birthdate_day = hdr->plus_birthdate_day;
+    edfhdr->birthdate_month = hdr->plus_birthdate_month;
+    edfhdr->birthdate_year = hdr->plus_birthdate_year;
     edflib_strlcpy(edfhdr->patient_name, hdr->plus_patient_name, 81);
     edflib_strlcpy(edfhdr->patient_additional, hdr->plus_patient_additional, 81);
     edflib_strlcpy(edfhdr->admincode, hdr->plus_admincode, 81);
@@ -1267,6 +1277,7 @@ int edf_get_annotation(int handle, int n, struct edf_annotation_struct *annot)
   }
 
   annot->onset = (annotationslist[handle] + n)->onset;
+  annot->duration_l = (annotationslist[handle] + n)->duration_l;
   edflib_strlcpy(annot->duration, (annotationslist[handle] + n)->duration, 16);
   edflib_strlcpy(annot->annotation, (annotationslist[handle] + n)->annotation, EDFLIB_MAX_ANNOTATION_LEN + 1);
 
@@ -2385,6 +2396,9 @@ static struct edfhdrblock * edflib_check_edf_file(FILE *inputfile, int *edf_erro
     if(edfhdr->patient[p]=='X')
     {
       edfhdr->plus_birthdate[0] = 0;
+      edfhdr->plus_birthdate_day = 0;
+      edfhdr->plus_birthdate_month = 0;
+      edfhdr->plus_birthdate_year = 0;
       p += 2;
     }
     else
@@ -2404,6 +2418,60 @@ static struct edfhdrblock * edflib_check_edf_file(FILE *inputfile, int *edf_erro
       edfhdr->plus_birthdate[6] = ' ';
       edfhdr->plus_birthdate[11] = 0;
       p += i + 1;
+      edfhdr->plus_birthdate_day = edflib_atoi_nonlocalized(edfhdr->plus_birthdate);
+      if(!strncmp(edfhdr->plus_birthdate + 3, "jan", 3))
+      {
+        edfhdr->plus_birthdate_month = 1;
+      }
+      else if(!strncmp(edfhdr->plus_birthdate + 3, "feb", 3))
+        {
+          edfhdr->plus_birthdate_month = 2;
+        }
+        else if(!strncmp(edfhdr->plus_birthdate + 3, "mar", 3))
+          {
+            edfhdr->plus_birthdate_month = 3;
+          }
+          else if(!strncmp(edfhdr->plus_birthdate + 3, "apr", 3))
+            {
+              edfhdr->plus_birthdate_month = 4;
+            }
+            else if(!strncmp(edfhdr->plus_birthdate + 3, "may", 3))
+              {
+                edfhdr->plus_birthdate_month = 5;
+              }
+              else if(!strncmp(edfhdr->plus_birthdate + 3, "jun", 3))
+                {
+                  edfhdr->plus_birthdate_month = 6;
+                }
+                else if(!strncmp(edfhdr->plus_birthdate + 3, "jul", 3))
+                  {
+                    edfhdr->plus_birthdate_month = 7;
+                  }
+                  else if(!strncmp(edfhdr->plus_birthdate + 3, "aug", 3))
+                    {
+                      edfhdr->plus_birthdate_month = 8;
+                    }
+                    else if(!strncmp(edfhdr->plus_birthdate + 3, "sep", 3))
+                      {
+                        edfhdr->plus_birthdate_month = 9;
+                      }
+                      else if(!strncmp(edfhdr->plus_birthdate + 3, "oct", 3))
+                        {
+                          edfhdr->plus_birthdate_month = 10;
+                        }
+                        else if(!strncmp(edfhdr->plus_birthdate + 3, "nov", 3))
+                          {
+                            edfhdr->plus_birthdate_month = 11;
+                          }
+                          else if(!strncmp(edfhdr->plus_birthdate + 3, "dec", 3))
+                            {
+                              edfhdr->plus_birthdate_month = 12;
+                            }
+                            else
+                            {
+                              edfhdr->plus_birthdate_month = 0;
+                            }
+      edfhdr->plus_birthdate_year = edflib_atoi_nonlocalized(edfhdr->plus_birthdate + 7);
     }
 
     for(i=0; i<(80-p);i++)
@@ -3169,8 +3237,16 @@ static int edflib_get_annotations(struct edfhdrblock *edfhdr, int hdl, int read_
 
                 new_annotation->annotation[0] = 0;
 
-                if(duration)  edflib_strlcpy(new_annotation->duration, duration_in_txt, 16);
-                else  new_annotation->duration[0] = 0;
+                if(duration)
+                {
+                  edflib_strlcpy(new_annotation->duration, duration_in_txt, 16);
+                  new_annotation->duration_l = edflib_get_long_time(duration_in_txt);
+                }
+                else
+                {
+                  new_annotation->duration[0] = 0;
+                  new_annotation->duration_l = -EDFLIB_TIME_DIMENSION;
+                }
 
                 for(j=0; j<n; j++)
                 {


=====================================
edflib.h
=====================================
@@ -166,6 +166,7 @@ struct edf_param_struct{         /* this structure contains all the relevant EDF
 
 struct edf_annotation_struct{                           /* this structure is used for annotations */
         long long onset;                                /* onset time of the event, expressed in units of 100 nanoSeconds and relative to the start of the file */
+        long long duration_l;                           /* duration time, expressed in units of 100 nanoSeconds, a value of -10000000 means unused (duration not present) */
         char duration[16];                              /* duration time, this is a null-terminated ASCII text-string */
         char annotation[EDFLIB_MAX_ANNOTATION_LEN + 1]; /* description of the event in UTF-8, this is a null terminated string */
        };
@@ -187,6 +188,9 @@ struct edf_hdr_struct{            /* this structure contains all the relevant ED
   char      patientcode[81];                              /* null-terminated string, is always empty when filetype is EDF or BDF */
   char      gender[16];                                   /* null-terminated string, is always empty when filetype is EDF or BDF */
   char      birthdate[16];                                /* null-terminated string, is always empty when filetype is EDF or BDF */
+  int       birthdate_day;                                /* 1 - 31 */
+  int       birthdate_month;                              /* 1 - 12 */
+  int       birthdate_year;
   char      patient_name[81];                             /* null-terminated string, is always empty when filetype is EDF or BDF */
   char      patient_additional[81];                       /* null-terminated string, is always empty when filetype is EDF or BDF */
   char      admincode[81];                                /* null-terminated string, is always empty when filetype is EDF or BDF */


=====================================
unittest/unittest.c
=====================================
@@ -78,7 +78,7 @@ int main(void)
 
   setlocale(LC_ALL, "C");
 
-  if(edflib_version() != 121)  JUMP_TO_EXIT_ERROR_PROC
+  if(edflib_version() != 122)  JUMP_TO_EXIT_ERROR_PROC
 
   ibuf = (int *)malloc(100 * sizeof(int));
   if(ibuf == NULL)
@@ -811,6 +811,12 @@ int main(void)
 
   if(strcmp(hdr.birthdate, "04 jul 2010"))  JUMP_TO_EXIT_ERROR_PROC
 
+  if(hdr.birthdate_day != 4)  JUMP_TO_EXIT_ERROR_PROC
+
+  if(hdr.birthdate_month != 7)  JUMP_TO_EXIT_ERROR_PROC
+
+  if(hdr.birthdate_year != 2010)  JUMP_TO_EXIT_ERROR_PROC
+
   if(strncmp(hdr.patient_additional, "nop", 3))  JUMP_TO_EXIT_ERROR_PROC
 
   if(strcmp(hdr.admincode, "789"))  JUMP_TO_EXIT_ERROR_PROC
@@ -871,6 +877,8 @@ int main(void)
 
   if(strcmp(annot.duration, ""))  JUMP_TO_EXIT_ERROR_PROC
 
+  if(annot.duration_l != -10000000LL)  JUMP_TO_EXIT_ERROR_PROC
+
   if(strcmp(annot.annotation, "Recording starts"))  JUMP_TO_EXIT_ERROR_PROC
 
   if(edf_get_annotation(hdl, 1, &annot))  JUMP_TO_EXIT_ERROR_PROC
@@ -879,6 +887,8 @@ int main(void)
 
   if(strcmp(annot.duration, "0.1000"))  JUMP_TO_EXIT_ERROR_PROC
 
+  if(annot.duration_l != 1000000LL)  JUMP_TO_EXIT_ERROR_PROC
+
   if(strcmp(annot.annotation, "Test 1"))  JUMP_TO_EXIT_ERROR_PROC
 
   if(edf_get_annotation(hdl, 2, &annot))  JUMP_TO_EXIT_ERROR_PROC
@@ -887,6 +897,8 @@ int main(void)
 
   if(strcmp(annot.duration, ""))  JUMP_TO_EXIT_ERROR_PROC
 
+  if(annot.duration_l != -10000000LL)  JUMP_TO_EXIT_ERROR_PROC
+
   if(strcmp(annot.annotation, "Recording ends"))  JUMP_TO_EXIT_ERROR_PROC
 
   if(edfseek(hdl, 1, 400, EDFSEEK_SET) == 400)  JUMP_TO_EXIT_ERROR_PROC
@@ -2354,6 +2366,12 @@ int main(void)
 
   if(strcmp(hdr.birthdate, "04 jul 2010"))  JUMP_TO_EXIT_ERROR_PROC
 
+  if(hdr.birthdate_day != 4)  JUMP_TO_EXIT_ERROR_PROC
+
+  if(hdr.birthdate_month != 7)  JUMP_TO_EXIT_ERROR_PROC
+
+  if(hdr.birthdate_year != 2010)  JUMP_TO_EXIT_ERROR_PROC
+
   if(strncmp(hdr.patient_additional, "nop", 3))  JUMP_TO_EXIT_ERROR_PROC
 
   if(strcmp(hdr.admincode, "789"))  JUMP_TO_EXIT_ERROR_PROC
@@ -2414,6 +2432,8 @@ int main(void)
 
   if(strcmp(annot.duration, ""))  JUMP_TO_EXIT_ERROR_PROC
 
+  if(annot.duration_l != -10000000LL)  JUMP_TO_EXIT_ERROR_PROC
+
   if(strcmp(annot.annotation, "Recording starts"))  JUMP_TO_EXIT_ERROR_PROC
 
   if(edf_get_annotation(hdl, 1, &annot))  JUMP_TO_EXIT_ERROR_PROC
@@ -2422,6 +2442,8 @@ int main(void)
 
   if(strcmp(annot.duration, "0.2000"))  JUMP_TO_EXIT_ERROR_PROC
 
+  if(annot.duration_l != 2000000LL)  JUMP_TO_EXIT_ERROR_PROC
+
   if(strcmp(annot.annotation, "Test 2"))  JUMP_TO_EXIT_ERROR_PROC
 
   if(edf_get_annotation(hdl, 2, &annot))  JUMP_TO_EXIT_ERROR_PROC
@@ -2430,6 +2452,8 @@ int main(void)
 
   if(strcmp(annot.duration, ""))  JUMP_TO_EXIT_ERROR_PROC
 
+  if(annot.duration_l != -10000000LL)  JUMP_TO_EXIT_ERROR_PROC
+
   if(strcmp(annot.annotation, "Recording ends"))  JUMP_TO_EXIT_ERROR_PROC
 
   if(edfseek(hdl, 1, 500, EDFSEEK_SET) == 500)  JUMP_TO_EXIT_ERROR_PROC



View it on GitLab: https://salsa.debian.org/med-team/edflib/-/commit/57ba90a48d0c6f7c4ee08cfc5c8421dde7196860

-- 
View it on GitLab: https://salsa.debian.org/med-team/edflib/-/commit/57ba90a48d0c6f7c4ee08cfc5c8421dde7196860
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20220717/d883db01/attachment-0001.htm>


More information about the debian-med-commit mailing list