Main Content

modifyAnnotations

Modify annotations in EDF or EDF+ file

    Description

    example

    edfw = modifyAnnotations(edfw,annotationindices,tsal) modifies annotations in edfw with the annotations in tsal at the indices specified in annotationindices.

    Examples

    collapse all

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

    load HeartRates

    Create an annotations timetable using the label values for the first signal in the labeled signal set.

    labels = getLabelValues(heartrates,1,'QRSregions')
    labels=41×2 table
           ROILimits       Value
        _______________    _____
    
        0.556     0.724     QRS 
        1.304       1.4     QRS 
         1.82     1.976     QRS 
        2.628     2.724     QRS 
        3.092     3.292     QRS 
        3.916      4.02     QRS 
        4.384     4.564     QRS 
        5.184     5.272     QRS 
        5.668     5.844     QRS 
        6.428     6.516     QRS 
        6.876     7.048     QRS 
        7.688     7.784     QRS 
        8.192     8.416     QRS 
        9.092     9.208     QRS 
        9.592     9.768     QRS 
        10.34    10.428     QRS 
          ⋮
    
    
    Onset = seconds(labels.ROILimits(:,1));
    Annotations = string(labels.Value);
    Duration = seconds(labels.ROILimits(:,2) - labels.ROILimits(:,1));
    
    tsal = timetable(Onset,Annotations,Duration);

    Create a new EDF+ file that contains a header, the first ECG signal in the labeled signal set, and the annotations.

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

    Modify the annotation at every odd index to "skip". Display the modified annotations in edfw.

    mtsal = tsal(1:2:end,:);
    mtsal.Annotations = repelem("skip",21)';
    
    idx = 1:2:numel(tsal(:,1));
    edfw = modifyAnnotations(edfw,idx,mtsal);
    edfw.Annotations
    ans=41×2 timetable
          Onset      Annotations    Duration 
        _________    ___________    _________
    
        0.556 sec      "skip"       0.168 sec
        1.304 sec      "QRS"        0.096 sec
        1.82 sec       "skip"       0.156 sec
        2.628 sec      "QRS"        0.096 sec
        3.092 sec      "skip"         0.2 sec
        3.916 sec      "QRS"        0.104 sec
        4.384 sec      "skip"        0.18 sec
        5.184 sec      "QRS"        0.088 sec
        5.668 sec      "skip"       0.176 sec
        6.428 sec      "QRS"        0.088 sec
        6.876 sec      "skip"       0.172 sec
        7.688 sec      "QRS"        0.096 sec
        8.192 sec      "skip"       0.224 sec
        9.092 sec      "QRS"        0.116 sec
        9.592 sec      "skip"       0.176 sec
        10.34 sec      "QRS"        0.088 sec
          ⋮
    
    

    Input Arguments

    collapse all

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

    Annotation indices, specified as a numeric vector. The values in annotationindices must be row indices of the Annotations property.

    Data Types: double

    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.

    The number of rows in tsal must be equal to the number of elements in annotationindices.

    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.

    See Also

    Apps

    Objects

    Functions

    External Websites

    Introduced in R2021a