Main Content


Modify header details of EDF or EDF+ file

Since R2021a



    edfw = modifyHeader(edfw,hdr) modifies header fields in edfw using the header specified in the structure hdr.


    collapse all

    Create a header record for an EDF file and specify the patient identification, recording information, and start time.

    hdr = edfheader("EDF");
    hdr.Patient = "001 M 2020";
    hdr.Recording = "This is the original header record";
    hdr.StartTime = "00.00.01"
    hdr = struct with fields:
                   Patient: "001 M 2020"
                 Recording: "This is the original header record"
                 StartDate: "12.02.24"
                 StartTime: "00.00.01"
                  Reserved: ""
            NumDataRecords: -1
        DataRecordDuration: 1 sec
                NumSignals: []
              SignalLabels: [0x0 string]
           TransducerTypes: [0x0 string]
        PhysicalDimensions: [0x0 string]
               PhysicalMin: []
               PhysicalMax: []
                DigitalMin: []
                DigitalMax: []
                 Prefilter: [0x0 string]
            SignalReserved: [0x0 string]

    Create a new EDF file that contains the header record and a random 10-sample signal. Specify in hdr the number of signals and the signal physical minimum and maximum values. Set the input sample type as physical.

    sig = randn(10,1);
    hdr.NumSignals = 1;
    hdr.PhysicalMin = min(sig);
    hdr.PhysicalMax = max(sig);
    edfw = edfwrite("file.edf",hdr,sig,"InputSampleType","physical");

    Create a new header structure with modified patient, recording, and start time information.

    newhdr.Patient = "002 F 2020";
    newhdr.Recording = "This is a test";
    newhdr.StartTime = "11.11.10";

    Modify the original header record in file with the new information in newhdr. Display the file properties.

    edfw = modifyHeader(edfw,newhdr);
    ans = 
      edfinfo with properties:
                  Filename: "file.edf"
               FileModDate: "12-Feb-2024 21:34:55"
                  FileSize: 532
                   Version: "0"
                   Patient: "002 F 2020"
                 Recording: "This is a test"
                 StartDate: "12.02.24"
                 StartTime: "11.11.10"
               HeaderBytes: 512
                  Reserved: ""
            NumDataRecords: -1
        DataRecordDuration: 1 sec
                NumSignals: 1
              SignalLabels: "Signal_1"
           TransducerTypes: ""
        PhysicalDimensions: ""
               PhysicalMin: -2.2588
               PhysicalMax: 3.5784
                DigitalMin: 0
                DigitalMax: 0
                 Prefilter: ""
                NumSamples: 10
            SignalReserved: ""
               Annotations: [0x2 timetable]

    Input Arguments

    collapse all

    EDF or EDF+ file, specified as an edfwrite object.

    Header, specified as a structure. hdr can contain one or more of these fields:

    • Patient

    • Recording

    • StartDate

    • StartTime

    • SignalLabels

    • TransducerTypes

    • PhysicalDimensions

    • PhysicalMin

    • PhysicalMax

    • DigitalMin

    • DigitalMax

    • Prefilter

    • SignalReserved

    See edfheader for more information about the possible fields in the header structure.

    Data Types: struct

    Output Arguments

    collapse all

    EDF or EDF+ file, returned as an edfwrite object.


    [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.

    [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.

    Version History

    Introduced in R2021a

    See Also




    External Websites