Software Open Access

Waveform Database Software Package (WFDB) for Python

Chen Xie Lucas McCullum Alistair Johnson Tom Pollard Brian Gow Benjamin Moody

Published: Aug. 9, 2022. Version: 4.0.0 <View latest version>


When using this resource, please cite: (show more options)
Xie, C., McCullum, L., Johnson, A., Pollard, T., Gow, B., & Moody, B. (2022). Waveform Database Software Package (WFDB) for Python (version 4.0.0). PhysioNet. https://doi.org/10.13026/mmpm-2v55.

Please include the standard citation for PhysioNet: (show more options)
Goldberger, A., Amaral, L., Glass, L., Hausdorff, J., Ivanov, P. C., Mark, R., ... & Stanley, H. E. (2000). PhysioBank, PhysioToolkit, and PhysioNet: Components of a new research resource for complex physiologic signals. Circulation [Online]. 101 (23), pp. e215–e220.

Abstract

Physiological waveforms - such as electrocardiograms (ECG), electroencephalograms (EEG), electromyograms (EMG) - are generated during the course of routine care. These signals contain information that can be used to understand underlying conditions of health. Effective processing and analysis of physiological data requires specialized software. The waveform-database (WFDB) package for Python is a library of tools for reading, writing, and processing physiological signals and annotations, written in the Python programming language. Core components of the Python package are loosely based on the specifications of the original C-language WFDB software. We aim to implement as many of the core WFDB features as possible, with user-friendly APIs. Additional features are added over time.


Background

Physiological waveforms - such as electrocardiograms (ECG), electroencephalograms (EEG), electromyograms (EMG) - are generated during the course of routine care. These signals contain information that can be used to understand underlying conditions of health. For example, ECGs aid diagnosis of abnormal heart conditions, EEGs aid detection of disorders such as epilepsy, and EMGs aid diagnosis of neuromuscular diseases. Despite the potential utility of waveforms, their complexity and granularity present challenges for retrospective analysis. Effective storage, processing and analysis of physiological signals requires specialized software.

The original Waveform Database (WFDB) Software Package, written in C, provides a large collection of software for processing and analyzing physiological waveforms [1]. Python is an increasingly popular language for data processing and analysis, particularly for tasks such as machine learning [2].


Software Description

This project describes Waveform Database Software Package (WFDB) for Python, a version of the WFDB Software implemented in Python. Core components of the Python package are loosely based on the specifications of the original C-language WFDB software, but there are significant differences between the two implementations. While there are many benefits to working with the original C-language library, most noticeably in terms of speed, Python may be a more familiar language to some researchers. At its core, the package allows users to import functions that can be used to read physiological signal files and associated annotations, to plot the signals and annotations, and to extract features of interest.


Technical Implementation

The development version of the WFDB Software for Python is hosted on GitHub [4]. The code follows standard conventions found in the PEP8 Style Guidelines [5]. Unit tests are written to help ensure integrity of code during development. Core packages used in the implementation include:

  • NumPy, the numerical Python library [6]
  • Pandas, for tabular data structures [7]
  • Scikit-Learn, for scientific models [8]
  • SciPy, for general scientific support [9]
  • MatPlotLib, for visual display of signals [10]

There are a few important concepts that should be well understood before using the WFDB software. These concepts include "records"; "signalssamples, and time"; and "annotations". We suggest reviewing the original WFDB documentation for more details on these concepts [1].


Installation and Requirements

The distribution is hosted on PyPI, the package manager for Python [3]. The software can be installed directly from PyPI using the following command:

$ pip install wfdb

The development version of the WFDB Software for Python is hosted on GitHub [4]. This repository also contains demo scripts and example data. To install the development version, clone or download the repository, navigate to the base directory, and run:

$ pip install .

Once installed, the following example will load a record named "a1031" and plot the waveform to screen. For more examples, please refer to the online documentation [11]:

# import the WFDB package
import wfdb

# load a record using the 'rdrecord' function
record = wfdb.rdrecord('sample-data/a103l')

# plot the record to screen
wfdb.plot_wfdb(record=record, title='Example signals')

Usage Notes

The source code for the WFDB Software is publicly available on GitHub [4]. If you are a user of the software and encounter issues, then we suggest searching to see if the issue is already tracked on the GitHub repository. If not, then please raise a new issue, clearly describing the problem that you have encountered and what steps you have taken to try to address it. We have limited resources to support the software, and so we encourage community contributions via pull requests.

We also highly recommend reviewing documentation on the original C language implementation of the software [1]. This documentation provides detailed background on various aspects of the WFDB library, including file structures, terminology, and general user guidance.

Development of this Python package has been largely independent of the development of the original WFDB package. As a result, there are significant differences between the two implementations. In future, we hope to more closely align the development processes (for example, making efforts to ensure that behavior is consistent across implementations). 


