This is wpg, produced by makeinfo version 4.0b from wpg.tex.

INFO-DIR-SECTION Libraries
START-INFO-DIR-ENTRY
* WFDB library: (wpg).		The Waveform Database library.
END-INFO-DIR-ENTRY


File: wpg,  Node: Signal processing,  Next: Graphics,  Prev: Evaluation,  Up: WFDB Applications

Signal Processing Applications
==============================

     rdsamp -r RECORD [ OPTIONS ... ]
     wrsamp -r RECORD [ OPTIONS ... ]
     snip -i INPUT-RECORD -n NEW-RECORD [ OPTIONS ... ]
     xform -i INPUT-RECORD [ OPTIONS ... ]
     fir [ OPTIONS ... ] -c COEFFICIENT ...
     sigamp -r RECORD [ OPTIONS ...]
     sqrs -r RECORD [ OPTIONS ... ]
     sample [ OPTIONS ... ]
     calsig -r RECORD [ OPTIONS ... ]

   `rdsamp' prints samples from the specified record;  `-f' and `-t'
options may be used to specify a range of sample numbers, and a subset
of signal numbers may be selected using the `-s' option.  The output of
`rdsamp', or any similar text, can be converted into a WFDB record
using `wrsamp'.

   To copy an excerpt of a longer record, use `snip', which creates new
header and signal files for NEW-RECORD in the current directory.  The
beginning and end of the excerpt are specified using `-f' and `-t'
options as for `rdsamp'.  Annotator names may follow a `-a' option; in
this case excerpts from the specified annotation files are copied as
well (the annotations are appropriately time-shifted).

   `xform' is a more general version of `snip'; its main uses are for
reformatting, rescaling, and sampling rate conversion.  You may create a
`hea' file specifying the desired format, sampling frequency, ADC zero
levels, signal gains, etc., and supply it to `xform' using the `-o'
option; if you do not do so, `xform' obtains the required information
interactively.  `xform' accepts all of the options used by `snip', as
well as several others.

   Program `fir' is a general-purpose FIR filter for WFDB records,
similar to the one discussed in chapter 6 (*note Example 7::).

   `sigamp' measures signal amplitudes (either baseline-corrected RMS
amplitudes or peak-to-peak amplitudes);  it may be useful for
calibrating signals (together with `calsig') or for determining signal
gains for `nst'.

   `sqrs' is a slightly modified version of the QRS detector discussed
in chapter 6 (*note Example 10::).  Options allow specification of the
signal and interval to be analyzed and the detection threshold.

   Program `sample' is an MS-DOS application that uses a Microstar
Laboratories DAP 1200- or 2400-series ISA (AT bus) analog interface
board (*note Sources::) to generate database records from analog
signals, or to generate analog signals from database records.  If you
wish to use other hardware for these purposes, refer to chapter 6
(*note Example 8::) and to the source for `sample' as models.

   If you create your own database records using `sample' or other
means, program `calsig' may be useful for determining signal gains and
offsets if your signals include standard calibration pulses or
identifiable signal levels. `calsig' incorporates two independent
algorithms for measuring calibration pulses; it rewrites header files
based on its measurements.


File: wpg,  Node: Graphics,  Prev: Signal processing,  Up: WFDB Applications

Graphical Applications
======================

     wave -r RECORD [ -a ANNOTATOR ]
     view RECORD ANNOTATOR
     wview RECORD ANNOTATOR
     pschart [ [ OPTIONS ... ] SCRIPT ... ]
     psfd [ [ OPTIONS ... ] SCRIPT ... ]

   `wave' is an X Window System client application for viewing and
editing WFDB records.  (`wave' is not included in the WFDB software
package, but is available separately; *note Sources::.)  `wave' can be
run on Unix systems, and can be accessed remotely using networked PCs or
other systems for which X11 servers are available.  Run `wave' without
any arguments to obtain instructions for printing its on-line manual.

   `view', included on the MIT-BIH Arrhythmia Database and European ST-T
Database CD-ROMs, among others, is an MS-DOS application for viewing
WFDB records on CGA, EGA, VGA, SVGA, XGA, or Hercules graphics-capable
PCs.  See `bin.doc' in the `bin' directory of the CD-ROM for more
information.

   `wview', included on recent (1995 and later) CD-ROMs and also
available separately (*note Sources::, is an MS-Windows application for
viewing WFDB records.  It has most of the display capabilities of
`wave', but lacks support for annotation editing.

   `pschart' and `psfd' produce annotated "chart recordings" and
