Next: WFDBCAT(1) Up: WFDB Applications Guide Previous: WFDB-CONFIG(1)On This Page

Name

wfdb2mat - convert WFDB-compatible signal file to Matlab .mat file

Synopsis

wfdb2mat -r record [ options ... ]

Description

This program converts the signals of any PhysioBank record (or one in any compatible format) into a record.mat file that can be read directly using any version of Matlab, and a short record.hea text file containing information about the signals (names, gains, baselines, units, sampling frequency, and start time/date if known). In addition, wfdb2mat writes a brief summary of this information to the standard output.

The .mat and .hea output files can also be read by any WFDB application as record RECm.

This program does not convert annotation files; for that task, rdann(1) is recommended.

The output .mat file contains a single matrix named val, containing raw (unshifted, unscaled) samples from the selected record. Using various options (below), one can select any time interval within a record, or any subset of the signals, which can be rearranged as desired within the rows of the matrix. Since .mat files are written in column-major order (i.e., all of column n precedes all of column n+1), each vector of samples is written as a column rather than as a row, so that the column number in the .mat file equals the sample number in the input record. If this seems odd, transpose your matrix after reading it!

This program writes version 4 MAT-file format output files (see http://www.mathworks.com/access/helpdesk/help/pdf_doc/matlab/matfile_format.pdf for details). The samples are written as 32-bit signed integers in little-endian format if the record contains any format 24 or format 32 signals, as 8-bit unsigned integers if the record contains only 8-bit unsigned samples, or as 16-bit signed integers in little-endian format otherwise. Although version 5 and newer versions of Matlab normally use a different (less compact and more complex) format, they can read these files without difficulty. The advantage of version 4 MAT-file format, apart from compactness and portability, is that files in these formats are still WFDB-compatible, given the .hea file constructed by this program.

Options for wfdb2mat include:

-f time
Begin at the specified time. By default, wfdb2mat starts at the beginning of the record.
-h
Print a brief usage summary.
-H
Read the signal files in high-resolution mode (default: standard mode). These modes are identical for ordinary records. For multifrequency records, the standard decimation of oversampled signals to the frame rate is suppressed in high-resolution mode (rather, all other signals are resampled at the highest sampling frequency).
-l interval
Limit the amount of output to the specified time interval (in standard time format; default: no limit). If both -l and -t are used, wfdb2mat stops at the earlier of the two limits.
-s signal-list
Convert only the signals named in the signal-list (one or more input signal numbers or names, separated by spaces; default: print all signals). This option may be used to re-order or duplicate signals.
-S signal
Search for the first valid sample of the specified signal (a signal name or number) at or following the time specified with -f (or the beginning of the record if the -f option is not present), and begin converting at that time.
-t time
Stop at the specified time. By default, wfdb2mat stops at the end of the record.

Example

To convert record mitdb/200, use this command:
   wfdb2mat -r mitdb/200

This works even if the input files have not been downloaded; in this case, wfdb2mat reads them directly from the PhysioNet server.

The output files are mitdb/200m.mat and mitdb/200m.hea. Note that if a subdirectory of the current directory named mitdb did not exist already, it would be created by wfdb2mat. In addition, if the standard output of wfdb2mat has been saved in a file named mitdb/200m.info, then the converted data can be read and plotted in Matlab or Octave from within the mitdb directory by running the command:
   plotATM(’200m.mat’, ’200m.info’)

(Download http://physionet.org/physiotools/matlab/plotATM.m and install it in your Matlab or Octave environment first.)

Note that when EDF (or EDF+, BDF, or BDF+) files are used as input, they may have empty ’physical dimension’ (units) fields, which imply that the associated signals are dimensionless (for example, they may be event markers or categorical variables). In such cases, wfdb2mat records the signal units as nd (no dimension).

Environment

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

Availability

This program is provided in the convert directory of the WFDB Software Package. Run make in that directory to compile and install it if it has not been installed already.

The PhysioNet ATM (http://physionet.org/cgi-bin/ATM) provides web access to wfdb2mat (select Export signals as .mat from the Toolbox).

See Also

a2m(1) , edf2mit, snip(1) , wav2mit(1) , xform(1) , wfdb(3) , header(5)

http://physionet.org/physiotools/matlab/plotATM.m

Author

George B. Moody (george@mit.edu)

Sources

http://www.physionet.org/physiotools/wfdb/convert/wfdb2mat.c


Table of Contents

Up: WFDB Applications Guide


Please e-mail your comments and suggestions to webmaster@physionet.org, or post them to:

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

Updated 10 June 2022