Skip to content

Class wrapper of the yasa package to detect drowsiness/sleep phase using EEG data

License

Notifications You must be signed in to change notification settings

nabilalibou/SleepChecker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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 [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 raw EEG data for easy visualization and analysis.

Installation

git clone https://github.com/nabilalibou/SleepChecker.git
pip install -r requirements.txt

Example

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

Releases

No releases published

Packages

No packages published

Languages