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 hashes)

Uploaded Source

Built Distributions

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

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 hashes)

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 hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

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

Uploaded CPython 3.12 macOS 10.9+ x86-64

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

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 hashes)

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 hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

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

Uploaded CPython 3.11 macOS 10.9+ x86-64

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

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 hashes)

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 hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

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

Uploaded CPython 3.10 macOS 10.9+ x86-64

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

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 hashes)

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 hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

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

Uploaded CPython 3.9 macOS 10.9+ x86-64

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