"full-disclosure" plots that can be printed on PostScript devices.
These programs were used to prepare the `MIT-BIH Arrhythmia Database
Directory' and the `European ST-T Database Directory'.


File: wpg,  Node: Extensions,  Next: Sources,  Prev: WFDB Applications,  Up: Top

Extensions
**********

   This section may be helpful if you wish to extend the capabilities of
the WFDB library, or if you wish to port it to another environment.  In
order to make use of the information in this section, you should have
the WFDB library sources (*note Sources::).  The sources are distributed
among four `include' (`.h') files and five `.c' files:

     wfdb.h         Constant and structure definitions, and function prototypes
     ecgcodes.h     Annotation codes
     ecgmap.h       Annotation code mapping macros
     wfdblib.h      External definitions for private WFDB library functions
     
     wfdbinit.c     Functions `wfdbinit', `wfdbquit', and `wfdbflush'
     signal.c       Functions for signals
     calib.c        Functions for signal calibration
     annot.c        Functions for annotations
     wfdbio.c       Low-level I/O and operating system-dependent functions

   The first three of these files are the standard `include' files that
are usually obtained by `#include <wfdb/FILE.h>' statements.  When
modifying the WFDB library, however, make any necessary changes in the
copies of these files that are kept in the library source directory.
Install the modified versions of the `.h' files in the system's
`include' directory after installing the modified WFDB library.

   The cleanest mechanism for adding additional fields to `hea' files is
to include them in `info' strings (*note getinfo::), rather than by
modifying the code that reads and writes `hea' files (in `signal.c').

   A common problem is the need to import signal files generated by
other software.  Often this problem can be solved by writing a format
conversion program that uses input functions provided with the other
software to read the signal files, and `putvec' to write them in one of
the formats supported by the WFDB library.  This solution is unlikely
to be satisfactory if you have many large signal files to import,
however, and you may wish to arrange for `getvec' to read the imported
files directly.  This may be done by defining a new signal file format,
as outlined below.

   To define a new format for signal files, choose a numeric code to
represent your format.  (Values between 900 and 999 are reserved for
user-defined signal file format codes.)  In `wfdb.h', add your format
code to `FMT_LIST' and increment `NFMTS'.  In `signal.c', define
functions (macros if possible for efficiency) for reading and writing
single samples; these should be named `rNNN' and `wNNN', where NNN is
your format code.  Follow the examples in `signal.c'; it will almost
certainly be easier to make use of the existing macros `r8' and `w8'
than to begin from scratch.  Add additional `case' statements in
`getvec' and `putvec', again following the existing models.  You will
also need to add a `case' in `isgsettime', including a formula to
determine the number of bytes needed per sample, given the number of
signals multiplexed.  (All currently-defined formats use fixed-length
encoding.  If you wish to implement variable-length encoding, it may be
easiest to implement an indexed-search method for `isgsettime' in such
cases.)  If the ADC resolution exceeds the number of bits in a C `int'
on your system, change the `typedef' for `WFDB_Sample' in
`<wfdb/wfdb.h>' as necessary;  be aware that this change is likely to
require additional changes to application programs (use `lint' or an
ANSI C compiler to check your code).

   Although the WFDB library generally assumes that signal files are
