Skip to main content

HeartPy - Python Heart Rate Analysis Toolkit

DOI Build Status codecov PyPI - Python Version

Structural update

HeartPy V1.2 has landed! The structure of the package has been reworked to be in separate modules now in preparation of the next big update, which will feature many analysis expansions and the first steps towards a GUI for HeartPy. HeartPy has been growing steadily and had reached the point where it became cluttered and unwieldy to keep in a single file. The API remains unchanged.

An 'Examples' folder has been added to the repo which will be expanded soon. Now there's two notebooks explaining how to analyse ppg signals from smartwatches and smart rings.

Installation

python -m setup.py install

Alternatively, we're also on PIP:

python -m pip install heartpy

That's it!

Official Documentation

The official documentation is online! You can find the official documentation here

Python 2.7 support

The module compiles and and runs fine on Python 2.7, but the unit tests fail due to formatting differences in outputs between Python 2 and Python 3. You can still install and use HeartPy on Python 2.7 if you want.

More information

HeartPy, the Python Heart Rate Analysis Toolkit is a module for heart rate analysis in Python. It started as pure-python implementation to analyse physiological data taken in naturalistic driving and cycling experiments.

The module takes a discrete heart rate signal and outputs time-domain and frequency-domain measures often found in scientific literature:

Time domain:

  • beats per minute, BPM
  • interbeat interval, IBI
  • standard deviation if intervals between adjacent beats, SDNN
  • standard deviation of successive differences between adjacent R-R intervals, SDSD
  • root mean square of successive differences between adjacend R-R intervals, RMSSD
  • proportion of differences between R-R intervals greater than 20ms, 50ms, pNN20, pNN50
  • median absolute deviation, MAD

Frequency domain

  • low frequency component (0.04-0.15Hz), LF
  • high frequency component (0.16-0.5Hz), HF
  • lf/hf ratio, Lf/HF

When using the package in your research, please cite:

van Gent, P., Farah, H., van Nes, N., & van Arem, B. (2018). Heart Rate Analysis for Human Factors: Development and Validation of an Open Source Toolkit for Noisy Naturalistic Heart Rate Data. In Proceedings of the 6th HUMANIST Conference (pp. 173–178).

van Gent, P. Van, Farah, H., Nes, N. Van, & Arem, B. Van. (manuscript submitted). Analysing Noisy Driver Physiology Real-Time Using Off-the-Shelf Sensors: Heart Rate Analysis Software from the Taking the Fast Lane Project.. Doi: doi.org/10.13140/RG.2.2.24895.56485

Documentation

You can find the official documentation here

The module is also to some extent described in my tutorial series:

License

The module is licensed under the GNU General Public License Version3, GPL-v3

Validation

Initial results of the validation have been reported in [1, 2]. Updates here are soon to follow once the papers are published.

[1]van Gent, P., Farah, H., van Nes, N., & van Arem, B. (2018). Heart Rate Analysis for Human Factors: Development and Validation of an Open Source Toolkit for Noisy Naturalistic Heart Rate Data. In Proceedings of the 6th HUMANIST Conference (pp. 173–178).

[2] van Gent, P. Van, Farah, H., Nes, N. Van, & Arem, B. Van. (manuscript submitted for publication). A Novel Heart Rate Algorithm for the Analysis of Noisy Signals.

To-do

The module is still in active development. See the changelog for past changes. The to-do for the coming months is:

to do before V1.2

  • Validate performance on Physionet datasets
  • Add several extra filtering options (Savitzky-Golay, Notch)
  • Add convolutional pre-processing pipeline for both PPG and ECG
  • Mark which RR-intervals are adjacent (no rejection gaps in between) to improve things like breathing rate detection
  • Update threshold parameter optimization to handle cases of double peaks and large portion of signal containing little to no hr
  • Report validation performance on repo (published paper + key-points document once published)
  • Add R-position interpolation ('high accuracy' mode)
  • Handle cases where strong T-peak in signal is present
  • Include example data on PIP release
  • Change peak fitting to optimize locally rather than globally, to handle long signals with noisy intermediate sections better
  • Change segmented analysis method to run peak detection once on whole signal, then do segmentwise computation from working_data object (drastic speed up)

Metadata

Release files for heartpy 1.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for heartpy 1.2.4
File Size Uploaded
heartpy-1.2.4.tar.gz 30.6 kB Details

Built distribution (wheel)

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

Total release size: 1.0 MB

Release files / heartpy-1.2.4.tar.gz

Download URL heartpy-1.2.4.tar.gz
Size 30.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3f9cc327ed8cce708998d4a793fd71b4b800fd78fa4d88e0886c2e1cfdd8fee9
BLAKE2b-256 checksum
How to use checksums
52e36a5faf0814d198859c3bdfb5b98065bcfca907124230a9389da7662acbdc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

Release files / heartpy-1.2.4-py3-none-any.whl

Download URL heartpy-1.2.4-py3-none-any.whl
Size 1.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
9898be1e2c3177e5bf1e4cd8a85a7da84cfccf1c10e0cdf7d9a636b596c5f47f
BLAKE2b-256 checksum
How to use checksums
f0b21ba671ec28f6c3ad9e43915463a2dc354dc294d569f77840c9edd6f4f5a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

Release history Release notifications | RSS feed

1.2.7

2 release files

1.2.6

2 release files

1.2.5

2 release files

This release

1.2.4 This release

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.1.7

2 release files

1.1.6

2 release files

1.1

2 release files

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