ann2rr, rr2ann - convert annotation files to interval lists and vice
ann2rr -r record -a annotator [ options ... ]
rr2ann -r record -a annotator [ options ... ]
These programs are
typically used to obtain RR interval series from ECG annotation files,
or to create an annotation file from such a series, but they have a wider
range of uses.
Use ann2rr to extract a list of intervals, in text
format, from an annotation file. By default, the intervals are listed in
units of sample intervals (use sampfreq(1)
to determine the sampling frequency
of the input record if necessary). Options for ann2rr include:
all intervals between annotations. By default, ann2rr prints only RR intervals
(those between QRS (beat) annotations). This option overrides the -c and
- Print intervals between consecutive valid annotations only.
(See discussion below.)
- -f time
- Begin at the specified time. By default,
ann2rr starts at the beginning of the record.
- Print a usage summary.
- Print intervals in the specified format. By default, intervals are
printed in units of sample intervals. Other formats include s (seconds),
m (minutes), h (hours), and t (time interval in hh:mm:ss format). Formats
s, m, and h may be followed by an integer between 0 and 15 inclusive, specifying
the number of decimal places (default: 3). For example, use the option
-is8 to obtain intervals in seconds with 8 decimal places.
- -p type [ type
- Print intervals ended by annotations of the specified types only. The
type arguments should be annotation mnemonics (e.g., N), as normally printed
in the third column. More than one -p option may be used in
a single command, and each -p option may have more than one type argument
following it. If type begins with ‘‘-’’, however, it must immediately follow
-p (standard annotation mnemonics do not begin with ‘‘-’’, but modification labels
in an annotation file may define such mnemonics).
- -P type [ type ... ]
intervals begun by annotations of the specified types only.
- -t time
at the specified time.
- -v format
- Print final times (the times of occurrence
of the annotations that end each interval). This option accepts all of
the formats defined for -i, as well as T (to print the date and time in
[hh:mm:ss dd/mm/yyyy] if the starting time and date have been recorded
in the header file for record). If this option is chosen, the times appear
at the end of each line of output.
- -V format
- Print initial times (the times
of occurrence of the annotations that begin each interval). Any of the
formats usable for the -v option may be used with -V. If this option is chosen,
the times appear at the beginning of each line of output.
- Print final
annotations (the types (N, V, etc., as for -p above) of the annotations that
end each interval), immediately following the intervals in each line of
- Print initial annotations (the types of the annotations that begin
each interval), immediately before the interval in each line of output.
The -c option, used without the -p option, causes ann2rr to filter out intervals
between beats that have intervening non-beat annotations, such as rhythm
or signal quality change annotations. Used with the -P and -p options, the
-c option causes ann2rr to reject intervals between annotations of the type(s)
specified by -p if there are annotations of any other types intervening;
thus, for example, ‘‘-c -P N -p N’’ yields only intervals between consecutive
normal beats, and intervals between pairs of normal beats surrounding an
ectopic beat are discarded from the output. As another example, ‘‘-c -P N -p
V’’ yields premature ventricular coupling intervals only (a coupling interval
is the interval between a normal beat and an immediately following premature
The default output contains a single column of
intervals only; by using the -v, -V, -w, and -W options, up to five columns,
separated by tabs, may be output. The order of the columns is fixed (initial
times, initial annotations, intervals, final annotations, final times).
Use rr2ann to create an annotation file from the standard input,
which should usually be a list of intervals in the format produced by ann2rr.
(For exceptions, see -T, -w, and -x below.) The first token on each line is
taken as an interval, and (if the -w option is present) the second token
is taken as an annotation mnemonic; anything else on the same line is ignored,
as are empty lines, spaces and tabs at the beginning of a line, non-numeric
tokens and anything following them on the same line, negative intervals,
and zero intervals. The output consists of a binary annotation file (record.annotator),
and (if it does not exist already) a text header file (record.hea). Options
for rr2ann include:
- -F frequency
- Assume the specified sampling frequency.
This option has no effect unless it is necessary for rr2ann to create
a header file; in this case, a sampling frequency of 250 Hz is assumed
if the -F option is omitted.
- Print a usage summary.
- Interpret the input
as times of occurrence, rather than as intervals.
- Set each annotation
type from the mnemonic (N, V, etc.) in the second column of the input (in
the format produced by ann2rr using its -w option).
- -x n
- Multiply input by
n to obtain intervals (or, if -T is also used, times of occurrence) in units
of sample intervals). Default: n = 1.
Note that wrann(1)
also provides a
way to generate an annotation file from text. Unlike that of rr2ann, wrann’s
input format permits specifying annotation subtypes and other fields.
may be necessary to set and export the shell variable WFDB (see setwfdb(1)
programs are provided in the app directory of the WFDB Software Package.
Run make in that directory to compile and install them if they have not
been installed already.
- header file
- annotation file
The PhysioNet ATM (http://physionet.org/cgi-bin/ATM)
provides web access to ann2rr (select Show RR intervals as text from the
B. Moody (email@example.com)
Table of Contents
Up: WFDB Applications Guide
Please e-mail your comments and suggestions to firstname.lastname@example.org, or post them to:PhysioNet
MIT Room E25-505A
77 Massachusetts Avenue
Cambridge, MA 02139 USA
Updated 8 March 2019