"pure", it is possible to read imported signal files that contain
prologs (data that precede the first sample).  To do so, you must
construct a header file in which the `format' fields encode the length
of the prolog in bytes (you can do this manually, or use
`wfdbsetstart', *note wfdbsetstart::, for this purpose).  For example,
a signal file with a 512-byte prolog followed by format 16 samples
would be specified using `16+512' in the `format' field or fields (if
the file contains more than one signal, the `format' fields for all
signals in the file must be identical).  Note that this facility is
provided only for signal file import; the WFDB library is not equipped
to create signal files with embedded prologs.

   In a similar fashion, though with substantially more effort in most
cases, you may define a new format for annotation files.  Add additional
`stat' values for reading and writing to the list in `wfdb.h'.  In
`annot.c', add additional `case' statements and code to `annopen',
`getann', `putann', and `wfdb_anclose'.  If you are designing a new
format, you may wish to specify a `magic number' with which your files
will begin, to allow `annopen' to recognize the format automatically; a
good choice of such a number is one in which the first byte is non-zero
(to distinguish it from AHA format files) and the high six bits of the
second byte are zero (to distinguish it from MIT format files).

   Some users may wish to define additional annotation codes.  An easy
and portable way to accomplish this is to use `setannstr' and
`setanndesc' within programs that create your annotation files, before
opening them using `annopen' (or `wfdbinit').  Annotation files created
in this way contain modification labels at the beginning that document
the non-standard code definitions, and that permit them to be read
properly by standard WFDB applications.  Another solution is to modify
the WFDB library.  This method has the disadvantage that all of your
applications that read annotation files must be recompiled, and they
may no longer read standard annotation files properly.  If despite this
disadvantage you prefer to modify the WFDB library, begin by defining
symbolic names and numeric values for your new codes in `ecgcodes.h'.
(Values between 42 and 49 are reserved for user-defined annotation
codes.  Unused values less than 42 may be assigned in future versions
of the WFDB library, and values greater than 49 are reserved to
indicate the presence of optional fields such as `subtyp'.)  Next,
decide how the new codes are to be mapped by `isqrs', `map1', `map2',
`mamap', and `annpos', and set the appropriate entries in each of the
code map arrays in `ecgmap.h'.  Finally, add mnemonic and descriptive
strings for the new codes in the `cstring', `astring', and `tstring'
arrays in `annot.c'.

   The modular design of the library makes it fairly easy to remove
unneeded functionality in order to conserve memory for special
applications.  The `calib.c' package is not referenced by any other
WFDB library modules.  For signal processing applications that do not
involve annotations, the entire `annot.c' package may be removed (with
trivial modifications to the functions in `wfdbinit.c').  If you wish
to add functions to the library, you will find that it will be easier to
maintain your modified version and to merge updates if you preserve the
existing arrangement of functions, which requires no global variables.
Rather than defining global variables, consider implementing query
functions (global-scope functions that read or write local variables).
If you wish to define new types of binary files, consider using the
low-level I/O routines in `wfdbio.c' for reading and writing them in a
machine-independent format.

   Porting the WFDB library to another environment is a straightforward
operation if an ANSI C compiler is available in the target environment.
Since all direct access to database files is performed using the
(private) function `wfdb_open', it is possible to include file name
translation in that function if needed, to accommodate file naming
schemes that may be imposed by the operating system or other
requirements.  If the notion of environment variables is foreign to the
target environment, `getwfdb' can be modified to read the WFDB path
from a file.  You may wish to modify the private function `wfdb_error'
(which is responsible for all error reporting from WFDB library
functions) if the `standard error output' is unavailable or inadequate
for use in the target environment.  All of these functions are
contained within `wfdbio.c'; it is unlikely that any other code will
require changes for a port.

   If you encounter errors while compiling `signal.c', you may wish to
