https://github.com/nabilalibou/sleepchecker
Class wrapper of the yasa package to detect drowsiness/sleep phase using EEG data
https://github.com/nabilalibou/sleepchecker
drowsiness-detection eeg eeg-analysis eeg-signals-processing sleep sleep-analysis sleep-scoring sleep-staging
Last synced: 4 months ago
JSON representation
Class wrapper of the yasa package to detect drowsiness/sleep phase using EEG data
- Host: GitHub
- URL: https://github.com/nabilalibou/sleepchecker
- Owner: nabilalibou
- License: mit
- Created: 2024-01-06T10:44:35.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-06T10:51:04.000Z (almost 2 years ago)
- Last Synced: 2025-06-12T16:46:59.111Z (8 months ago)
- Topics: drowsiness-detection, eeg, eeg-analysis, eeg-signals-processing, sleep, sleep-analysis, sleep-scoring, sleep-staging
- Language: Python
- Homepage:
- Size: 29.3 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SleepChecker: A Simplified Wrapper for Robust Sleep Stage Detection in EEG
SleepChecker simplifies the process of detecting sleep stages in EEG recordings. It wraps the powerful
[yasa](https://raphaelvallat.com/yasa/build/html/index.html) [[1]](#1) SleepStaging module, providing a
user-friendly interface for robust sleep detection.
Key Features:
- Automated Sleep Stage Classification: Combines predictions from the underlying algorithm for a single, reliable sleep stage label.
- Total Sleep Time: Calculates the total percentage of time spent asleep during the recording.
- Sleep Annotation: Annotates sleep segments directly onto your [MNE](https://mne.tools/stable/index.html) raw EEG data for easy visualization and analysis.
# Installation
```
git clone https://github.com/nabilalibou/SleepChecker.git
pip install -r requirements.txt
```
# Example
```python
import mne
from SleepChecker import SleepChecker
# Load an EDF file using MNE
raw_eeg = mne.io.read_raw_edf("myfile.edf", preload=True)
sc = SleepChecker(raw_eeg, eeg_name=['C4', 'C3'], eog_name="HEOGR-HEOGL", ref_channel=["M1", "M2"])
# Return an array containing the predicted sleep phases among ['W', 'N1', 'N2', 'N3', 'R']
sleep_stages = sc.predict()
# get the overall % of time asleep
sleep_percent = sc.get_tot_sleep_percentage(sleep_stages)
# annotate the sleeping time spans directly on the raw data
raw_eeg = sc.annotate_data()
```
# References
[1]
Vallat, Raphael, and Matthew P. Walker. "An open-source, high-performance tool for automated sleep staging." Elife 10
(2021). doi: https://doi.org/10.7554/eLife.70092