WFDB Python package version 5.0.0
We have released version 5.0.0 of wfdb, the Python package for reading, writing and processing physiologic signals and annotations in the WFDB format. Install or upgrade it with pip install --upgrade wfdb. This version requires Python 3.11 or later.
Store a record in a single file. A record can now be kept in one .wfdb archive, a ZIP file containing its header, signal and annotation files. Pass the path of the archive to rdrecord, rdsamp, rdheader or rdann to read from it, and use the wfdb_archive argument of wrsamp to write one. Part of a signal can be read without unpacking the whole archive.
import wfdb
record = wfdb.rdrecord("100.wfdb", sampfrom=1000, sampto=2000)
annotation = wfdb.rdann("100.wfdb", "atr")
Read records from more places. rdrecord, rdsamp and rdheader now accept memory:// URIs, so files uploaded through a web form can be read without writing them to disk. Cloud storage URIs, such as s3:// and gs://, now also work on Windows for signal files and multi-segment records.
Spend less time waiting. Signal files on PhysioNet that are read in small pieces, such as FLAC files, are now fetched in larger requests: a 7.4 MB MIMIC-IV signal file takes 8 requests instead of 229, which saves several minutes per file. Requests to PhysioNet now time out instead of waiting indefinitely when the server does not respond. Reading annotation files is 2 to 3 times faster, writing a 4-hour, 8-channel record at 500 Hz in format 16 uses about 110 MB of memory instead of 2 GB, and XQRS no longer takes hours on records with long stretches without beats.
Check results that may have changed. Several fixes change the results of existing code:
ann2rrnow uses only beat annotations, as the WFDBann2rrprogram does, andstart_timeandstop_timeselect intervals by when they end in the record. Passall_annotations=Trueto include all annotations as before.XQRSdetections may change slightly, becausefind_local_peaksnow searches the full window on both sides of each sample.- When a signal with more than one sample per frame is read with
smooth_frames=True(the default), a frame containing an invalid sample now gives NaN instead of a large, valid-looking value. resample_signow returns NaN where the input is missing, instead of filled-in values.compute_hrnow uses the last RR interval for the heart rate after the last beat, andRecord.to_dataframetimestamps no longer drift over long records.
from wfdb.processing import ann2rr
rr = ann2rr("100", "atr", all_annotations=True) # behaviour of earlier versions
The release also fixes compare_annotations, correct_peaks, csv_to_wfdb, wfdb_to_mat, wfdb_to_wav, rdedfann and wrann, among others. See the changelog for the full list of changes, and the documentation for details of each function.
The package is open source. Thank you to everyone who contributed code, reported issues and reviewed changes for this release. Questions and bug reports are welcome on the GitHub issue tracker.
Read more: https://github.com/MIT-LCP/wfdb-python/releases/tag/v5.0.0
