next up previous contents
Next: Creating an annotation file Up: Using the WFDB_tools library Previous: Reading signals   Contents

Reading annotations

This example illustrates how to open an annotation file, how to read annotations from it, and how to translate them into their mnemonic and description strings.

First, we need to create an `Anninfo' structure containing the annotator name and mode of the annotation file:

    >> A = WFDB_Anninfo(1)
    A = 
        name: 'a1'
        stat: 'WFDB_READ'

This might seem like a complicated way to go, but it reflects the way the underlying WFDB library works. The record 100s has an annotator named atr, so we need to change the name field of A before issuing the command to open the file.

    >> A.name = 'atr'
    A = 
        name: 'atr'
        stat: 'WFDB_READ'
    >> WFDB_annopen('100s', A)

Now that the annotation file is open, we may read the first two annotations, and take a closer look at the second one.

    >> ANNOTATION = WFDB_getann(0, 2)
    ANNOTATION = 
    2x1 struct array with fields:
        time
        anntyp
        subtyp
        chan
        num
        aux
    >> ANNOTATION(2)
    ans = 
          time: 77
        anntyp: 1
        subtyp: 0
          chan: 0
           num: 0
           aux: ''

The first argument of WFDB_getann is the input annotator number. Since we are reading only one annotation file, its annotator number is 0. (If we had opened a second annotation file for reading, its annotator number would be 1, etc.) Next, let's see what the annotation type (the anntyp field) means, in mnemonic and description:

    >> WFDB_annstr(ANNOTATION(2).anntyp)
    ans =
    N
    >> WFDB_anndesc(ANNOTATION(2).anntyp)
    ans =
    Normal beat

Finally,

    >> WFDB_wfdbquit

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


next up previous contents
Next: Creating an annotation file Up: Using the WFDB_tools library Previous: Reading signals   Contents
George B. Moody 2005-06-02