Skip to main content

A package for sleep stage classification using ECG data

Project description

Python PyPI conda-forge Docs 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.

Changelog

Check out the changelog to learn what we added, changed, or fixed.

Dependencies

SleepECG requires Python ≥ 3.8 and the following packages:

Optional dependencies provide additional features:

  • joblib ≥ 1.0.0 (parallelized feature extraction)
  • matplotlib ≥ 3.5.0 (plot ECG time courses, hypnograms, and confusion matrices)
  • mne ≥ 1.0.0 (read data from MESA and SHHS)
  • 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)

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 scipy.misc import electrocardiogram
from sleepecg import detect_heartbeats

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

More examples are available at https://github.com/cbrnr/sleepecg/tree/main/examples.

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.5.tar.gz (2.3 MB view details)

Uploaded Source

Built Distributions

sleepecg-0.5.5-cp311-cp311-win_amd64.whl (2.3 MB view details)

Uploaded CPython 3.11 Windows x86-64

sleepecg-0.5.5-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.4 MB view details)

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

sleepecg-0.5.5-cp311-cp311-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

sleepecg-0.5.5-cp311-cp311-macosx_10_9_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

sleepecg-0.5.5-cp310-cp310-win_amd64.whl (2.3 MB view details)

Uploaded CPython 3.10 Windows x86-64

sleepecg-0.5.5-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.4 MB view details)

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

sleepecg-0.5.5-cp310-cp310-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

sleepecg-0.5.5-cp310-cp310-macosx_10_9_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

sleepecg-0.5.5-cp39-cp39-win_amd64.whl (2.3 MB view details)

Uploaded CPython 3.9 Windows x86-64

sleepecg-0.5.5-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.3 MB view details)

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

sleepecg-0.5.5-cp39-cp39-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

sleepecg-0.5.5-cp39-cp39-macosx_10_9_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

sleepecg-0.5.5-cp38-cp38-win_amd64.whl (2.3 MB view details)

Uploaded CPython 3.8 Windows x86-64

sleepecg-0.5.5-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.3 MB view details)

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

sleepecg-0.5.5-cp38-cp38-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

sleepecg-0.5.5-cp38-cp38-macosx_10_9_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: sleepecg-0.5.5.tar.gz
  • Upload date:
  • Size: 2.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for sleepecg-0.5.5.tar.gz
Algorithm Hash digest
SHA256 da29cfea1f0ee81942be9898065d376f5b21c76e018a3be5b1355e3a3986e284
MD5 62eaa7d008ce2c755542a57d4612d73c
BLAKE2b-256 d7453bdb7126284dcf23fd39a9a1623f0fc4398b0ea293bea418ac47ca269746

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sleepecg-0.5.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 40bf6541923b51a7b9516dd9757222849cd4b0ecce2033bb65c6d32cf74232aa
MD5 77fb25035bed6a343828d12523d03d49
BLAKE2b-256 9ad2d39aa92d69c21e171dd635265d1e86b0be278e5f218d8870450645ae48e2

See more details on using hashes here.

File details

Details for the file sleepecg-0.5.5-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.5-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 081c9069f85aa0466525f2048ddf606d5b1f344f9aa1d121977d0940591d8df7
MD5 c50331418b09b75837e0b1679646e73d
BLAKE2b-256 239ae775988ba39b0d871519a814c3acb1442c832a6da9e02f2e1d99f707c87e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sleepecg-0.5.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4c2cd3d8855c657b8efae1898c58fdefdf0af927630a3630002c6335f24b6ce9
MD5 8b3597ca569a677dcf3b051e6d7504ff
BLAKE2b-256 74db56bd20737fa3f8e556f03d4ace01f0221b047211d0cf52f3d0d3321399d5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sleepecg-0.5.5-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 12f6f2ff683598a28d1f0cd8ad2fa37eabfe53e7099f5f01658cd2579031fa1e
MD5 e8d9eed435a0190aca4f05b9b788dc3c
BLAKE2b-256 fa36f3674ba510f1316fb91521b2090cac3cdc15729e4580a3079ecaa0c67ca7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sleepecg-0.5.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 819011418997e8c4cd259c09126af73dac02590296802d8c35c5b16b868a95ca
MD5 f8b70f974c69f60c5f683647ab1e0d4e
BLAKE2b-256 c07062e0ddf5654d8bc7c70a3671f844601369ccad3f9160d1b0d93dea82740e

