Main Content

addAnnotations

Add annotations to EDF or EDF+ file

Since R2021a

    Description

    edfw = addAnnotations(edfw,tsal) adds the annotations in tsal to the European Data Format (EDF) or EDF+ file.

    example

    Examples

    collapse all

    Create a new EDF file that contains a header and a random 10-sample signal.

    sig = randn(10,1);
    hdr = edfheader("EDF");
    hdr.NumSignals = 1;
    hdr.NumDataRecords = 1;
    hdr.PhysicalMin = min(sig);
    hdr.PhysicalMax = max(sig);
    hdr.DigitalMin = -32768;
    hdr.DigitalMax = 32768;
    
    edfw = edfwrite("random.edf",hdr,sig,"InputSampleType","physical");

    Create a timetable that contains three annotations which occur at 2, 3, and 7 seconds. Specify the annotation strings as "Two", "Three", and "Seven". Each annotation duration is 1 second.

    Onset = seconds([2;3;7]);
    Annotations = ["Two" "Three" "Seven"]';
    Duration = seconds(ones(3,1));
    
    tsal = timetable(Onset,Annotations,Duration)
    tsal=3×2 timetable
        Onset    Annotations    Duration
        _____    ___________    ________
    
        2 sec      "Two"         1 sec  
        3 sec      "Three"       1 sec  
        7 sec      "Seven"       1 sec  
    
    

    Add the annotations to edfw. Use edfread to read the data and annotations present in the file. Plot the data and add red vertical lines at each annotation onset.

    edfw = addAnnotations(edfw,tsal);
    [data,anns] = edfread("random.edf");
    plot(data.Signal_1{1})
    xline(seconds(anns.Onset),'r')

    Figure contains an axes object. The axes object contains 4 objects of type line, constantline.

    Input Arguments

    collapse all

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

    List of timestamped annotations, specified as a timetable containing these variables:

    • Onset — Time at which the annotation occurred, expressed as a duration indicating the number of seconds elapsed since the start time of the file. Use Onset to specify the RowTimes in the timetable.

    • Annotations — A string that contains the annotation text.

    • Duration — A duration scalar that indicates the duration of the event described by the annotation. If the file does not specify an annotation duration, this variable is returned as NaN.

    Output Arguments

    collapse all

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

    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