Release Notes

Changes from version 3.4.1 to version 4.0.0:

  • Supports reading WFDB records that contain FLAC signal files. #372
  • Switches to Poetry for package management. #356
  • Sets Python support to >=3.7
  • Supports reading multi-frequency multi-segment records. #331
  • Supports plotting multi-frequency data using plot_wfdb. ​​#348
  • Plots annotations on top of signals in plot functions. #345
  • Aligns signals horizontally in plot_wfdb if possible by default. #390
  • Correctly handles sample numbers > 2**31 in annotation files. #328
  • Fixes bugs when reading formats 8, 310, and 311. #327
  • Removes the ability for rdrecord and rdsamp to read EDF and WAV files. #370
  • Renames edf2mit, mit2edf, wav2mit, mit2wav, and csv2mit to read_edf, wfdb_to_edf, read_wav, wfdb_to_wav, and csv_to_wfdb respectively. #370 See also this note.
  • Moves the above format conversion functions to the wfdb.io.convert submodule. #370

The distribution is hosted on PyPI, the package manager for Python [3]. For the latest stable version of the software, we highly recommend referring to PyPI. For the latest development versions, please refer to GitHub [4].


Ethics

This project contains example data from numerous databases that were previously published on PhysioNet and elsewhere. Many of these example files were originally collected from clinical studies and were de-identified at the time they were published. We do not believe these example files contain personally identifying information of any individual.


Acknowledgements

Development of this software was supported by the National Institute of Biomedical Imaging and Bioengineering (NIBIB) under NIH grant number R01EB030362.


Conflicts of Interest

The authors have no conflicts of interest to declare.


References

  1. Scikit-learn: Machine Learning in Python, Pedregosa et al. (2011) Journal of Machine Learning Research (JMLR). Volume 12, pp. 2825-2830.
  2. Moody, G., Pollard, T., & Moody, B. (2021). WFDB Software Package (version 10.6.2). PhysioNet. https://doi.org/10.13026/zzpx-h016.
  3. Van Rossum, G., & Drake, F. L. (2009). Python 3 Reference Manual. Scotts Valley, CA: CreateSpace.
  4. WFDB on PyPI. https://pypi.python.org/pypi/wfdb/ [Accessed: 1 March 2021]
  5. WFDB Python on GitHub. https://github.com/MIT-LCP/wfdb-python [Accessed: 1 March 2021]
  6. Style Guide for Python (PEP8). https://www.python.org/dev/peps/pep-0020/ [Accessed: 1 March 2021]
  7. Harris, C.R., Millman, K.J., van der Walt, S.J. et al. Array programming with NumPy. Nature 585, 357–362 (2020). https://doi.org/0.1038/s41586-020-2649-2
  8. McKinney, Proceedings of the 9th Python in Science Conference, Volume 445, 2010. https://doi.org/10.25080/Majora-92bf1922-00a
  9. Virtanen P, Gommers R, Oliphant T, ... and SciPy 1.0 Contributors. (2020) SciPy 1.0: Fundamental Algorithms for Scientific Computing in Python. Nature Methods, 17(3), 261-272. https://doi.org/10.1038/s41592-019-0686-2
  10. John D. Hunter (2007) Matplotlib: A 2D Graphics Environment, Computing in Science & Engineering, 9, 90-95. https://doi.org/10.1109/MCSE.2007.55
  11. Documentation for WFDB Python. https://wfdb.readthedocs.io/en/latest/ [Accessed: 1 March 2021]

Parent Projects
Waveform Database Software Package (WFDB) for Python was derived from: Please cite them when using this project.
Share
Access

Access Policy:
Anyone can access the files, as long as they conform to the terms of the specified license.

License (for files):
MIT License

Discovery
Corresponding Author
You must be logged in to view the contact information.
Versions

Files

Total uncompressed size: 233.9 MB.

