Skip to content

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

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

Contributing

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