Keywords: wfdb_tools

Next: Creating a signal file Up: Using the WFDB_tools library Previous: Reading annotations Contents

# Creating an annotation file

In this example, we will create an annotation file that annotates the first two P-waves of record 100s. These are located at (roughly) sample numbers 315 and 610. First, let's find the annotation code for a P-wave:

        >> WFDB_strann('p')
        ans =
            24

The description is:

        >> WFDB_anndesc(24)
        ans =
        P-wave peak

Create the two annotations:

        >> ANN = WFDB_Annotation(2)
        ANN =
        1x2 struct array with fields:
            time
            anntyp
            subtyp
            chan
            num
            aux
        >> ANN(1).time = 315;
        >> ANN(1).anntyp = 24;
        >> ANN(1).aux = 'First P-wave';
        >> ANN(2).time = 610;
        >> ANN(2).anntyp = 24;
        >> ANN(2).aux = 'Second P-wave';

Now create an annotator structure:

        >> A = WFDB_Anninfo(1)
        A =
            name: 'a1'
            stat: 'WFDB_READ'
        >> A.name = 'p';
        >> A.stat = 'WFDB_WRITE';

Create an empty annotation file to hold the annotations:

        >> WFDB_annopen('100s', A)

Write the annotations:

        >> WFDB_putann(0, ANN)

The first argument of WFDB_putann is the output annotator number. Since we are writing only one annotation file, its annotator number is 0.

Close all open files:

        >> WFDB_wfdbquit

The new annotation file, `100s.p`, will be located in MATLAB's current directory. The result may be verified using WAVE (under Linux) or GTKWave (under MS-Windows). These interactive viewers can be called from MATLAB using:

        >> !wave -r 100s -a p &

(substitute `gtkwave` for `wave` under MS-Windows).

(Remember the !-sign to call system functions from MATLAB and the &-sign to run WAVE as a background process; depending on your setup, using & may cause an error, however, and you may need to run WAVE as a foreground process without the final '&' in the command.)

An elaborated version of this example is provided in the `examples` directory of the WFDB_tools package (look for `example3.m`).

Next: Creating a signal file Up: Using the WFDB_tools library Previous: Reading annotations Contents