Analysis example: Generating a heart rate signal

In the rest of this exercise, we'll develop a command for generating a heart rate signal, add it to the WAVE menu, and test it. First, set the Start and End fields to 0 and 1:0 respectively, and click on \ovalbox{\rule[-.3mm]{0cm}{2.5mm}\small\sf ~Mark QRS complexes~} to regenerate the annotation file. Open the annotation file using the Load window.

Generating a heart rate signal is simple enough, given a beat annotation file and tach, a program supplied as part of the WFDB Software Package. tach reads an annotation file, calculates an instantaneous heart rate for each cardiac cycle from the reciprocal of the interval between successive beat annotations, and then uniformily resamples this signal (by default, at 2 Hz). Referring to the WFDB Applications Guide, we find the command we need to generate a heart rate signal from `100s.qrs':

    tach -r 100s -a qrs -f 0 -t 1:0

If this command is typed into the Analysis Commands window, it prints:

These numbers are the calculated samples of the heart rate signal (the units are beats per minute).

We can generalize this command as:

    tach -r $RECORD -a $ANNOTATOR -f $START -t $END
where the parameters $RECORD, $ANNOTATOR, etc., are replaced by the appropriate values when the command is executed. This is the form of the command we should add to WAVE 's menu; by parameterizing the arguments in this way, we can use WAVE to select a record, annotator, and segment to be analyzed as for the other commands in the menu. To add this command to the menu, click on \ovalbox{\rule[-.3mm]{0cm}{2.5mm}\small\sf ~Edit menu~} again. Position the cursor at the end of the menu file and add the line:
   Heart rate<TAB>tach -r $RECORD -a $ANNOTATOR -f $START -t $END
where <TAB> represents one or more TAB characters; at least one TAB must be present (spaces don't count). Be sure to end the line with RETURN. Save the menu (choose Save from the textedit window's \ovalbox{\rule[-.3mm]{0cm}{2.5mm}\small\sf ~File~\ensuremath{\nabla}~} menu), and quit from textedit. Now click on \ovalbox{\rule[-.3mm]{0cm}{2.5mm}\small\sf ~Reread menu~} in the Analyze window. The Analyze window will disappear briefly, then reappear (possibly in a different location, depending on your window manager) with a new \ovalbox{\rule[-.3mm]{0cm}{2.5mm}\small\sf ~Heart rate~} button. If you click on this button, WAVE executes the tach command as above.

You might prefer to look at heart rate as a signal rather than as a column of numbers. tach has the capability of generating an output signal file instead of text. To try this out, edit the menu file again, and add `-o hr_$RECORD' to the end of the entry. (You may split the command across two lines using a `$\tt\backslash$' at the end of the first line if you wish.) Once again, save the menu file, quit from textedit, click on \ovalbox{\rule[-.3mm]{0cm}{2.5mm}\small\sf ~Reread menu~}, and on \ovalbox{\rule[-.3mm]{0cm}{2.5mm}\small\sf ~Heart rate~}. This time, there is no text output from tach; if you enter `hr_100s' in the Record field of the Load window, however, WAVE displays the calculated heart rate signal.

Figure 3.2: Heart rate signal.
(You may wish to change the time and amplitude scales using the View window, in order to see more of the signal at once. If you set the time scale to 250 mm/min and the amplitude scale to 100 mm/mV, you will be able to see the heart rate signal for the entire record as in figure 3.2; the periodic modulation is due to respiratory sinus arrhythmia.)

George B. Moody (