See more details on using hashes here.

File details

Details for the file sleepecg-0.5.5-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.5-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6ab35c08b9e8002895634bd9e2ec062ebaa1a87f988104313d073694fa2e0b1e
MD5 070a74d0ebb03dc0892467088ef30264
BLAKE2b-256 d0f38f70e6ec5850e8dea338ed2ef0fe17b00a5607b222278cda3129ae7fbcb7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sleepecg-0.5.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 919196b3a6922db7ac267c770f31600caadcbba7bbf65b4c1ce164feaa34b80e
MD5 9f2d7540983e655a8ea8fbba9cd9f368
BLAKE2b-256 ca750c9505fdbc0df40145328f9c360437251702e2e2cc39796990e0bfb8945a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sleepecg-0.5.5-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 20005e1d6c63544caf91c20f18e72acdd1602044e2a4658dc6be43bed5152795
MD5 4cb88a899a9eceac261db63929e749e2
BLAKE2b-256 304485cad17b34d6cd9522c658e1a164f1e9e35b0ab4db30b21cc56f82eab8d2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sleepecg-0.5.5-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 2.3 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for sleepecg-0.5.5-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 6513766d1ee1222b45ccef8899cdbec8e8912c827ee86c09f19915e7ec9a7bd8
MD5 c377e21b8d78362a1edd5bcac400fee7
BLAKE2b-256 0b6ebc002200ffd936efdd83223e048892fbc839f87d2b1faefab3fb28ad4387

See more details on using hashes here.

File details

Details for the file sleepecg-0.5.5-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.5-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d858ccab2869c4bfddbb4f3b7418be47bdb234d756aa0a6662ca95964d32efbd
MD5 0d00049c189d9fc37e54904d17c09e27
BLAKE2b-256 0e65789391f146026d039935313e707d70c43ad5a7bed82236388aed32986147

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sleepecg-0.5.5-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fd670bf2216cb6b4bb86a9dd21753b21b49976ab523263f10804f463d8a988ec
MD5 21c6f0a2aed5443e8ffc1dc3dcb27bc8
BLAKE2b-256 8a1ac4e0995800f33f3ef7e5898bd1a7557daaf3b5b9a740b08e60599b5c4d4a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sleepecg-0.5.5-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a9e7f48c318764c07aa6631ac11feddc9ed8a82b64fdb67a8569d1ed6f09522f
MD5 721e153060dc4ba1cc9768a2aac1989e
BLAKE2b-256 a8aa311d1122808807238946fa3665af7747d73835ba1c787588bcca4b8eab75

See more details on using hashes here.

File details

Details for the file sleepecg-0.5.5-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: sleepecg-0.5.5-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 2.3 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for sleepecg-0.5.5-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 7888cfa824909700200aed0bd785535d4f20fef95b1b89c7ecc76de4234a94cd
MD5 0030402cc1b425f28e2795bd5e11a366
BLAKE2b-256 f31a292ac8be1059c51111db18a9e161afa1bee9747cb4e37bf1292d94dc03d8

See more details on using hashes here.

File details

Details for the file sleepecg-0.5.5-cp38-cp38-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.5-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c92508b0f10af62ba3b2090b95120c178faf681d652ba8c28e54e384e74d52f8
MD5 c4ae12b569126cde7c823f784c775d91
BLAKE2b-256 fd6c1953808472c453e047601c92ec3d9092b2db39cef39389bded07d871cb14

See more details on using hashes here.

File details

Details for the file sleepecg-0.5.5-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for sleepecg-0.5.5-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6d298ab6c23c758ed2da4e0eb1fb683374da8339b95fd1e22ca53074db6777e1
MD5 5db67cda55109ddf22957ae165133cf2
BLAKE2b-256 2af6548044c9ab47e8d3a065f47586435d3dca8ecb3460f67468f659be06f631

See more details on using hashes here.

File details

Details for the file sleepecg-0.5.5-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for sleepecg-0.5.5-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5d6e0037eab59e0719503f01f705c8f46f90754b36fb1dff5e516d15d84121d8
MD5 c277e7a52fdebe77ecf5e32a269a9715
BLAKE2b-256 434e6550fe540c8b8bd5165a64046c36db871876cba5ae0544b61fb941ee38e5

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