Go to the first, previous, next, last section, table of contents.


Answers to Selected Exercises

3.
280 adu = (280 adu -(-300 adu)) / 10 adu/mmHg = 58 mmHg.
4.
120 mmHg = 120 mmHg * 10 adu/mmHg + ( -300 adu) = 900 adu.
5.
The range of sample values is -2048 to +2047 adu, or -174.8 to +234.7 mmHg.
6.
We don't know how big `signal.dat' is, because we don't know how many other signals are multiplexed with the BP signal. If there are no others, `signal.dat' is 1,500,000 bytes (nsamp * 1.5 bytes/sample). One-third of the space occupied by `signal.dat' could be saved if it were converted to format 8. The maximum slew rate representable in format 8 is 127 adu/sample interval * 100 sample intervals/sec / 10 adu/mmHg = 1270 mmHg/sec.
7.
One way to save a little space is to resample the signal at 120 Hz, and then change to format 8 (maximum slew rate = 1524 mmHg/sec). This can be done using `xform'; it reduces the storage requirement by one-fifth.
8.
On a UNIX system that supports the `graph' and `plot' commands, a simple solution is to write the sample numbers and values on the standard output in two-column ASCII format. The plotting is then performed by the pipeline:
your-program | graph | plot
11.
Line 5 allocates storage for a pointer; in line 12, getann needs storage for the annotation structure. `t' is declared as an int in line 7, which works on a 32-bit machine, but probably not on a 16-bit machine. Line 11 contains three errors (did you find all of them?): the first argument to annopen should be a character string, not an integer; the second argument should be a pointer to a DB_Anninfo object, not the object itself; and (as written) the `if' condition is satisfied only if annopen fails (it returns zero if successful). Line 12 also contains three errors: the first argument to getann is the annotator number, but the first (in this case, the only) input annotator is 0, not 1; the second argument to getann should be, but is not, a pointer to an allocated DB_Annotation structure; and the `while' loop terminates only if getann succeeds. There are two errors in lines 13 and 14: `annot.time' is a long integer (unless long is equivalent to int on your machine, `%d' is an incorrect specification for printing it); and the functions timstr and mstimstr return pointers to static storage that is overwritten by each call. If the other errors are fixed, the printf statement will print the same string twice (which one depends on the order of evaluation of function arguments, which may vary between compilers). Having fixed all of these errors, the output is still incorrect, since getann returns rhythm and signal quality annotations as well as beat labels (only the latter should be used for calculating R-R intervals), and `t' is not initialized, which makes the first interval wrong in any case. As for the extra credit question, the program probably produces nothing at all on its standard output! If, by some miracle, annopen succeeds, it returns zero, and the body of the `if' is never executed. If annopen simply fails, perhaps because the input annotation file can't be opened, getann also fails, and the program probably dumps core with an illegal memory reference in the printf statement, since annot hasn't been initialized. More likely, the program will dump core in annopen, attempting to reference memory location 100.


Go to the first, previous, next, last section, table of contents.



George B. Moody (george@hstbme.mit.edu)