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.4.0 (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.59.1 (JIT-compiled heartbeat detector)
  • tensorflow ≥ 2.16.1 (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.8.tar.gz (569.6 kB view details)

Uploaded Source

Built Distributions

sleepecg-0.5.8-cp312-cp312-win_amd64.whl (412.1 kB view details)

Uploaded CPython 3.12 Windows x86-64

sleepecg-0.5.8-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (424.6 kB view details)

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

sleepecg-0.5.8-cp312-cp312-macosx_11_0_arm64.whl (408.4 kB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

sleepecg-0.5.8-cp312-cp312-macosx_10_9_x86_64.whl (408.0 kB view details)

Uploaded CPython 3.12 macOS 10.9+ x86-64

sleepecg-0.5.8-cp311-cp311-win_amd64.whl (412.0 kB view details)

Uploaded CPython 3.11 Windows x86-64

sleepecg-0.5.8-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (424.2 kB view details)

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

sleepecg-0.5.8-cp311-cp311-macosx_11_0_arm64.whl (408.3 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

sleepecg-0.5.8-cp311-cp311-macosx_10_9_x86_64.whl (407.9 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

sleepecg-0.5.8-cp310-cp310-win_amd64.whl (412.0 kB view details)

Uploaded CPython 3.10 Windows x86-64

sleepecg-0.5.8-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (424.2 kB view details)

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

sleepecg-0.5.8-cp310-cp310-macosx_11_0_arm64.whl (408.3 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

sleepecg-0.5.8-cp310-cp310-macosx_10_9_x86_64.whl (407.9 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

sleepecg-0.5.8-cp39-cp39-win_amd64.whl (412.0 kB view details)

Uploaded CPython 3.9 Windows x86-64

sleepecg-0.5.8-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (423.6 kB view details)

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

sleepecg-0.5.8-cp39-cp39-macosx_11_0_arm64.whl (408.3 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

sleepecg-0.5.8-cp39-cp39-macosx_10_9_x86_64.whl (407.9 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: sleepecg-0.5.8.tar.gz
  • Upload date:
  • Size: 569.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for sleepecg-0.5.8.tar.gz
Algorithm Hash digest
SHA256 07971f52af329598a95f3e3d36e227fbb82b0f1df8acab32abf5c1c7f6a94ea7
MD5 9635024556c26de0ca9f512e3b01682b
BLAKE2b-256 408cd3637535ce113a351c9c2084cf9fff20d4adaf637e825e5bfb8b738ee8dd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sleepecg-0.5.8-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 412.1 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for sleepecg-0.5.8-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 d357d56aa4261dc41890c91ed76c5586a6fd6dc6d94f1abc8c44a6e83265d894
MD5 acaaea8181a3078340a6763974789081
BLAKE2b-256 e2a590547991c4189abb086986b6a787e52acfb61734f45ade8d8ade743d4081

See more details on using hashes here.

File details

Details for the file sleepecg-0.5.8-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.8-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5269372ac9f3a2fcbbc10422ab06dee9a0721d3049ba84362748f28e3a328661
MD5 82b09004fe999a6b9768874584be112e
BLAKE2b-256 3cf265378f894744eb81ea8367023a555442bc589ee4c1fa75113f9e40fe0682

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sleepecg-0.5.8-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b5a8f98246686f74cddbe565f25f9939c52ff69d9eb84fe945cd9d54b19ac552
MD5 a7ba8056ede85cc50a05b462151ab53d
BLAKE2b-256 71407f914beb67ce65e099e5261380729cd5ef8583b460812c8a6c9b719ede2e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sleepecg-0.5.8-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6c2cb9eca5ac2e05036c63dac847fa3df1e7428e5fcd928107c1d92cb2d22cf6
MD5 395cee52e71b787554a4c525c3e84fb1
BLAKE2b-256 ae67c898528c75851076a76c95c7d3748610594306dc42bc436497cf91c24434

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sleepecg-0.5.8-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 412.0 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for sleepecg-0.5.8-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 3b7fe368b06ed78ea297e86cc8a77a6bfe61369d08a32fa0e86d3080cf7bc6a6
MD5 b5b9a9df52dfd1d28eead674cc329dc1
BLAKE2b-256 ff7bcc0a6291d9a90b2ebdb492b445d1ccc497377be0ab1e799941a1d98fc0a9

See more details on using hashes here.

File details

Details for the file sleepecg-0.5.8-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.8-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 22f3798f03483fd68531e3cb0e5eff134ef680338e815738ccdf0d9332c0cb12
MD5 8ab9569ab0a0710ca3ea18b7372f116e
BLAKE2b-256 b602eacf29db2466c43af1c50236e46027a446802d743ce4b8a56414283f4f4b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sleepecg-0.5.8-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 eec8405f642fa3cc3670766bdf68754efc77ab083fe5ad1e4145fcb9c2ad6535
MD5 42c976fdc2686b337acb964068d11cb7
BLAKE2b-256 0b5d31d6b4e7352aff5699c45b57786430f342a79c259372448fc0fbfc075d04

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sleepecg-0.5.8-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a7d27fb2dc9ed7a2637ca09a1752888171d767f2e408a56a9caa018d9655286e
MD5 e696ab7cfaa7ae8d9790f77ed37f80f3
BLAKE2b-256 40ecc46c1cdf770c614edbcf3905a94335d83c98a30f9a0c5562de553e591a4c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sleepecg-0.5.8-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 412.0 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for sleepecg-0.5.8-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f553027dfe0048d791696227c932fa5f54da1c1e30836e4f106f674eb76d4757
MD5 fbc14f6f81767f1c4b806c5d5b4157a3
BLAKE2b-256 39b9c42cfed0177d1e504190b094a67c9a1d0d2afff4b7890133f94604aaa2d6

See more details on using hashes here.

File details

Details for the file sleepecg-0.5.8-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.8-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8876e41a21ff04333203605579553b0c791c40c963d45aa68ba018a4b79a989d
MD5 be27078af2492c0a65678bffb743b19c
BLAKE2b-256 26c00c6786584b45f780bb47d515f55815eec284e6c1b20dff575da39d19f1a9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sleepecg-0.5.8-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 13cf86ca300eec8d89bab2ccb266d3696252efa057c65fe0845d2de96906907e
MD5 df7ba11ce2aab33763204286cd130964
BLAKE2b-256 345218372b920a0ad3c1ec1926e0998c049945868a46e41755f1f6567c60c8df

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sleepecg-0.5.8-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b200986db9cec540dcf52d82af0d13b1561964c4f8a5b9ad5f02262f85c4096c
MD5 b27eafea2082b7f024c0f54b8b732bb9
BLAKE2b-256 738ba86b84e42fbb078b8c3310957605316b1c999b87144b75096c91124d2a16

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sleepecg-0.5.8-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 412.0 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for sleepecg-0.5.8-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 7b65181f8496a1d565357495573cd9e64f8836107433cc5cf38717421e60ea63
MD5 781b6388e539cc1569618dcba70e6709
BLAKE2b-256 ce60981cf48620a50b1e5e01dfb8050575f857a4fdf5ce4e64640707c36c2e37

See more details on using hashes here.

File details

Details for the file sleepecg-0.5.8-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.8-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 265e26405cec666846d98300110d5f9df1d65ba6d4f352523763b72509354404
MD5 e6d5e5d67bc57a9f956265ecfc7556ef
BLAKE2b-256 99daefcb30697803a0372a76790e9d9fa9ca84f91d2dfad4b62d369dd1f1ad82

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sleepecg-0.5.8-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d79f586affd0d2d93f94cba1364ab613b5be020624a85f93bdc6178d465fd5d5
MD5 cf8db491e4e1744112257b76bfdc67cc
BLAKE2b-256 8f5dcac075281b9448ee2483b500103cb3752f132f68d950ff2f2c7bb7dc059e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sleepecg-0.5.8-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5864622d588029d090808f6c606df1e5a0e5368f5736bd33049dd1aeb47d1d5c
MD5 6a1828a4f5f3ba5356da3db9dda9352f
BLAKE2b-256 bbd94984382171f257e2e4aa4eebd76e917e855d9657f01268c31f58d746d7a7

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