Main Content

edfheader

Create header structure for EDF or EDF+ file

Since R2021a

    Description

    hdr = edfheader(filetype) creates a header structure that can be used to create European Data Format (EDF) or EDF+ files with edfwrite.

    example

    Examples

    collapse all

    Create a header record for an EDF+ file and specify the recording information. Display the header properties.

    hdr = edfheader("EDF+");
    hdr.Patient = "P42Dory F";
    hdr.Recording = "AJMS Device2";
    hdr.StartDate = "27.12.1993";
    hdr.StartTime = "04.22.24";
    hdr.Reserved = "EDF+C";
    hdr.NumDataRecords = 1;
    hdr.DataRecordDuration = seconds(4.22)
    hdr = struct with fields:
                   Patient: "P42Dory F"
                 Recording: "AJMS Device2"
                 StartDate: "27.12.1993"
                 StartTime: "04.22.24"
                  Reserved: "EDF+C"
            NumDataRecords: 1
        DataRecordDuration: 4.22 sec
                NumSignals: []
              SignalLabels: [0x0 string]
           TransducerTypes: [0x0 string]
        PhysicalDimensions: [0x0 string]
               PhysicalMin: []
               PhysicalMax: []
                DigitalMin: []
                DigitalMax: []
                 Prefilter: [0x0 string]
            SignalReserved: [0x0 string]
    
    

    Create a header record for a new EDF file.

    hdr = edfheader("EDF");

    Generate two random 1000-sample signals containing integers in the range [–24000, 32767] and add random noise to the second signal. Plot both signals.

    sigdata = randi([-24000 32767],1000,2);
    sigdata(:,2) = sigdata(:,2) + 0.7*randn(1000,1);
    plot(sigdata)

    Figure contains an axes object. The axes object contains 2 objects of type line.

    Specify header properties based on the two digital signals you created. The digital minimum and maximum values correspond to the extreme values that can occur, so specify these values as –32768 and 32767.

    hdr.NumSignals = 2;
    hdr.NumDataRecords = 1;
    hdr.PhysicalMin = [-3200 -3200];
    hdr.PhysicalMax = [3200 3200];
    hdr.DigitalMin = [-32768 -32768];
    hdr.DigitalMax = [32767 32767];

    Write a new EDF file with the header structure and the random data. View the file properties.

    edfw = edfwrite("rand.edf",hdr,sigdata);
    edfinfo("rand.edf")
    ans = 
      edfinfo with properties:
    
                  Filename: "rand.edf"
               FileModDate: "20-Jul-2024 12:59:18"
                  FileSize: 4768
                   Version: "0"
                   Patient: "1234567 F 20-JUL-2024 Patient_1"
                 Recording: "Startdate 20-JUL-2024 MW_1234567 MW_Inv_01 MW_Eq_01"
                 StartDate: "20.07.24"
                 StartTime: "12.59.18"
               HeaderBytes: 768
                  Reserved: ""
            NumDataRecords: 1
        DataRecordDuration: 1 sec
                NumSignals: 2
              SignalLabels: [2x1 string]
           TransducerTypes: [2x1 string]
        PhysicalDimensions: [2x1 string]
               PhysicalMin: [2x1 double]
               PhysicalMax: [2x1 double]
                DigitalMin: [2x1 double]
                DigitalMax: [2x1 double]
                 Prefilter: [2x1 string]
                NumSamples: [2x1 double]
            SignalReserved: [2x1 string]
               Annotations: [0x2 timetable]
    
    

    Specify a new patient identification record, change the recording start time to 21:12:00, and specify a label for each signal. Display the header structure to see the modified properties.

    hdr.Patient = "20210410 F 27-JUL-2017";
    hdr.SignalLabels = ["sig1" "sig2"];
    hdr.StartTime = "21.12.00"
    hdr = struct with fields:
                   Patient: "20210410 F 27-JUL-2017"
                 Recording: "Startdate 20-JUL-2024 MW_1234567 MW_Inv_01 MW_Eq_01"
                 StartDate: "20.07.24"
                 StartTime: "21.12.00"
                  Reserved: ""
            NumDataRecords: 1
        DataRecordDuration: 1 sec
                NumSignals: 2
              SignalLabels: ["sig1"    "sig2"]
           TransducerTypes: [0x0 string]
        PhysicalDimensions: [0x0 string]
               PhysicalMin: [-3200 -3200]
               PhysicalMax: [3200 3200]
                DigitalMin: [-32768 -32768]
                DigitalMax: [32767 32767]
                 Prefilter: [0x0 string]
            SignalReserved: [0x0 string]
    
    

    Input Arguments

    collapse all

    File type, specified as "EDF" or "EDF+".

    Data Types: string

    Output Arguments

    collapse all

    Header record, returned as a structure with these fields:

    FieldDescription

    Patient

    Patient identification details, returned as a string scalar. Patient identification details can include Patient ID, sex or gender, birth date in 'dd-MMM-yyyy' format, and name.

    Recording

    Recording identification details, returned as a string scalar. Recording identification details may include its start date and time, the ID of the technician that made the recording, and the ID of the equipment that made the recording.

    StartDate

    Recording start date, returned as a string scalar in 'dd.MM.yy' format.

    StartTime

    Recording start time, returned as a string scalar in 'HH.mm.ss' format.

    Reserved

    EDF+ interruption information, returned as "EDF+C" or "EDF+D" for EDF+ compliant files.

    • "EDF+C" — The recording is continuous. There are no interruptions and all data records are contiguous, such that the start time of each data record coincides with the start time of the previous record plus its duration.

    • "EDF+D" — The recording is discontinuous with interruptions between consecutive data records.

    For files that are not EDF+ compliant, this property is an empty string ("").

    NumDataRecords

    Number of data records in file, returned as an integer scalar.

    Note

    If filename is not EDF compliant, NumDataRecords can be set to -1 when the number of data records is unknown. If filename is EDF compliant, NumDataRecords must be set to a positive integer. If filename has Reserved set to a nonempty string and NumDataRecords set to -1, edfinfo throws an error.

    DataRecordDuration

    Duration of each data record, returned as a duration scalar.

    NumSignals

    Number of signals in file, returned as an integer scalar.

    SignalLabels

    Signal names, returned as a string vector of length NumSignals.

    Note

    If SignalLabels is not specified, edfwrite uses the default label "Signal_i" for the ith signal.

    TransducerTypes

    Transducer details, returned as a string vector of length NumSignals. Each element of TransducerTypes contains details about the transducer used to obtain the corresponding signal in SignalLabels.

    PhysicalDimensions

    Signal data units, returned as a string vector of length NumSignals. Each element of PhysicalDimensions contains the measurement units used to express the values of the corresponding signal in SignalLabels.

    PhysicalMin

    Signal minimum physical value, returned as a numeric vector of length NumSignals. Each element of PhysicalMin contains the minimum physical value of the corresponding signal in SignalLabels.

    PhysicalMax

    Signal maximum physical value, returned as a numeric vector of length NumSignals. Each element of PhysicalMax contains the maximum physical value of the corresponding signal in SignalLabels.

    DigitalMin

    Signal minimum digital value, returned as a numeric vector of length NumSignals. Each element of DigitalMin contains the minimum digital value of the corresponding signal in SignalLabels.

    DigitalMax

    Signal maximum digital value, returned as a numeric vector of length NumSignals. Each element of DigitalMax contains the maximum digital value of the corresponding signal in SignalLabels.

    Prefilter

    Signal data units, returned as a string vector of length NumSignals. Each element of Prefilter contains details about the filters, if any, used to preprocess the corresponding signal in SignalLabels.

    SignalReserved

    Additional signal information, returned as a string vector of length NumSignals. Each element of SignalReserved contains additional information, if any, about the corresponding signal in SignalLabels.

    References

    [1] Kemp, Bob, Alpo Värri, Agostinho C. Rosa, Kim D. Nielsen, and John Gade. “A Simple Format for Exchange of Digitized Polygraphic Recordings.” Electroencephalography and Clinical Neurophysiology 82, no. 5 (May 1992): 391–93. https://doi.org/10.1016/0013-4694(92)90009-7.

    [2] Kemp, Bob, and Jesus Olivan. "European Data Format 'plus' (EDF+), an EDF Alike Standard Format for the Exchange of Physiological Data." Clinical Neurophysiology 114, no. 9 (2003): 1755–1761. https://doi.org/10.1016/S1388-2457(03)00123-8.

    Version History

    Introduced in R2021a

    See Also

    Apps

    Objects

    Functions

    External Websites