Skip to main content

WFDB for Python

Read, write, and analyze physiologic waveforms and annotations in the WFDB format. WFDB-Python works with local files, records published on PhysioNet, and supported cloud storage.

PyPI Docs

ECG example

Install

WFDB-Python requires Python 3.11 or newer:

pip install wfdb

With uv, use uv add wfdb. On some systems, soundfile also needs a separate installation of libsndfile; see its installation notes.

Start with a record

Read ten seconds of ECG from the MIT-BIH Arrhythmia Database directly from PhysioNet:

import wfdb

record = wfdb.read_record("physionet://mitdb/1.0.0/100", layout="uniform", stop=3600)
print(record.signals.values.shape)  # (3600, 2): frames x channels
print(record.metadata.fs)  # 360 frames per second
print([channel.name for channel in record.metadata.signals])  # ['MLII', 'V5']

read_record returns RecordData: editable signal arrays, fixed metadata, and information about the source. layout="uniform" gives one value per channel per frame; layout="expanded" retains every sample when a channel has several samples per frame. Physical values are the default. For digital integers and a mask of missing samples, pass kind="digital".

For local files, pass a record stem or a .hea path instead of a URI:

record = wfdb.read_record("path/to/record", layout="uniform")
Task API
Read a selected, combined record read_record
Inspect a header without loading samples read_header
Keep a multi-segment record's boundaries read_segments
Write a multi-segment record with its boundaries write_segments
Read an annotation file read_annotations
Plot signals and annotations record.plot(annotation=...)
Write a loaded record or an array write_record or write_signals
Check files before sharing wfdb check

Annotations and plots

Read beat annotations from the same record:

annotations = wfdb.read_annotations("physionet://mitdb/1.0.0/100.atr", stop=3600)
print(annotations.sample_indices[:5])
print(annotations.symbols[:5])

record.plot(
    annotation=annotations,
    plot_sym=True,
    title="MIT-BIH record 100",
)

For a local annotation, pass its filename, such as "path/to/record.atr". plot_wfdb also accepts RecordData directly, while continuing to support legacy Record objects.

For a multi-segment record, plot the original pieces and gaps together:

segments = wfdb.read_segments("path/to/record", layout="uniform")
segments.plot()  # one figure with segment boundaries and shaded gaps

Write records

Use write_record to save a loaded or edited RecordData; it already has channel names, sampling frequency, and other metadata:

selected = record.select(start=0, stop=1000)
wfdb.write_record("selected", selected)

To keep the boundaries of a multi-segment record, read and write its segments instead. This also preserves gaps between segments:

segments = wfdb.read_segments(
    "path/to/multi-segment-record", layout="uniform", start=0, stop=1000
)
segments.write("selected-segments")
# Equivalent: wfdb.write_segments("selected-segments", segments)

If the source uses a format that cannot be written, pass a target format such as formats="16". You can also pass one format per selected channel in master channel order. A fixed-layout selection needs at least one data segment to define its channels; a window containing only gaps cannot be written.

Use write_signals to create a single-segment record from arrays. In that case, supply the sampling frequency, value kind, storage format, channel names, and units:

import numpy as np

signal = np.array([0.0, 0.2, 0.0, -0.2])[:, None]
wfdb.write_signals(
    "example",
    signal,
    fs=250,
    kind="physical",
    formats="16",
    channel_names=["ECG"],
    units=["mV"],
)

This writes example.hea and example.dat. The input has one column per channel; formats specifies the WFDB storage format. See the writing guide for expanded signals, digital calibration, missing samples, archives, and write_annotations.

Check a dataset

Before sharing local files, check a record or a whole directory:

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

The checker reports header syntax problems, missing referenced signal or segment files, and problems in the first signal frame. It checks .hea files and .wfdb archives while ignoring unrelated PDFs and CSVs. This is a preflight check, not a full scan of every sample or annotation. See the checking guide for check_record() and check_dataset().

More ways to use WFDB

  • Remote records: Use a physionet:// URI, an HTTP URL, or a supported fsspec cloud URI such as s3:// or gs://. See source locations.
  • Archives: Read and write .wfdb archives. See the archive guide.
  • Signal processing: Resample signals and detect beats with the processing tools.
  • Conversions: See the conversion guide.

Upgrading from 5.x

In 6.0, read_record returns RecordData instead of a mutable Record or MultiRecord. read_signals has been removed; use read_record instead. Use read_segments when you need uncombined segments, or rdrecord when you need a mutable legacy object. The legacy API remains available. The 6.0 migration guide maps the old fields and calls to their replacements.

Documentation and community

The documentation covers the full API. The demo notebook walks through bundled sample data offline. Report bugs and request features in the issue tracker.

See DEVELOPING.md to contribute. If you use WFDB-Python in research, please cite its PhysioNet publication.

WFDB-Python follows the open WFDB specifications and is inspired by the original WFDB Software Package. The WFDB project website introduces the format and its other implementations.

Metadata

Release files for wfdb 6.1.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 6.1.0
File Size Uploaded Provenance Actions
wfdb-6.1.0.tar.gz 281.7 kB With provenance Details for wfdb-6.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 585.2 kB

Release files / wfdb-6.1.0.tar.gz

Download URL wfdb-6.1.0.tar.gz
Size 281.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a93fc3d9b9c9189355b97770ad7fbe2795c11e649a9e133ab411be50d2eb1e13
BLAKE2b-256 checksum
How to use checksums
c7b0c78650a9a59198bbe94301d3f624bd24297a7e85df801fb675fdceb0627e
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 4, 2026.

Transparency log

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

Download URL wfdb-6.1.0-py3-none-any.whl
Size 303.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cf156ac87e08ed1ffbb5264232855e97bc57db0a49b30f5228c521ec7dc2cc13
BLAKE2b-256 checksum
How to use checksums
eef0f5e58de56f197804637f9a558a41e4656eb063e2b3edeb4cbefd356d8475
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 4, 2026.

Transparency log

Security for wfdb 6.1.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-6.1.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 4, 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

6.1.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