Next: CALSIG(1) Up: WFDB Applications Guide Previous: ANN2RR(1)On This Page


bxb - ANSI/AAMI-standard beat-by-beat annotation comparator


bxb -r record -a reference-annotator test-annotator [ options ... ]


Using options -C, -L, or -S, bxb implements the beat-by-beat comparison algorithms described in ANSI/AAMI EC38:1998, the American National Standard for Ambulatory ECGs, and in ANSI/AAMI EC57:1998, the American National Standard for Testing and Reporting Performance Results of Cardiac Rhythm and ST Segment Measurement Algorithms. bxb is the reference implementation of these algorithms, and must be used to obtain the beat-by-beat performance statistics cited in EC38 and EC57 in order to be in compliance with these standards (see EC38, section 5.2.14, and EC57, section 4.2). The -C, -L, and -S options also gather statistics on RR interval errors, which were considered for inclusion in EC38, but were eventually dropped from it.

Input to this program consists of two annotation files associated with the same record. One of these is designated the reference annotation file, the other the test annotation file (called the ‘algorithm’ annotation file in EC38 and in EC57).

Options include:

-c file
Append condensed reports (EC57 Table A.2.1 format) to file.
-C file
As for -c, but report RMS RR interval error and SVEB statistics also.
-f time
Begin the comparison at the specified time (default: 5 minutes after the beginning of the record).
Print a usage summary.
-l file1 file2
Append line-format reports (EC57 Tables A.2 and A.3 format) to file1 and file2 respectively (see below).
-L file1 file2
As for -l, but report RMS RR interval error and SVEB statistics also.
Generate an output annotation file (see below).
Generate an expanded output annotation file (see below).
-s file
Append standard reports (EC38, section 5.2.14, and EC57, Table 3 format) to file.
-S file
As for -s, but report RMS RR interval error and SVEB statistics also.
-t time
Stop the comparison at the specified time (default: the end of the record if it is defined, the end of the reference annotation file otherwise; if time is 0, the comparison ends when the end of either annotation file is reached).
Verbose mode (list all beat label discrepancies; see below).
-w time
Set the match window (default: 0.15 seconds; see below).

The statistics gathered by bxb are based on tallies of ‘matching’ annotations in the reference and test annotation files. Matching annotations need not have exactly equal annotation times; the match window specifies the maximum absolute difference in annotation times that is permitted for matching annotations. bxb measures the total shutdown time in the test annotation file as the sum of all intervals that begin with a ‘shutdown’ annotation and that end with a ‘resume’ annotation. (If a period of shutdown does not end before the end of the record, the creator of the annotation file should nevertheless write a ‘resume’ annotation at the end of the record, in order to permit correct shutdown accounting.) This program follows the convention for ‘shutdown’ and ‘resume’ annotations adopted for reference annotation files of the European ST-T database, a convention compatible with that established for the MIT-BIH Arrhythmia Database: ‘shutdown’ annotations are NOISE annotations with bits 4 and 5 (i.e., the ‘16’ bit and the ‘32’ bit) of the subtype field both set; ‘resume’ annotations are NOISE annotations with any other subtype. The convention used in AHA Database reference files, in which unreadable intervals are marked by only one ‘shutdown’ annotation placed near the middle of the interval, is also acceptable; in this case, shutdown is assumed to begin 150 ms after the previous annotation, and it is assumed to end 150 ms before the following annotation.

At most one of -c, -C, -l, -L, -O, -s, and -S can be given as an option. If ‘-’ is given as a file argument, reports are written on the standard output. If no options are specified, bxb writes standard reports on the standard output (equivalent to using the option -s -). The output generated by selecting -l or -L includes column headings only if a file other than ‘-’ is specified, and only if the specified file does not already exist. In this way, bxb can be used repeatedly to build up a line-format table for multiple records, for further processing by sumstats(1) .

The -o option produces an output annotation file with annotator name bxb. The output annotation file contains exact copies of all of the test annotator’s beat labels that match those of the reference annotator, as well as NOTE annotations that describe all mismatches. Mismatched annotation types are mapped into the AAMI ‘test label’ mnemonics (N, V, F, Q, O, and X; if the -C, -L, or -S option is also specified, the mnemonics also include S). The ‘aux’ field of each NOTE annotation indicates the element of the confusion matrix in which the mismatch is tallied (e.g., Nv represents an eventcalled a normal beat by the reference annotator and a ventricular ectopic beat by the test annotator). NOTE annotations that correspond to beats missed by the test annotator are placed at the sample indicated by the reference annotation; all others are placed at that indicated by the test annotation.

The -O option produces a similar output annotation file, in this case containing not only beat labels but all others as well. No summary report is produced if -O is specified. NOTE annotations produced using -O contain unmapped annotation mnemonics from the input annotation files. This option, if used together with -f 0 -w 0, identifies all discrepancies between a pair of annotation files. It can be especially useful for developing reference annotation files for new records.

The -v option specifies that each beat label mismatch is described on the standard output in a format similar to:

where the letters indicate the AAMI mnemonics corresponding to the reference and test annotators’ beat labels, and the numbers indicate the time fields (sample numbers) of the reference and test annotations respectively. Note that O and X mnemonics are generated by bxb as placeholders for missing beat labels; you will not find them in the input annotation files.


It may be necessary to set and export the shell variable WFDB (see setwfdb(1) ).


non-standard comparison selected
The -f, -O, -t, and -w options modify the comparison algorithm used by bxb in ways not permitted by EC38 or EC57. These options are provided for the use of developers, who may find them useful for obtaining a more detailed understanding of algorithm errors.

See Also

ecgeval(1) , epicmp(1) , mxm(1) , rxr(1) , setwfdb(1) , sumstats(1)
Evaluating ECG Analyzers (in the WFDB Applications Guide)
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
The last two publications are available from AAMI, 1110 N Glebe Road, Suite 220, Arlington, VA 22201 USA (


George B. Moody (


Table of Contents

Up: WFDB Applications Guide

Please e-mail your comments and suggestions to, or post them to:

MIT Room E25-505A
77 Massachusetts Avenue
Cambridge, MA 02139 USA

Updated 8 March 2019