A2M(1)

NAME
a2m, ad2m, ahaconvert, m2a, md2a - converting between MIT and AHA DB formats

SYNOPSIS
a2m -i ahafile -r record -a annotator [ options ... ]
ad2m -i ahafile -r record [ options ... ]
ahaconvert ahafile ...
m2a -r record -a MIT-annotator AHA-annotator [ options ... ]
md2a -o ahafile -r record [ options ... ]

DESCRIPTION
These programs can be used to convert AHA DB distribution files from half-inch 9-track tape, CD-ROMs, or floppy disks to MIT (PhysioBank) format (i.e., formats that can be read directly by programs compiled with the wfdb(3) library), or to convert files in MIT format into AHA DB tape distribution format (conversion to AHA DB CD-ROM/floppy disk distribution format is not supported). All of these programs print a brief usage summary if invoked with no command-line arguments, or with a -h option.

  a2m

Use a2m to convert AHA-format annotation files into MIT format. Options for a2m include:

-s time
    Shift annotations forward by the specified time (default: no shift for type 0 input files, 5 minutes for type 1, 2 hours and 30 minutes for type 2; for type 3, the default is 5 minutes if record is of the form n2nn or n3nn, or 2 hours and 30 minutes if record is of the form n0nn or n1nn).

-t type
    Convert an input file of the specified type (0: a file produced by a WFDB application using putann and WFDB_AHA_WRITE mode; 1: an AHA DB `short format' tape file; 2: an AHA DB `long format' tape file; 3: an AHA DB compressed (.ano) CD-ROM or floppy disk file). Input files of types 1, 2, and 3 are assumed to contain annotation times in milliseconds, which are converted to sampling intervals based on an assumed sampling frequency of 250 Hz. Default: type 3 is assumed if ahafile ends with .ANO or .ano; type 0 is assumed otherwise.

  ad2m

Use ad2m to convert AHA-format signal files into MIT format. Options for ad2m include:

-c  Convert an AHA DB compressed (.cmp) floppy disk file (this is the default if ahafile ends with .CMP or .cmp, otherwise ad2m assumes that the input is a file in AHA DB tape format).

-f time
    Begin converting at the specified time relative to the beginning of the input file (default: 0, i.e., at the beginning of the input file)

-t time
    Stop converting at the specified time relative to the beginning of the input file (default: 35 minutes after the starting time if record is of the form n2nn or n3nn, 3 hours if record is of the form n0nn or n1nn, or the end of the input file, whichever comes first).

  ahaconvert

Use ahaconvert to convert one or more records from an AHA DB CD-ROM into MIT format. Run ahaconvert without any command-line arguments for instructions, or see the examples below. Note: ahaconvert is a shell script; to use it successfully, you will need to have a shell (standard with all versions of Unix, and included in the free Cygwin package for MS-Windows) as well as ad2m and a2m, which perform the actual work of the conversion.

  m2a

Use m2a to convert MIT-format annotation files into AHA tape format. Options for m2a include:

-s time
    Shift annotation times backward by the specified time, and convert them from sample intervals to milliseconds.

  md2a

Use md2a to convert MIT-format signal files into AHA tape format. Options for md2a include:

-n new-record
    Create a new header file for the AHA-format output signal file, so that it may be read as record new-record.

MIT-format files can be excerpted and reformatted in more generally useful ways using snip(1) or xform(1).

ENVIRONMENT

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

EXAMPLES

  AHA Database CD-ROM
AHA DB CD-ROMs contain two verisons of each record: a 35-minute "short-format" version, and a 3-hour "long-format" version. In most cases, you will want to convert only one version of each record. To convert the short-format records only, if the contents of the CD-ROM are available at /mnt/cdrom, type:
    ahaconvert /mnt/cdrom/?[23]??.cmp
(The pattern '?[23]??' matches the record names of the short-format records.)

To convert the long-format records only, type:
    ahaconvert /mnt/cdrom/?[01]??.cmp

  AHA DB floppy disk
To make a version of AHA DB record 1201 in MIT format, given the distribution floppy disk, copy the files 1201.ano and 1201.cmp to the current directory, then type:
    ad2m -i 1201.cmp -r 1201 -c
    a2m -i 1201.ano -r 1201 -a atr -t 3
These commands produce files 1201.dat (the signal file), 1201.hea (the header file), and 1201.atr (the reference annotation file), all in the current directory. Run ad2m first, so that the new header file is available for the use of a2m. (In this example, note that the options '-r 1201', '-c', and '-t 3' are redundant unless you have renamed the input files, since ad2m and a2m recognize the record name and file types from the suffixes otherwise.)

  AHA DB short format tape

To obtain the same files given a `short format' 9-track distribution tape, copy the second and third files from the tape into files 1201.tap and 1201.ann in the current directory, then type:
    ad2m -i 1201.tap -r 1201
    a2m -i 1201.ann -r 1201 -a atr -t 1
The names for the files copied from the tape are arbitrary, but do not use names of files to be generated by ad2m or a2m (see the previous example). Note that the first and fourth files on the distribution tape contain an `id' block, which can be read by readid (a program included in the convert directory of the WFDB Software Package) to verify the record name. Distribution tapes that contain more than one record contain additional sets of four files, always in the same order within each set.

  AHA DB long format tape

To make a version of the three-hour AHA DB record 1001 in MIT format, given the `long format' distribution tape, copy the second and third files from the tape into files 1001.tap and 1001.ann in the current directory, then type:
    ad2m -i 1001.tap -r 1001 -t 3:0:0
    a2m -i 1001.ann -r 1001 -a atr -t 2
The -t 3:0:0 option is necessary to prevent ad2m from truncating the signal file after the first 35 minutes.

  Converting AHA DB long format to short format

To make a version of AHA DB record 1201 in MIT format, given a `long format' 9-track distribution tape containing the corresponding three-hour record 1001, copy the second and third files from the tape into files 1001.tap and 1001.ann in the current directory, then type:
    ad2m -i 1001.tap -r 1201 -f 2:25:0
    a2m -i 1001.ann -r 1201 -a atr -t 1
In this case, the -f option instructs ad2m to skip the first two hours and 25 minutes of the `long-format' AHA signal file, and to reformat the remainder (equivalent to the 35-minute `short-format' record). The -t 1 option is used with a2m even though its input file comes from a `long-format' tape, because the annotation times must be shifted only by the amount necessary for a `short-format' tape in this case.

  Sharing signal files for long format and short format AHA DB records

To keep both versions (1001 and 1201) on-line, make the `long format' version first (see above), then type:
    a2m -i 1001.ann -r 1201 -a atr -t 1
to make a `short format' reference annotation file. Continue (under UNIX) by:
    cp 1001.hea 1201.hea
or (under MS-DOS) by:
    copy 1001.hea 1201.hea
and edit 1201.hea, replacing `1001' in the first line (only!) with `1201', and replacing `212' in the second and third lines by `212+6525000' (see the description of the `byte offset' field in header(5)). Although two header and reference annotation files are needed, both versions can share the same signal file, allowing a substantial savings in storage requirements. Note that WFDB application programs that read the `short format' record 1201 signal file may report signal checksum errors at the end of the record, unless you also recalculate the signal checksums (easily done using snip(1) to copy the record; delete the copy once the checksums have been obtained).

AVAILABILITY
These programs are provided in the convert directory of the WFDB Software Package. Run make in that directory to compile and install them if they have not been installed already.

SEE ALSO
snip(1), xform(1), wfdb(3), header(5)

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

SOURCES
http://www.physionet.org/physiotools/wfdb/convert/a2m.c
http://www.physionet.org/physiotools/wfdb/convert/ad2m.c
http://www.physionet.org/physiotools/wfdb/convert/ahaconvert
http://www.physionet.org/physiotools/wfdb/convert/m2a.c
http://www.physionet.org/physiotools/wfdb/convert/md2a.c