try using the functions provided in that file as alternatives to the
standard macros `r16' and `w16'; the fully-expanded versions of these
macros are quite complex and are known to cause difficulty for at least
one (now obsolete) C compiler.  (Define the symbol `BROKEN_CC' while
compiling `signal.c' in order to obtain the function versions of `r16'
and `w16'.)  While compiling `signal.c', it may be necessary to disable
code optimization for some C compilers;  no current compilers are known
to have such limitations, however.


File: wpg,  Node: Sources,  Next: Answers,  Prev: Extensions,  Up: Top

Sources
*******

   This section is a compendium of sources for databases and related
materials that may be useful to readers of this guide.  Please send any
corrections to the author (<george@mit.edu>).

_WFDB Programmer's Guide (this guide)_
_WFDB Applications Guide_
_WAVE User's Guide_
_MIT-BIH Arrhythmia Database (selected records)_
_MIT-BIH Arrhythmia Database Directory_
_MIT-BIH Polysomnographic Database_
_MIMIC Database_
_Other reference databases of physiologic signals_
_WFDB Software Package_
_W3C libwww sources_
_XView toolkit (needed for WAVE)_

          WWW: `http://www.physionet.org/'

     PhysioNet offers free access via the web to large collections of
     recorded physiologic signals and related open-source software.
     PhysioNet is a public service of the Research Resource for Complex
     Physiologic Signals, funded by the National Center for Research
     Resources of the National Institutes of Health.  The master
     PhysioNet web server is located at MIT in Cambridge, Massachusetts;
     about ten public mirrors are located elsewhere in the US and around
     the world (see `http://www.physionet.org/mirrors/' for a list).

_MIT-BIH Arrhythmia Database CD-ROM_
_MIT-BIH Polysomnographic Database CD-ROM_
_Software for Physiologic Databases with Samples CD-ROM_

          MIT-BIH Database Distribution
          MIT Room E25-505A
          77 Massachusetts Ave.
          Cambridge, MA 02139 USA
          
          email: <george@mit.edu>
          WWW: http://ecg.mit.edu/
          telephone: +1 617 253 7424

_European ST-T Database CD-ROM_
_European ST-T Database Directory_
_VALE Database Directory_

          National Research Council (CNR) Institute of Clinical Physiology
          Dept. of Bioengineering and Medical Informatics
          via Trieste, 41
          56126 PISA, Italy
          
          email:	<taddei@ifc.pi.cnr.it>
          telephone: +39 050 501145
          telefax: +39 050 503596

_AHA Database for Evaluation of Ventricular Arrhythmia Detectors_

          ECRI
          5200 Butler Pike
          Plymouth Meeting, PA 19462 USA
          
          email: <hshupack@shrsys.hslc.org>
          WWW: `http://www.healthcare.ecri.org/'
          telephone: +1 610 825 6000

_MGH/Marquette Foundation Waveform Database CD-ROMs_

          Anaesthesia/Bioengineering Unit
          Massachusetts General Hospital
          Fruit St.
          Boston, MA 02114 USA
          
          email: <cooper@etherdome.mgh.harvard.edu>
          telephone: +1 617 726 8824

     This is a large database of multi-channel recordings (3 ECG leads,
     radial arterial, pulmonary arterial, and central venous pressure,
     respiration, and CO2), which has been issued on 10 CD-ROMs.

_American National Standard ANSI/AAMI EC38:1998, Ambulatory Electrocardiographs_
_American National Standard ANSI/AAMI EC57:1998 Testing and Reporting Performance_
_   Results of Cardiac Rhythm and ST Segment Measurement Algorithms_

          Association for the Advancement of Medical Instrumentation
          1110 N Glebe Road, Suite 220
          Arlington, VA 22201 USA
          
          WWW: `http://www.aami.org/'
          telephone: +1 703 525 4890
          telefax: +1 703 276 0793

_Computers in Cardiology_

          WWW: `http://www.cinc.org/'

     CinC is the major scientific meeting at which current research in
     ECG signal processing and modelling is discussed;  the proceedings
     of the conference are probably the single best source of
     information in print about these topics.  CinC conferences have
     taken place annually since 1974, usually in September; in
     even-numbered years, they are convened in North America, and in
     Europe in odd-numbered years.  The deadline for submission of
     abstracts is 1 May each year.  Proceedings of the conferences are
     published by the IEEE, and usually appear about 3 months after the
     date of the conference.  CinC will be in Memphis, Tennessee in
     2002, and in Thessaloniki in 2003.

_Proceedings of Computers in Cardiology (ISSN 0276-6574)_

          IEEE Customer Service
          445 Hoes Lane
          P.O. Box 1331
          Piscataway, NJ 08855-1331 USA
          
          email: <customer.service@ieee.org>
          WWW: `http://www.ieee.org/ieeestore/'
          telephone: 1 800 678 IEEE (USA and Canada) or +1 732 981 0060
          telefax: +1 732 981 9667

_GNU emacs_
_gcc (the GNU portable C/C++ compiler)_
_ghostscript_
_GNU tar_
_GNU gzip (free and improved replacement for `compress')_
_Larry Wall's `patch' program, with GNU revisions_
_GNU groff, gtbl, and related text formatting utilities_
_GNU info and makeinfo (standalone hypertext browser and formatter)_

          Free Software Foundation
          59 Temple Place - Suite 330
          Boston, MA 02111-1307 USA
          
          email: <gnu@gnu.org>
          WWW: `http://www.gnu.org/'
          telephone: +1 617 542 5942
     GNU software is included in all Linux distributions (in fact,
     since Linux is the name of the kernel only, and the largest
     component of these distributions is actually GNU software, it is
     proper to refer to them as GNU/Linux distributions).  GNU software
     for all popular (and many other) operating systems is available on
     CD-ROM or tape from the address above, and is also freely
     available by anonymous FTP from `ftp.gnu.org' and and many other
     archive sites.  Please support the FSF with a donation if you use
     GNU software.

_TeX for Unix systems_

     This software is available by anonymous FTP from CTAN
     (Comprehensive TeX Archive Network) mirrors, including
     `ftp.tex.ac.uk', `ftp.dante.de', and `ctan.tug.org'.  Many of the
     sources of GNU software (above) also make TeX, etc. available.
     CTAN is indexed on the World Wide Web (one such index is
     `http://www.ctan.org/').

     The Unix TeX distribution is also distributed on CD-ROM and in
     other tape formats by the Free Software Foundation (address above)
     and others.  It is also included with most GNU/Linux distributions
     (see below).

     Several commercial implementations of TeX for MS-DOS, MS-Windows,
     and MacOS are widely available;  visit the web site of the TeX
     Users Group (below) for pointers.

_General information on TeX_

          TeX Users Group
          PO Box 2311
          Portland, OR 97208-2311 USA
          
          WWW: `http://www.tug.org/'
          email: <office@tug.org>
          telephone: +1 503 223 3960
          telefax: +1 503 223 9994

_W3C libwww libraries_


          WWW: `http://www.w3.org/Library/'

     The `libwww' libraries, created and maintained by the World Wide
     Web Consortium, provide the low-level functions needed to support
     the WFDB library's (optional) NETFILES capability.  The `libwww'
     libraries are also available from PhysioNet.

_X11R6 (the X Window System, Version 11, Release 6)_


          email: `xorg_info@x.org'
          WWW: `http://www.x.org/'
          telephone: +1 781 376 8200
          telefax: +1 781 376 9358

     Sources for XView are available from PhysioNet.

_GNU/Linux_
     GNU/Linux is a POSIX-compliant reimplementation of the Unix
     operating system, written by Linus Torvalds and a cast of
     thousands.  It runs on Intel 386, 486, and Pentium PCs, among
     others.  For information about GNU/Linux, visit the web site of
     the Linux Documentation Project:
          WWW: `http://www.linuxdoc.org/'

     GNU/Linux is freely available by anonymous FTP in source and
     binary form from many sites, including:
          tsx-11.mit.edu
          metalab.unc.edu
          ftp.funet.fi

     Many low-cost (typically US$10 to US$30) distributions of
     GNU/Linux on CD-ROMs are widely available.  Among the more popular
     are:

          Debian (non-commercial)
          
          WWW: `http://www.debian.org/'
          
          
          Gentoo (non-commercial)
          
          WWW: `http://www.gentoo.org/'
          
          
          MandrakeSoft S.A.
          43, rue d'Aboukir
          75002 Paris
          France
          
          email: <webmaster@linux-mandrake.com>
          WWW: `http://www.linux-mandrake.com/'
          telephone: +1 626 296 6290 (USA), +33(0) 1 40 41 00 41 (France)
          telefax: +1 801 765 1313
          
          
          Red Hat
          2600 Meridian Parkway
          Durham, NC 27713
          
          email: <orders@redhat.com>
          WWW: `http://www.redhat.com/'
          telephone: 1 888 733 4281 (USA and Canada) or +1 919 547 0012
          telefax: +1 919 547 0024
          
          
          Slackware
          
          email: <info@slackware.com>
          WWW: `http://www.slackware.com/'
          
          
          S.u.S.E. GmbH
          Schanzaeckerstr. 10
          D-90443 Nurnberg
          Germany
          
          email: <suse@suse.de>
          WWW: `http://www.suse.de/' (Germany), `http://www.suse.com/' (USA)
          telephone: +49 911 74053 31
          telefax: +49 911 7417755

_Compilers and software development systems_
     Any ANSI/ISO C compiler (or any K&R C compiler, if you still have
     one) can be used to compile the WFDB library and applications that
     use it.  Under Unix and GNU/Linux, high-quality free compilers and
     development tools are universally available and taken for granted.
     Even if you must work in the MS-Windows or MS-DOS environment,
     however, there is no reason to purchase expensive, bloated, and
     inferior proprietary compilers and software development systems,
     since there are several excellent, highly recommended, and
     completely free alternatives based on the GNU C/C++ compiler (gcc).

     Using any of these packages does not limit you to creating free
     (open source) software, although you are certainly encouraged to
     do so.  If you wish to develop and sell proprietary software using
     `gcc', this is certainly possible, with fewer and less severe
     restrictions than you will encounter if using a commercial
     compiler.

_Cygwin_
     WWW: `http://www.cygwin.com/'

     This is a freely available software development platform for
     MS-Windows 9x/NT/2000/ME/XP, based on GNU `gcc' and a large set of
     Unix utilities developed by the GNU project and ported to
     MS-Windows by Cygnus Software (now part of Red Hat, see above).
     Cygwin itself is open-source software and is highly recommended in
     preference to commercial C/C++ compilers if you must work in the
     MS-Windows environment.  The WFDB Software Package binaries
     available via PhysioNet are created using Cygwin.

_MinGW_
     WWW: `http://www.mingw.org/'

     This is another freely available software development platform for
     MS-Windows, also based on `gcc' and many of the same utilities as
     Cygwin.

_djgpp_
     WWW: `http://www.delorie.com/djgpp/'

     A freely available software development platform for MS-DOS,
     including `gcc', a free 32-bit DOS extender, and many of the same
     utilties as Cygwin and MinGW.

_Microstar DAP analog interface boards for PCs_

          Microstar Laboratories
          2265 116th Avenue N.E.
          Bellevue, WA 98004 USA
          
          email: <info@mstarlabs.com/>
          WWW: `http://www.mstarlabs.com/'
          telephone: +1 425 453 2345
          telefax: +1 425 453 3199

_Web browsers_

     The most popular Web browsers may be downloaded by anonymous FTP.

          Netscape
          FTP: `ftp.netscape.com'
          WWW: `http://www.netscape.com/'
          
          Mozilla
          FTP: `ftp.mozilla.org'
          WWW: `http://www.mozilla.org/'
          
          MS Internet Explorer
          FTP: `ftp.microsoft.com'
          WWW: `http://www.microsoft.com/'


File: wpg,  Node: Answers,  Next: Concept Index,  Prev: Sources,  Up: Top

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 `WFDB_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 `WFDB_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.

