File Exchange Pick of the Week

Our best user submissions

EDF Read

Sean‘s pick this week is edfRead by Brett Shoelson.

EDF Read

A MATLAB user asked me yesterday if we have support for the binary file format EDF, short for “European Data Format”. I’d never heard of it. However, apparently my colleague, Brett, had already written a reader for it.

[hdr, record] = edfread('ecgca998.edf');
Step 1 of 2: Reading requested records. (This may take a few minutes.)...
Step 2 of 2: Parsing data...

The function returns the header information and a matrix where each row is the data for that variable.

disp(hdr)
            ver: 0
      patientID: 'X F X Gestation_32+3                                                            '
       recordID: 'Startdate 29-JAN-2004 X X X                                                     '
      startdate: '29.01.04'
      starttime: '23.38.00'
          bytes: 2048
        records: 45
       duration: 5
             ns: 7
          label: {1×7 cell}
     transducer: {1×7 cell}
          units: {'mV'  'mV'  'uV'  'uV'  'uV'  'uV'  ''}
    physicalMin: [-5 -5 -500 -500 -500 -500 -1]
    physicalMax: [5 5 500 500 500 500 1]
     digitalMin: [-32768 -32768 -32768 -32768 -32768 -32768 -32768]
     digitalMax: [32767 32767 32767 32767 32767 32767 32767]
      prefilter: {1×7 cell}
        samples: [5000 5000 5000 5000 5000 5000 500]
      frequency: [1000 1000 1000 1000 1000 1000 100]

Today, it might be easier to store some of this as a table.

T = array2table(record','VariableNames', hdr.label);
T.Properties.VariableUnits = hdr.units;
T.Properties.VariableDescriptions = hdr.transducer;
head(T)
ans =
  8×7 table
    Thorax_1    Thorax_2    Abdomen_1    Abdomen_2    Abdomen_3    Abdomen_4    EDFAnnotations
    ________    ________    _________    _________    _________    _________    ______________
     -1.0331    -0.22179     -22.133       -22.21      -22.118      -22.194        0.37633    
       -1.04     -0.5642     -50.866       -28.13      -66.934      -20.958        0.15688    
     -1.0117    -0.54879     -50.942      -26.009      -65.759      -23.262        0.33596    
    -0.98688    -0.53689     -51.553      -27.901      -67.681      -25.368        0.36086    
    -0.99832    -0.53887     -52.346      -28.832      -66.781      -25.841         0.4078    
     -1.0159    -0.54238     -48.867      -28.527      -65.621      -24.559        0.15792    
     -1.0304    -0.54986     -47.585       -31.67      -67.407      -24.331        0.64312    
     -1.0468    -0.56466     -48.409      -34.203      -70.184      -25.444         0.1588    
summary(T)
Variables:
    Thorax_1: 225000×1 double
        Properties:
            Units:  mV
            Description:  AgAgCl electrodes
        Values:
            Min              -5 
            Median     -0.33333 
            Max               5 
    Thorax_2: 225000×1 double
        Properties:
            Units:  mV
            Description:  AgAgCl electrodes
        Values:
            Min              -5 
            Median     -0.18532 
            Max               5 
    Abdomen_1: 225000×1 double
        Properties:
            Units:  uV
            Description:  AgAgCl electrodes
        Values:
            Min            -500  
            Median      -13.603  
            Max             500  
    Abdomen_2: 225000×1 double
        Properties:
            Units:  uV
            Description:  AgAgCl electrodes
        Values:
            Min            -500  
            Median      -4.2649  
            Max             500  
    Abdomen_3: 225000×1 double
        Properties:
            Units:  uV
            Description:  AgAgCl electrodes
        Values:
            Min            -500  
            Median      -7.7745  
            Max             500  
    Abdomen_4: 225000×1 double
        Properties:
            Units:  uV
            Description:  AgAgCl electrodes
        Values:
            Min            -500  
            Median      -2.2354  
            Max             500  
    EDFAnnotations: 225000×1 double
        Values:
            Min                 0     
            Median              0     
            Max           0.65097     

Comments

Give it a try and let us know what you think here or leave a comment for Brett.

Published with MATLAB® R2018b

|
  • print

Comments

To leave a comment, please click here to sign in to your MathWorks Account or create a new one.