Skip to main content

The WFDB Python package: tools for reading, writing, and processing physiologic signals and annotations.

Project description

The WFDB Python Package

signals

tests workflow PyPI Downloads PhysioNet Project Supported Python Versions

Introduction

A Python-native package for reading, writing, processing, and plotting physiologic signal and annotation data. The core I/O functionality is based on the Waveform Database (WFDB) specifications.

This package is heavily inspired by the original WFDB Software Package, and initially aimed to replicate many of its command-line APIs. However, the projects are independent, and there is no promise of consistency between the two, beyond each package adhering to the core specifications.

Documentation and Usage

See the documentation site for the public APIs.

See the demo.ipynb notebook file for example use cases.

Installation

The distribution is hosted on PyPI at: https://pypi.python.org/pypi/wfdb/. The package can be directly installed from PyPI using either pip or poetry:

pip install wfdb
poetry add wfdb

On Linux systems, accessing compressed WFDB signal files requires installing libsndfile, by running sudo apt-get install libsndfile1 or sudo yum install libsndfile. Support for Apple M1 systems is a work in progess (see https://github.com/bastibe/python-soundfile/issues/310 and https://github.com/bastibe/python-soundfile/issues/325).

The development version is hosted at: https://github.com/MIT-LCP/wfdb-python. This repository also contains demo scripts and example data. To install the development version, clone or download the repository, navigate to the base directory, and run:

# Without dev dependencies
pip install .
poetry install

# With dev dependencies
pip install ".[dev]"
poetry install -E dev

# Install the dependencies only
poetry install -E dev --no-root

See the note below about dev dependencies.

Developing

We welcome community contributions in the form of pull requests. When contributing code, please ensure:

  • Documentation is provided. New functions and classes should have numpy/scipy style docstrings.
  • Unit tests are written for new features that are not covered by existing tests.
  • The code style is consistent with the project's formating standards.

Run the formatter with:

black .

Package and Dependency Management

This project uses poetry for package management and distribution.

Development dependencies are specified as optional dependencies, and then added to the "dev" extra group in the pyproject.toml file.

# Do NOT use: poetry add <somepackage> --dev
poetry add --optional <somepackage>

The [tool.poetry.dev-dependencies] attribute is NOT used because of a limitation that prevents these dependencies from being pip installable. Therefore, dev dependencies are not installed when purely running poetry install, and the --no-dev flag has no meaning in this project.

Creating Distributions

Make sure the versions in version.py and pyproject.toml are updated and kept in sync.

It may be useful to publish to testpypi and preview the changes before publishing to PyPi. However, the project dependencies likely will not be available when trying to install from there.

Setup: configure access to repositories:

# Create an API token, then add it
poetry config pypi-token.pypi <my-token>

# For testpypi
poetry config repositories.test-pypi https://test.pypi.org/legacy/
poetry config pypi-token.test-pypi <my-testpypi-token>

To build and upload a new distribution:

poetry build

poetry publish -r test-pypi
poetry publish

Creating Documentation

The project's documentation is generated by Sphinx using the content in the docs directory. The generated content is then hosted on readthedocs (RTD) at: http://wfdb.readthedocs.io

To manage the content on RTD, request yourself to be added to the wfdb project. The project has already been configured to import content from the GitHub repository. Documentation for new releases should be automatically built and uploaded. See the import guide for more details.

There is some redundancy in specifying the Sphinx requirements between pyproject.toml and docs/requirements.txt, the latter of which is used by RTD. Make sure that the content is consistent across the two files.

To generate the HTML content locally, install the required dependencies and run from the docs directory:

make html

Tests

Run tests using pytest:

pytest
# Distribute tests across multiple cores.
# https://github.com/pytest-dev/pytest-xdist
pytest -n auto

Citing

When using this resource, please cite the software publication oh PhysioNet.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wfdb-4.0.0.tar.gz (151.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wfdb-4.0.0-py3-none-any.whl (161.7 kB view details)

Uploaded Python 3

File details

Details for the file wfdb-4.0.0.tar.gz.

File metadata

  • Download URL: wfdb-4.0.0.tar.gz
  • Upload date:
  • Size: 151.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.9.5 Darwin/20.6.0

File hashes

Hashes for wfdb-4.0.0.tar.gz
Algorithm Hash digest
SHA256 e814d59997c0818ad74617a1d4a3412a2ae694d30f3c8c922c8683e54a0fb2fc
MD5 0e2846b0572c75d22704dcdbc1281dda
BLAKE2b-256 8995442cd21d8688577a7a7076e6983ef931bbdf0af3030543a209b2ed7ce121

See more details on using hashes here.

File details

Details for the file wfdb-4.0.0-py3-none-any.whl.

File metadata

  • Download URL: wfdb-4.0.0-py3-none-any.whl
  • Upload date:
  • Size: 161.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.9.5 Darwin/20.6.0

File hashes

Hashes for wfdb-4.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c2130d8af0601df713b295ae10e00172019951734db590cd9b8ba9023cad15b9
MD5 42f622b9c26346c579415842b7707afb
BLAKE2b-256 2b8c9fb860f8370d600665725a39e65086c7681a63462be96d892a0feca19eab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page