Skip to main content

A package for sleep stage classification using ECG data

Project description

Python PyPI conda-forge Docs DOI License

SleepECG

SleepECG provides tools for sleep stage classification when EEG signals are not available. Based only on ECG, SleepECG provides functions for

  • downloading and reading open polysomnography datasets,
  • detecting heartbeats from ECG signals, and
  • classifying sleep stages (which includes preprocessing, feature extraction, and classification).

Documentation

Documentation for SleepECG is available on Read the Docs. Check out the changelog to learn what we added, changed, or fixed.

Installation

SleepECG is available on PyPI and can be installed with pip:

pip install sleepecg

Alternatively, an unofficial conda package is available:

conda install -c conda-forge sleepecg

SleepECG with all optional dependencies can be installed with the following command:

pip install "sleepecg[full]"

If you want the latest development version, use the following command:

pip install git+https://github.com/cbrnr/sleepecg

Example

The following example detects heartbeats in a short ECG (a one-dimensional NumPy array):

import numpy as np
from sleepecg import detect_heartbeats, get_toy_ecg

ecg, fs = get_toy_ecg()  # 5 min of ECG data at 360 Hz
beats = detect_heartbeats(ecg, fs)  # indices of detected heartbeats

Dependencies

SleepECG requires Python ≥ 3.9 and the following packages:

Optional dependencies provide additional features:

  • edfio ≥ 0.1.1 (read data from MESA and SHHS)
  • joblib ≥ 1.0.0 (parallelized feature extraction)
  • matplotlib ≥ 3.5.0 (plot ECG time courses, hypnograms, and confusion matrices)
  • numba ≥ 0.55.0 (JIT-compiled heartbeat detector)
  • tensorflow ≥ 2.7.0 (sleep stage classification with Keras models)
  • wfdb ≥ 3.4.0 (read data from SLPDB, MITDB, and LTDB)

Contributing

The contributing guide contains detailed instructions on how to contribute to SleepECG.

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

sleepecg-0.5.7.tar.gz (2.6 MB view details)

Uploaded Source

Built Distributions

sleepecg-0.5.7-cp312-cp312-win_amd64.whl (2.7 MB view details)

Uploaded CPython 3.12 Windows x86-64

sleepecg-0.5.7-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

sleepecg-0.5.7-cp312-cp312-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

sleepecg-0.5.7-cp312-cp312-macosx_10_9_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.12 macOS 10.9+ x86-64

sleepecg-0.5.7-cp311-cp311-win_amd64.whl (2.7 MB view details)

Uploaded CPython 3.11 Windows x86-64

sleepecg-0.5.7-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

sleepecg-0.5.7-cp311-cp311-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

sleepecg-0.5.7-cp311-cp311-macosx_10_9_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

sleepecg-0.5.7-cp310-cp310-win_amd64.whl (2.7 MB view details)

Uploaded CPython 3.10 Windows x86-64

sleepecg-0.5.7-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

sleepecg-0.5.7-cp310-cp310-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

sleepecg-0.5.7-cp310-cp310-macosx_10_9_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

sleepecg-0.5.7-cp39-cp39-win_amd64.whl (2.7 MB view details)

Uploaded CPython 3.9 Windows x86-64

sleepecg-0.5.7-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

sleepecg-0.5.7-cp39-cp39-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

sleepecg-0.5.7-cp39-cp39-macosx_10_9_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

File details

Details for the file sleepecg-0.5.7.tar.gz.

File metadata

  • Download URL: sleepecg-0.5.7.tar.gz
  • Upload date:
  • Size: 2.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for sleepecg-0.5.7.tar.gz
Algorithm Hash digest
SHA256 b91e793ba8610671a52ce8f7c45266d118e8b88103cded9d8461f1ca0acad721
MD5 27658196b61e1bf6ebdf82251cd20d09
BLAKE2b-256 aecfb8e9263b04ce6c70b8d185f0d89d6417d7332df6940ab2eccdfdd4ad6723

See more details on using hashes here.

File details

Details for the file sleepecg-0.5.7-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for sleepecg-0.5.7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 9ee5c0494227e789e238cc2cd12b1dfa5fc6750f101e499b8611cea89186429b
MD5 8194bd90f941be8039fe69b83cdc7c4a
BLAKE2b-256 53f0b8111d9c9f8758d2cef2fa6935cef034ad75559199828959a1519cf6f189

See more details on using hashes here.

File details

Details for the file sleepecg-0.5.7-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for sleepecg-0.5.7-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e8a7a1026f83ab684f04871f350a8ac819c25e90655882da302a2468c2500d20
MD5 1b6634a322b5b96597e0d8e6fbb6b65a
BLAKE2b-256 ea303be6839114319efa50c3da7698d7bb3c24e756834fcbd3633c96771fd778

See more details on using hashes here.

File details

Details for the file sleepecg-0.5.7-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for sleepecg-0.5.7-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c488b813729222b79606aaee45cd9b0dbc1d1fcea15276a4f6fc25c9ddcfb014
MD5 6b4f99014da45d39bb4359e7fa3a9019
BLAKE2b-256 0792c2abb87eec4081da95731bb494387afcdb6718d74c7bcde45384404235fd

See more details on using hashes here.

File details

