PhysioNet  ·  PhysioBank  ·  PhysioToolkit

PhysioToolkit
open source software for
biomedical science and engineering

Advanced Search | Tour | Mirrors
How to Cite | Contributing | FAQ
Getting Started  ·  Software Index  ·  Matlab Software  ·  WFDB Software  ·  Manuals Site Map

Contributed software for Matlab and Octave

This directory contains software contributed by PhysioNet users for use with Matlab and Octave. Matlab is a popular commercial program that provides an interactive environment for numeric computation and graphics using an interpreted programming language that optionally can be compiled. Octave is a freely available open-source program that is compatible with Matlab. Both Octave and Matlab can run under most popular operating systems, including GNU/Linux, Mac OS X, MS-Windows, and many versions of Unix. Sources for Octave are available here and from the official Octave web site.

Reading and writing PhysioBank and compatible data

PhysioBank data are stored in a variety of formats ("WFDB-compatible formats") that can be read and written using the WFDB library, which is written in C and can be called directly from user-written applications written in C, C++, or Fortran. Digitized signals (waveforms) are most often stored in "format 212", in which pairs of 12-bit samples are bit-packed into three 8-bit bytes. The library can read and write signal files in many other WFDB-compatible formats, and a few of these formats are used for PhysioBank data that cannot be stored in format 212. Although the WFDB library also supports multiple annotation formats, only one of these is used for PhysioBank annotation files, which are binary files containing variable-length annotations averaging slightly over 2 bytes each.

Software available here offers several ways of reading and writing WFDB-compatible files from Matlab, with varying levels of effort required:

  1. Easiest but slowest: Convert the binary files into text format, then parse the text using Matlab or Octave. The programs rdsamp and rdann can convert any desired portions of the binary signal and annotation files into text format (they write to the standard output; you can redirect this into a file or pipe it directly into the standard input of your Matlab application). If you need to create WFDB-compatible files, you can write text in the formats produced by 'rdsamp' and 'rdann', and convert the text to WFDB-compatible binary formats using wrsamp and wrann. These programs are available as part of the WFDB Software Package in C source form and in binaries for GNU/Linux, Mac OS X, MS-Windows, and several versions of Unix. In addition, the rdsamp-O-matic and rdann-O-matic provide web interfaces to rdsamp and rdann. This solution is easy to implement and reasonable for an exploratory project, but it is inefficient.
  2. Faster but limited capability: Use a reimplemented version of the WFDB library in native m-code (or in a mixture of m-code and C compiled with Matlab's built-in C compiler). Jose Garcia Moros and Salvador Olmos have contributed their reimplementations of a useful subset of the WFDB library, which is available here. They can be used to read and write WFDB-compatible annotation files and format 212 signal files using Matlab or Octave. The authors have also provided compiled versions of these files for use with Matlab under GNU/Linux, Solaris, and MS-Windows.
  3. A viewer that displays signals and annotations: Robert Tratnig and Klaus Rheinberger have contributed rddata.m, a Matlab program that reads 1- or 2-channel PhysioBank records stored in format 212 (see signal(5) for a description of this format) and displays them together with annotations in a Matlab figure. Lines 26-29 of this program can be edited to specify the input files. (Note that most PhysioBank records are stored in format 212. The program will warn you if the record you choose is not in this format, or if it contains more than 2 signals. In such cases, you can use xform(1) from the WFDB Software Package to reformat records in other formats and to select 1 or 2 signals from a larger set if necessary.)
  4. A signal file exporter: Use the code available in ECG_Exporter to create .mat files containing digitized signals from PhysioBank and compatible records. This package, contributed by James Lamberg of the University of Minnesota, converts two-signal format 212 records using code from Robert Tratnig's rddata.m, as well as text files created using rdsamp or the rdsamp-O-matic. The package also includes a viewer.
  5. Fastest and most capable, for Matlab R13 (a.k.a. 6.5) and later: Use the standard WFDB library via a set of `wrappers' that make use of the mechanisms for calling external libraries that are supported by Matlab and Octave. The advantage of this approach is that the wrappers allow your Matlab programs to make use of the full range of functionality provided by the WFDB library, including direct access to records stored on PhysioNet and other web servers in addition to local disk files, support for a wide and growing variety of data formats using a uniform API, resampling on-the-fly, and much more. As enhancements are made to the WFDB library (to support new file formats, etc.), they become immediately usable simply by updating your copy of the WFDB library, without requiring any changes to your m-files. This is also the most efficient solution, which may be an important consideration if you plan to analyze a large amount of data.

    Jonas Carlson has contributed a nearly complete set of such wrappers (currently missing only the calibration-related functions and a few other rarely-used functions in the WFDB library); see WFDB_tools. These wrappers are usable with Matlab R13 and later under GNU/Linux, Mac OS X, and MS-Windows, and we expect that they should also be usable on other platforms for which Matlab R13 or a later version is available. (They will definitely not work with earlier versions of Matlab.) If you are interested in contributing to this project, whether as a developer, a tester, or a documentation writer, please write and let us know how you would like to participate.

Other PhysioToolkit software for Matlab and Octave

The directory ECGwaveGen contains software contributed by Floyd Harriott for generating a synthesized ECG-like test signal. A Matlab/Octave implementation of ECGSYN, which generates realistic ECGs, has been contributed by Patrick McSharry and Gari Clifford.

For an example of a large Matlab application that works together with C-language software from the WFDB Software Package, see RCVSIM, contributed by Ramakrishna Mukkamala.

Matlab code for calculating sample entropy (SampEn) has been contributed by Doug Lake, Randall Moorman, and Cao Hanqing, and is available here.

We thank the authors for these generous contributions to PhysioToolkit. If you find these programs useful, please send us a note (or write to the contributors directly).

Icon  Name                    Last modified      Size  Description
[DIR] Parent Directory - [DIR] ECG_Exporter/ 17-May-2005 15:34 - [DIR] ECGwaveGen/ 03-Jan-2003 10:08 - [   ] WFDB_tools.tar.gz 29-Apr-2006 22:35 393K gzip-compressed tar archive [TXT] rddata.m 28-Feb-2003 09:10 5.3K Matlab/Octave source [DIR] wfdb/ 16-Nov-2001 16:43 - [DIR] wfdb_tools/ 01-Dec-2007 08:51 -
Send feedback about this page to PhysioNet

Your comments and suggestions are welcome. We encourage you to use our feedback form to comment on this page. If you would like to receive a reply, please send your comments by email to webmaster@physionet.org, or post them to:

PhysioNet
MIT Room E25-505A
77 Massachusetts Avenue
Cambridge, MA 02139 USA
National Institute of Biomedical Imaging and Bioengineering National Institutes of Health National Institute of General Medical Sciences