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

Reading annotations

This example will illustrate 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 (which might seem like a complicated way to go, but it reflects the way the C wfdb library works) containing the name and mode of the annotation file:

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

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 the annotation file is open and 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: ''

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



George Moody 2003-11-27