Main Content

addSignals

Add new signals to EDF or EDF+ file

Since R2021a

    Description

    edfw = addSignals(edfw,signallabels,signaldata) adds new signals to the European Data Format (EDF) or EDF+ file with labels in signallabels and data in signaldata.

    example

    edfw = addSignals(___,Name,Value) specifies additional options using name-value pairs. For example, 'DigitalMin',-2048,'DigitalMax',2048 specifies the digital minimum and digital maximum values of sigdata.

    Examples

    collapse all

    Load a labeledSignalSet into the workspace. heartrates contains two electrocardiogram (ECG) signals from the MIT-BIH Arrhythmia Database [1]. The sample rate is 250 Hz.

    load HeartRates

    Create an EDF+ file that contains a header and the first signal in the labeled signal set (y200).

    sig1 = getSignal(heartrates,1);
    sig1 = sig1.y200;
    
    hdr = edfheader("EDF+");
    hdr.SignalLabels = "y200";
    hdr.NumDataRecords = 1;
    hdr.PhysicalMin = min(sig1);
    hdr.PhysicalMax = max(sig1);
    
    edfw = edfwrite("ECG.edf",hdr,sig1, ...
        "InputSampleType","physical");

    Retrieve the second signal from heartrates and add it to the EDF+ file with signal label y203. Specify the physical minimum and maximum values of the second signal.

    sig2 = getSignal(heartrates,2);
    sig2 = sig2.y203;
    sig2Label = "y203";
    
    edfw = addSignals(edfw,sig2Label,sig2, ...
        "PhysicalMin",min(sig2),"PhysicalMax",max(sig2));

    Use edfinfo to view the file properties. The number of signals in the header record is 2.

    edfinfo("ECG.edf")
    ans = 
      edfinfo with properties:
    
                  Filename: "ECG.edf"
               FileModDate: "05-Sep-2024 17:52:02"
                  FileSize: 28814
                   Version: "0"
                   Patient: "1234567 F 05-SEP-2024 Patient_1"
                 Recording: "Startdate 05-SEP-2024 MW_1234567 MW_Inv_01 MW_Eq_01"
                 StartDate: "05.09.24"
                 StartTime: "17.52.01"
               HeaderBytes: 1024
                  Reserved: "EDF+C"
            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]
    
    

    Input Arguments

    collapse all

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

    Signal names, specified as a string vector or cell array of character vectors. The number of signal names must equal the number of input signals in signaldata.

    Data Types: string

    Input signal data, specified as a numeric matrix or cell array of numeric vectors. The number of samples in each signal must be a multiple of the number of data records in NumDataRecords. Specify signaldata as a numeric matrix when all input signals have the same sample rate. If input signals have different sample rates or lengths, specify signaldata as a cell array of numeric vectors.

    Name-Value Arguments

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

    Example: 'PhysicalMin',-5,'PhysicalMax',5 specifies the physical minimum and physical maximum values of the input signal as -5 and 5, respectively.

    Signal minimum physical value, specified as a numeric vector of length NumSignals. The signal physical minimum value must be less than the corresponding signal physical maximum value. PhysicalMin must be specified when InputSampleType is set to 'digital'. If the input sample type is 'physical' and PhysicalMin is not specified, then the function uses the minimum value of each signal as the physical minimum value.

    Data Types: double

    Signal maximum physical value, specified as a numeric vector of length NumSignals. The signal physical maximum value must be greater than the corresponding signal physical minimum value. PhysicalMax must be specified when InputSampleType is set to 'digital'. If the input sample type is 'physical' and PhysicalMax is not specified, then the function uses the maximum value of each signal as the physical maximum value.

    Data Types: double

    Signal digital minimum value, specified as a numeric vector of length NumSignals. The signal digital minimum value must be less than the corresponding signal digital maximum value. DigitalMin values are based on the analog-to-digital converter used to generate signaldata. If not specified, the signal digital minimum value defaults to -32768.

    Data Types: double

    Signal digital maximum value, specified as a numeric vector of length NumSignals. The signal digital maximum value must be greater than the corresponding signal digital minimum value. DigitalMax values are based on the analog-to-digital converter used to generate signaldata. If not specified, the signal digital maximum value defaults to 32767.

    Data Types: double

    Output Arguments

    collapse all

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

    References

    [1] Moody, G.B., and R.G. Mark. “The Impact of the MIT-BIH Arrhythmia Database.” IEEE Engineering in Medicine and Biology Magazine 20, no. 3 (June 2001): 45–50. https://doi.org/10.1109/51.932724.

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

    [3] 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