WFDB Python Package

4.3.1 · active · verified Thu Apr 16

The WFDB Python Package is a native Python library offering tools for reading, writing, processing, and visualizing physiologic signal and annotation data. It adheres to the WFDB format specification and is designed to be user-friendly for researchers and developers working with biomedical waveform data. The current version is 4.3.1, with active development and regular releases addressing compatibility and adding features.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart example demonstrates how to import the `wfdb` library, download and read a record from the PhysioNet 'mitdb' database, plot the physiological signals, and access key metadata like signal data, sampling frequency, and signal names. The `plt.show()` call is important for displaying plots in many environments.

import wfdb
import matplotlib.pyplot as plt

# Download and read a WFDB record from PhysioNet
# '100' is a record name, 'mitdb' is the PhysioNet database directory
record = wfdb.rdrecord('100', pn_dir='mitdb')

# Plot the signal
wfdb.plot_wfdb(record=record, title='Record 100 from MIT-BIH Arrhythmia Database', figsize=(10, 4))
plt.show() # Crucial for displaying plots in non-interactive environments

# Access signal data and metadata
signals = record.p_signal # Physical signals as NumPy array
fs = record.fs # Sampling frequency
sig_names = record.sig_name # Signal names

print(f"Signals shape: {signals.shape}")
print(f"Sampling frequency: {fs} Hz")
print(f"Signal names: {sig_names}")

view raw JSON →