Skip to main content

WFDB for Python

Read, write, plot, and process physiologic waveforms and annotations with Python. WFDB works with local files and records hosted on PhysioNet, so you can move from a published dataset to NumPy arrays in a few lines of code.

PyPI Docs

ECG

Install

WFDB requires Python 3.11 or newer. Install it from PyPI:

pip install wfdb

If you use uv, run uv add wfdb instead. On some systems, the soundfile dependency also needs a separate installation of libsndfile; see the soundfile installation notes.

Quick start

Read ten seconds of ECG and its beat annotations from the MIT-BIH Arrhythmia Database:

import wfdb

record = wfdb.read_record("physionet://mitdb/1.0.0/100", stop=3600)
annotation = wfdb.read_annotations("physionet://mitdb/1.0.0/100.atr", stop=3600)

print(record.fs)  # Sampling frequency: 360 Hz
print(record.sig_name)  # ['MLII', 'V5']
print(record.p_signal.shape)  # (3600, 2): samples x channels
print(annotation.sample[:5])  # Sample positions of the first five annotations

wfdb.plot_wfdb(record=record, annotation=annotation, title="Record 100")

The physionet:// URI reads data from PhysioNet. For local files, pass the record stem to read_record and the annotation filename to read_annotations:

record = wfdb.read_record("path/to/record")
annotation = wfdb.read_annotations("path/to/record.atr")

record.p_signal is a NumPy array of signals in physical units. Use kind="digital" with read_record to read digital values in record.d_signal. Annotations provide sample positions, symbols, and other label information.

Write a record

Create a WFDB header and signal file from a NumPy array:

import numpy as np
import wfdb

signal = np.array([0.0, 0.2, 0.0, -0.2])[:, None]
wfdb.wrsamp(
    "example",
    fs=250,
    units=["mV"],
    sig_name=["ECG"],
    p_signal=signal,
    fmt=["16"],
)

This writes example.hea and example.dat in the current directory. See wrann to write annotations.

Check records before sharing

Check a local record or dataset directory for common WFDB file problems:

wfdb check path/to/record.hea
wfdb check path/to/dataset

The command checks .hea files and .wfdb archives, including header syntax, record names, referenced signal and segment files, and the first signal frame. It reports the affected file and exits with status 1 when it finds a problem. Other files in the dataset, such as PDFs and CSVs, are ignored. This is a preflight check; it does not read every sample or validate annotations. See the record checking documentation for the Python check_record() and check_dataset() functions.

What else can you do?

  • Work with remote data: Use a physionet:// URI for PhysioNet or a complete HTTP URL for another server. Supported cloud URIs include s3:// and gs:// when the corresponding fsspec backend is installed. The older pn_dir argument still works but is deprecated.
  • Find local records: Use find_record() with an ordered list of directories, or wfdb_search_path() to read local directories from the WFDB environment variable. See the source location guide.
  • Use WFDB archives: Read local .wfdb archives containing a record and its annotations. See the archive documentation.
  • Analyze signals: Use the processing tools for tasks such as resampling and QRS detection.
  • Convert formats: See the conversion guide for supported waveform formats.

WFDB-Python follows the open WFDB specifications. It is inspired by the original WFDB Software Package, but its Python API is documented separately. The WFDB project website introduces the format and the other WFDB implementations.

Documentation and help

The documentation covers the full I/O API, plotting, and processing. The demo notebook is an offline walkthrough using bundled sample data. Report bugs or request features in the issue tracker.

Contributing and citing

See DEVELOPING.md for setup, testing, and contribution guidance. If you use WFDB-Python in research, please cite its PhysioNet publication.

Metadata

Release files for wfdb 5.14.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wfdb 5.14.0
File Size Uploaded Provenance Actions
wfdb-5.14.0.tar.gz 232.8 kB With provenance Details for wfdb-5.14.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for wfdb 5.14.0
File Interpreter ABI Platform Actions
wfdb-5.14.0-py3-none-any.whl Python 3 none any Details for wfdb-5.14.0-py3-none-any.whl

Total release size: 482.0 kB

Release files / wfdb-5.14.0.tar.gz

Download URL wfdb-5.14.0.tar.gz
Size 232.8 kB
Tags Source
SHA-256 checksum
How to use checksums
99d1dd1ab0c4d42ea8a61fb89f933979cb2da782cc6ea25889e7ee46d3db883e
BLAKE2b-256 checksum
How to use checksums
dd74a24201b0a535593356f6b5b39dfda34ac9ac31ccdbaa364c78c370c31100
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Release files / wfdb-5.14.0-py3-none-any.whl

Download URL wfdb-5.14.0-py3-none-any.whl
Size 249.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
12e3c91a489de8d27846e8fc73c7a3d949e5a84626c78d7023a580c9cfc39a65
BLAKE2b-256 checksum
How to use checksums
a42ef831bd219c4fde72b4392e81bf521ccc74ee2045cee548c972a4178670a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Security for wfdb 5.14.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for wfdb-5.14.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

5.14.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page