ECG Database Applications Guide Table of Contents


sortann - rearrange annotations in canonical order


sortann -r record -a annotator [ options ... ]


Applications that use the DB library (version 9.7 and later versions) may write annotations in any order. Most applications that read annotations, however, expect to find them in time order (with simultaneous annotations ordered by their chan attributes).

sortann rewrites the annotation file specified by record and annotator, arranging its contents in canonical (time and chan) order. By default, DB applications run sortann as needed (from within dbquit or oannclose). If the environment variable DBNOSORT has been set (to any value), sortann will not be run automatically, and a warning message will be printed instead. In most such cases, you should run sortann as instructed by the warning message before reading the annotation file with any other DB application.

If the input contains two or more annotations with the same time and chan fields, only the last one is copied. As a special case of this policy, if the last such annotation has anntyp = 0 (NOTQRS), no annotation is written at that location. Thus a program that generates input for sortann can effectively delete a previously written annotation by writing a NOTQRS annotation at the same location.

The sorted (output) annotation file is always written to the current directory. If the input annotation file is in the current directory, sortann replaces it unless you specify a different output annotator name (using the -o option). Note that the output annotation file is likely to be slightly shorter than the input file, since more compact storage is usually possible when all annotations are sorted.

If the input annotations are already in the correct order, no output is written unless you have used the -o option.

If you attempt to sort a very large annotation file, sortann may run out of memory. If this happens, use the -f and -t options to work on the file in sections of any convenient size, one at a time, then use mrgann(1) to concatenate the sections. Note that you must specify an output annotator name (with -o) when using the -f or -t options (to avoid replacing the entire input file with a sorted subset of its contents).

Running out of memory is unlikely unless:

  1. you have less than 2 Mb of memory and you are attempting to sort a 24-hour or longer annotation file.
  2. .
  3. you have compiled sortann using a 16-bit compiler and you are attempting to sort more than about 4000 annotations (note that the precompiled versions of sortann for MS-DOS and UNIX do not have this limitation).

Options include:

-f time
Begin at the specified time. By default, sortann starts at the beginning of the record.
Print a usage summary.
-o output-annotator
Write output to the annotation file specified by output-annotator and (as specified using -r) record. By default, sortann replaces the input annotation file.
-t time
Stop at the specified time.

The -f and -t options may be used to select a portion of an annotation file for processing.

The shell variable DB should be set and exported (see setdb(1) ).


mrgann(1) , setdb(1)

Table of Contents