Access the files
Folder Navigation: <base>/sample-data
Name Size Modified
Parent Directory
multi-segment
03700181.dat (download) 659.2 KB 2021-03-10
03700181.gqrsh (download) 4.1 KB 2022-06-27
03700181.gqrsl (download) 4.0 KB 2022-06-27
03700181.hea (download) 204 B 2021-03-10
03700181.sqrs (download) 2.4 KB 2022-06-27
100-no-len.hea (download) 161 B 2021-03-10
100.atr (download) 4.5 KB 2021-03-10
100.csv (download) 7.9 MB 2021-03-10
100.dat (download) 1.9 MB 2021-03-10
100.hea (download) 166 B 2021-03-10
100.qrs (download) 8.6 KB 2021-03-10
1003.atr (download) 5.8 KB 2021-03-10
1003.hea (download) 323 B 2021-03-10
100_3chan.dat (download) 4.4 KB 2021-03-10
100_3chan.hea (download) 240 B 2021-03-10
100skew.hea (download) 204 B 2021-03-10
12726.anI (download) 698 B 2021-03-10
12726.dat (download) 4.7 MB 2021-03-10
12726.hea (download) 307 B 2021-03-10
12726.wabp (download) 49.6 KB 2021-03-10
12726.wqrs (download) 55.8 KB 2021-03-10
3000003_0003.dat (download) 2.0 KB 2021-03-10
3000003_0003.hea (download) 125 B 2021-03-10
310derive.dat (download) 2.7 KB 2021-03-10
310derive.hea (download) 110 B 2021-03-10
310derive_2.dat (download) 1.3 KB 2021-03-10
310derive_2.hea (download) 128 B 2021-03-10
310derive_3.dat (download) 1.3 KB 2021-03-10
310derive_3.hea (download) 333 B 2021-03-10
311derive.dat (download) 1.3 KB 2021-03-10
311derive.hea (download) 65 B 2021-03-10
311derive_2.dat (download) 1.3 KB 2021-03-10
311derive_2.hea (download) 71 B 2021-03-10
311derive_3.dat (download) 1.3 KB 2021-03-10
311derive_3.hea (download) 177 B 2021-03-10
311derive_4.dat (download) 1.3 KB 2021-03-10
311derive_4.hea (download) 172 B 2021-03-10
SC4001E0-PSG.wav (download) 1.1 MB 2021-03-10
a103l-no-len.hea (download) 196 B 2021-09-16
a103l.hea (download) 195 B 2021-03-10
a103l.mat (download) 483.4 KB 2021-03-10
binformats.d0 (download) 499 B 2022-06-27
binformats.d1 (download) 998 B 2022-06-27
binformats.d2 (download) 998 B 2022-06-27
binformats.d3 (download) 499 B 2022-06-27
binformats.d4 (download) 998 B 2022-06-27
binformats.d5 (download) 749 B 2022-06-27
binformats.d6 (download) 666 B 2022-06-27
binformats.d7 (download) 666 B 2022-06-27
binformats.d8 (download) 1.5 KB 2022-06-27
binformats.d9 (download) 1.9 KB 2022-06-27
binformats.hea (download) 613 B 2022-06-27
drive02-no-len.hea (download) 255 B 2021-09-16
drive02.dat (download) 5.7 MB 2021-03-10
drive02.hea (download) 254 B 2021-03-10
flac_3_constant.dat (download) 20 KB 2022-06-27
flac_3_constant.hea (download) 182 B 2022-06-27
flacformats.d0 (download) 524 B 2022-06-27
flacformats.d1 (download) 881 B 2022-06-27
flacformats.d2 (download) 1.3 KB 2022-06-27
flacformats.hea (download) 205 B 2022-06-27
huge.qrs (download) 34 B 2022-06-27
mixedsignals.hea (download) 380 B 2022-06-27
mixedsignals_e.dat (download) 72.1 KB 2022-06-27
mixedsignals_p.dat (download) 33.2 KB 2022-06-27
mixedsignals_r.dat (download) 6.6 KB 2022-06-27
n16.dat (download) 29.4 MB 2021-03-10
n16.edf (download) 29.4 MB 2021-03-10
n16.hea (download) 308 B 2021-03-10
n8_evoked_raw_95_F1_R9.dat (download) 11.6 MB 2021-03-10
n8_evoked_raw_95_F1_R9.hea (download) 218 B 2021-03-10
p10143.dat (download) 1.7 MB 2021-03-10
p10143.hea (download) 102 B 2021-03-10
s0010_re.dat (download) 900 KB 2021-03-10
s0010_re.hea (download) 2.6 KB 2021-03-10
s0010_re.xyz (download) 225 KB 2021-03-10
test01_00s.dat (download) 31.2 KB 2021-03-10
test01_00s.hea (download) 277 B 2021-03-10
test01_00s_frame.hea (download) 324 B 2021-03-10
test01_00s_skew.hea (download) 343 B 2021-03-10
test01_00s_skewframe.hea (download) 371 B 2021-03-10
test_edfann.edf (download) 60.5 KB 2021-09-16
test_generator_2.dat (download) 2.6 MB 2021-03-10
test_generator_2.edf (download) 2.6 MB 2021-03-10
test_generator_2.hea (download) 817 B 2021-03-10
v102s.dat (download) 439.5 KB 2021-03-10
v102s.hea (download) 232 B 2021-03-10
wave_4.dat (download) 9.1 MB 2021-03-10
wave_4.edf (download) 9.1 MB 2021-03-10
wave_4.hea (download) 447 B 2021-03-10