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.
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 |
| 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.
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)
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 supportedfsspeccloud URI such ass3://orgs://. See source locations. - Archives: Read and write
.wfdbarchives. 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.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| wfdb-6.0.0.tar.gz | 274.7 kB | With provenance | Details for wfdb-6.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| wfdb-6.0.0-py3-none-any.whl | Python 3 | none | any | Details for wfdb-6.0.0-py3-none-any.whl |
Total release size: 570.2 kB
Release files / wfdb-6.0.0.tar.gz
| Download URL | wfdb-6.0.0.tar.gz |
|---|---|
| Size | 274.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
62d305347f19cdc34360eb2253540ceec98c7e31faa4c2fd1bdc507fdfcd9413
|
|
BLAKE2b-256 checksum How to use checksums |
69a5163d61a51d1bdeb20cc5d89f726595a5fdd6ec0f18dd3921abadf58a8bbd
|
| 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 logRelease files / wfdb-6.0.0-py3-none-any.whl
| Download URL | wfdb-6.0.0-py3-none-any.whl |
|---|---|
| Size | 295.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e0e618c2963ccdf93b62d20b223c6d920929ab65ef3f7ff0cdeda7f4cf0cf48f
|
|
BLAKE2b-256 checksum How to use checksums |
b5849df20a9533a05720a8e7aba8bbdc976a5edc7ca5ede810c7301593f1e6ee
|
| 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 logSecurity for wfdb 6.0.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.
Attestation for wfdb-6.0.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 logA 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.