A package for sleep stage classification using ECG data
Project description
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for sleepecg-0.5.6-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0574cabc50aa90716d368fbf71129903d0a55dd8e08d8afa1453441d8dc5a599 |
|
MD5 | 0ad6a2750bab7d751aa73d991f3b1c22 |
|
BLAKE2b-256 | ec8b2d215b02a13def7ca35d5fef0bb998c8619367f89e9855af0d319d64bc40 |
Hashes for sleepecg-0.5.6-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e16f05912f50d34d54e7d87df02e231fcc3d9db0f583381f160f9b6a254095e |
|
MD5 | 9aee1d481b6c00a0681bd4db5425449a |
|
BLAKE2b-256 | 384b29a936fa560a3eee9f37e67ed8330931bf43d882e5c0df07d7ca419dd8c4 |
Hashes for sleepecg-0.5.6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6557e50466d79540cb169657dd47c7742490500b9c11be788bb575aff9a4110 |
|
MD5 | 26400e8b42c5bcf9be2835a2f8f3d8f3 |
|
BLAKE2b-256 | 572920dbdfc50be2c97f12398222ec95f5414ad7405e78d7189451d766cfd42e |
Hashes for sleepecg-0.5.6-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 637bf4b13df81b90f0dc8ecc0ea2d268ef2fcbbe994ca012cb367fd9b0f5a759 |
|
MD5 | da7fad3465ce33abc39a834d46ea3805 |
|
BLAKE2b-256 | 7bbb69d7e106f686017aec55d3104b37c12e3f04adf62ab751a7d8e01262e085 |
Hashes for sleepecg-0.5.6-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7d515c8fab6714171721f62eb351d949a4a1126c45db13bf709dbce9947d409 |
|
MD5 | c7adde2962fea8a01427d492529b5e83 |
|
BLAKE2b-256 | 6adaf182c5085867a55f06f1374204a30afae849b4dabf00cdf90b5d00b352ca |
Hashes for sleepecg-0.5.6-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22b415b254f2799e625acc198ab0fd56fa2b5b552152ef265b4953c891e36098 |
|
MD5 | 15c5ee71bf7160014b89acd0c9693f0a |
|
BLAKE2b-256 | 7616c95674776aa3e499aed27742ac7c78dfd016e4b8938fd297945331a87468 |
Hashes for sleepecg-0.5.6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e937ca89eae48dd66fce8dd2022ea2d1ee96ea5679161ed58f456a2e2e29fcdd |
|
MD5 | 035950e2f1052143e19df30753da918b |
|
BLAKE2b-256 | 9afe4bcfd1ad3984898b75dd52b169ecf4e7c9fe6b9ab2edbe4c4b74a3ccab17 |
Hashes for sleepecg-0.5.6-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 393d5bab7ce1bdef938d84c7f96ef2883b41adfc24c0956ac3bfbbec1dd58e58 |
|
MD5 | d2ab1ec53f0fc943504aeb06f14e41c5 |
|
BLAKE2b-256 | 148c1dfeac9ccff0dfadd1298cbc8ca5c55792b8f1f7e00d63d904565325f0a2 |
Hashes for sleepecg-0.5.6-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57105e318b9a4f22fa3ffbf441cbdd7f2f5ab98dd55a18b528b2d4f44d199b32 |
|
MD5 | ff988244a618d0ec4bdb7b9306d97590 |
|
BLAKE2b-256 | 9243ea0927a07294440b8cb1bdca1d70bb00dc9915153a1e1755177cfe0ee483 |
Hashes for sleepecg-0.5.6-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07851e7f25fe698f78cadcc71952a840005069d14602cae49f55a1cfa9dcc926 |
|
MD5 | 2b1ddfed11fca95fc2645c46a370b18e |
|
BLAKE2b-256 | 0d164e6b065b0aa45ea17b63b623c43e7e1a8c8d8154e8c6ef401f2507ed75de |
Hashes for sleepecg-0.5.6-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01508f9152b91db59ea94e4a5d6b0fb59eb89e61122d9a07c60d3f8046395158 |
|
MD5 | c4465042e2e302a1e19f0afe06c0f2ea |
|
BLAKE2b-256 | 5c2263ba8a5b88405430764f1989427706a3fd4a8e3bcf191989290a9b46730e |
Hashes for sleepecg-0.5.6-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d24563fe49e93fa9bfb6b6280ff88ab3727954aca06c27bd64721b34fe92ef01 |
|
MD5 | 43bbe983785a2fb9554446a6c4c2bc5c |
|
BLAKE2b-256 | 0b1fcce9802302534c10056206c16698c9b36408f455e4c5834ba0546452b7af |
Hashes for sleepecg-0.5.6-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8af30a66909bed6f541c2b8006d7fa011e320ae87429c7e07a458beb7dee8847 |
|
MD5 | d379940aee68b4adbcd85ab72681597b |
|
BLAKE2b-256 | 00bdddf7a5a23bd1586bb167d2749d980f35a690a17efcbe8aa213f525cd79fd |
Hashes for sleepecg-0.5.6-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04a21b0024ed5275602ee36a40bc2eaac47eb29977164033b61950ca21cd9bd5 |
|
MD5 | 889564fbd8085d92b36bf2b91a6c7f2c |
|
BLAKE2b-256 | d6e78931b6c0fc5bc36256c7a2fdb815238c51fdb77b943d457311caedb3224a |
Hashes for sleepecg-0.5.6-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6739ab0badb0b7591916c0d4b10ecd28807154a9c252b3ca51413bda45496910 |
|
MD5 | 6478be55adad498e364174c8d2d900bb |
|
BLAKE2b-256 | 12f66af5307e0b6565be7da8bdf2f24672b51c86036d558179c6b8b93beceda6 |
Hashes for sleepecg-0.5.6-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1bcb2b7d56a269461b16346d5255df1e4cdfa06a242baea93cb61f432cebd8f1 |
|
MD5 | ae900d2f005125ffaa467624d94ec526 |
|
BLAKE2b-256 | 8b01a59388fd62453b8783fd59dec44aee201d10d9e4dcee2fefa45b628a8f73 |