Main Content

modifySignals

Modify signals in EDF or EDF+ file

Since R2021a

    Description

    edfw = modifySignals(edfw,signaldata) modifies all signals present in the European Data Format (EDF) or EDF+ file with the new signals in signaldata.

    example

    edfw = modifySignals(___,Name,Value) specifies additional options using name-value arguments. For example, 'PhysicalMin',-3,'PhysicalMax',6 specifies the signal physical minimum value as –3 and the physical maximum value as 6.

    Examples

    collapse all

    Load EMGdata.mat into the workspace. The file contains eight channels of electromyography (EMG) data [1] recorded from eight arm muscles. The data is available at www.sce.carleton.ca/faculty/chan/index.php?page=matlab. The sample rate is 1000 Hz. Plot the first four channels in data.

    load EMGdata
    fs = 1000;
    t = 0:1/fs:(size(data,1)-1)/fs;
    plot(t,data(:,1:4)) 
    xlabel('Seconds')
    ylabel('mV')

    Figure contains an axes object. The axes object with xlabel Seconds, ylabel mV contains 4 objects of type line.

    Create an EDF+ file that contains a header and signal data from channels 1-4 in data. See edfheader for more information about creating a header structure.

    sig = data(:,1:4);
    hdr = edfheader("EDF+");
    hdr.NumSignals = 4;
    hdr.NumDataRecords = 1;
    hdr.PhysicalMin = min(sig);
    hdr.PhysicalMax = max(sig);
    hdr.DigitalMin = repelem(-32768,4);
    hdr.DigitalMax = repelem(32767,4);
    
    edfw = edfwrite("EMG.edf",hdr,sig,"InputSampleType","physical");

    Modify the signals in edfw with the data from channels 5-8 in data. Use edfread to read the data in EMG.edf and plot the signals.

    modsig = data(:,5:8);
    edfw = modifySignals(edfw,modsig);
    
    x = edfread("EMG.edf");
    for i = 1:4
        y = x.(i){1};
        plot(t,y)
        xlabel('Seconds')
        ylabel('mV')
        hold on
    end

    Figure contains an axes object. The axes object with xlabel Seconds, ylabel mV contains 4 objects of type line.

    Input Arguments

    collapse all

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

    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.

    Note

    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: 'SelectedSignals',["F1" "B1"],'SelectedDataRecords',[1 2] instructs modifySignals to modify the first and second data records of signals F1 and B1.

    Signal names, specified as a string vector or cell array of character vectors. modifySignals modifies the data of the signals with names specified by SelectedSignals.

    Data Types: char | string

    Data records, specified as a numeric vector. modifySignals modifies all the signals in the data records specified by the record indices in SelectedDataRecords.

    Data Types: double

    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. Specify PhysicalMin only when the entire signal is modified. If not specified, the function uses the existing physical minimum value of the corresponding signal.

    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. Specify PhysicalMax only when the entire signal is modified. If not specified, the function uses the existing physical maximum value of the corresponding signal.

    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] Chan, Adrian D.C., and Geoffrey C. Green. 2007. "Myoelectric Control Development Toolbox". Paper presented at 30th Conference of the Canadian Medical & Biological Engineering Society, Toronto, Canada, 2007.

    [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