Details for the file sleepecg-0.5.7-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for sleepecg-0.5.7-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4748d3df5b742f0f27c36cdef306f6910782ae06a88b42d9b19440afc575796d
MD5 07b480eeeec2db6b5a8ed55805858feb
BLAKE2b-256 52858163cfc875ef5db9bedc35d797f84ddec9a27bcd9b2112394d091133456c

See more details on using hashes here.

File details

Details for the file sleepecg-0.5.7-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for sleepecg-0.5.7-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 e58d6d55b4acc9243e115a0f63fd0e5e0d9aebececac270a6cbc685e885441de
MD5 fad0b2c8d0bef5b55fe48b6b9a1b89b1
BLAKE2b-256 7aa1839cd6f3ae70eb6186fde725d2398fa206a7f374944c7eaf74f3998a0aba

See more details on using hashes here.

File details

Details for the file sleepecg-0.5.7-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for sleepecg-0.5.7-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 480529f17e0c394a53224811e1a3b7cbc8d3875d8de9e176a65fa31d8315ebcd
MD5 4c1207ef1d547d90e8fffd346b823985
BLAKE2b-256 748da5bab649b483e81f7709320479fac474a7c6d4f5b6285b6631c8a97d399a

See more details on using hashes here.

File details

Details for the file sleepecg-0.5.7-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for sleepecg-0.5.7-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ac625bd2cc28247de303969b4fbeb51849b2aa69dd37aae5af4d2427f8124c8a
MD5 928690279362715c887267394b7eec21
BLAKE2b-256 aa608e802250969e6cf74ba2d16e28ca4f2f4bfc7fb05278c7fa882c956a77ac

See more details on using hashes here.

File details

Details for the file sleepecg-0.5.7-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for sleepecg-0.5.7-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 800a7b6e56b2094d40b40bb31763b2e181ea3fb34232cf6cc17f883e89b50ecc
MD5 3256c014f58fc314582801d54e7e9dec
BLAKE2b-256 b2a02e715b44bb51044bd1d07c84dec5cc6046257ca932e12b52ce8d12554faa

See more details on using hashes here.

File details

Details for the file sleepecg-0.5.7-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for sleepecg-0.5.7-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 04bdb22d8bfd0640d9013bdbf0a78124f3e29a417eee42f1adffe5666666af65
MD5 33e08c6e19054e2c2206c13d26177bab
BLAKE2b-256 7d77a432ee131e4c687ff90a1d8a62962fbc69d78ec63620253b7774ff722a79

See more details on using hashes here.

File details

Details for the file sleepecg-0.5.7-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for sleepecg-0.5.7-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5e1df1472ea2b8b2cdd5733bee6dfaa2a8573cbb5380ea0284c8b43381575b58
MD5 8f550364a178db0fcadbe59ed15123a0
BLAKE2b-256 06b818947ac47eba1d7021034704dbf691bea4316a9816371d7e967665120427

See more details on using hashes here.

File details

Details for the file sleepecg-0.5.7-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for sleepecg-0.5.7-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c3d06958faadf6b87f1fa205e542b62172b433a3ea44ac8dedc98512ee877034
MD5 9a82a89c4745998e6b868cd83ffdb2ef
BLAKE2b-256 455b7df95b12a513d586c38cd5f2958eaf0421c1e857320e98f543086c57131a

See more details on using hashes here.

File details

Details for the file sleepecg-0.5.7-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for sleepecg-0.5.7-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 32509f39808e9a49c5e01d8c2e8e24336c4ee2148ff806a201b9448ffcddde3d
MD5 499eae36612dec6d02c6588ff3a0add9
BLAKE2b-256 8a3e9e7474a5e44ab33e98daaf47ac48a7a602885ff3fd1363bbb72eac7924c4

See more details on using hashes here.

File details

Details for the file sleepecg-0.5.7-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: sleepecg-0.5.7-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 2.7 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for sleepecg-0.5.7-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 3eacaf0fa6aa8d0103249cab7d57b4e93e00604823165e3a764a56e1e8596f8c
MD5 73bacbdb68b0771ffa543218f36e5024
BLAKE2b-256 a1012358bc199657320c8d517ffe61d538e00f51390b7d121709a16d38f61bf3

See more details on using hashes here.

File details

Details for the file sleepecg-0.5.7-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for sleepecg-0.5.7-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 953702cf6b15406ea2581f65dde8fb1b43e41ff24c995a71179d3035ee3eccb8
MD5 62f4cf3832874189b75fca7616b1c2bc
BLAKE2b-256 8f183057f293a20bfa867a4f3363d37c57017679c7b0c35554f95426a9e9cef2

See more details on using hashes here.

File details

Details for the file sleepecg-0.5.7-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for sleepecg-0.5.7-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e7d9e2ef18e734c727c064a1ffe15c9eb5c949fe063c57255905b2a06a1c1254
MD5 be5068dc43844f6192859975e2a6b166
BLAKE2b-256 696537b6475945cfaae8d14b632f8cda5c291b90c6d201aaa11ca625d95d7329

See more details on using hashes here.

File details

Details for the file sleepecg-0.5.7-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for sleepecg-0.5.7-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5ca6a947dc75e79df73c6e4d31982d8241ce459cb5de21101bee267e1067a3a3
MD5 18ed85438ffc5b482ff6fc330a39da54
BLAKE2b-256 cf90db51ad4c8ec75c647656533718701115bf9c933d130aaa8b2205274bc083

See more details on using hashes here.

Supported by

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