Skip to content

Sleep Stage Classification using Attention

License

Notifications You must be signed in to change notification settings

jacker2019/AttendToSleep

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AttendToSleep

Sleep Stage Classification using CNN + Attention mechanism (Transformers)

We use the EEG Fpz-Cz single channel data to classify the sleep

Setup

  • TODO: add data download instructions (put processed npy files in data/all/processed)
  • Use the environment.yml file to install the conda environment
  • Move to directory code by running cd code
  • Install the repository by running pip install -e .
  • Download the PSG and hypnogram files from PhysioNet by running cd data, chmod +x download_physionet.sh,./download_physionet.sh
  • Extract signals from EEG Fpz-Cz, EEG Pz-Oz, and EOG horizontal by running python prepare_physionet.py --data_dir data
  • Data processing by running python python data_processing.py --data_dir data
  • Copy the processed numpy arrays into dataset/processed/all and split them into train, val, and test set. (python test_train_split.py can be used to help the splitting.)
  • train the cnn-only model by running python helper/runner_cnn.py
  • train the final model by running python helper/runner_cnn_seq2seq.py

Datasets

We are using the expanded Sleep-EDF database from https://physionet.org/content/sleep-edfx/1.0.0/

Channels

  • EEG Fpz-Cz
  • EEG Pz-Oz
  • EOG horizontal
  • Resp oro-nasal
  • EMG submental
  • Temp rectal
  • Event marker

ETL Pipeline

  1. Download raw PSG file and hypnogram file from PhysioNet.
  2. Extract different channel signals from downloaded PSG for each patient, and save as a CSV file. Extract corresponding labels from the hypnogram for the same patient.
  3. Load the label CSV and the signal CSV into Spark (PySpark).
  4. Remove unknown labels, only keep stages W, N1, N2, N3, N4, and REM.
  5. Segment the signals into 30s epochs.
  6. Save the channel signals and corresponding label as NPZ file for models.

Deep Learning Pipeline

  1. CNN
  2. Attention on RNN
  3. GAN?

Existing Work

  1. Automatic Sleep Stage Scoring Using Time-Frequency Analysis and Stacked Sparse Autoencoders, 2015. Paper
  2. Automatic Sleep Stage Scoring with Single-Channel EEG Using Convolutional Neural Networks, 2016. Paper
  3. Learning Sleep Stages from Radio Signals: A Conditional Adversarial Architecture, 2017. Paper
  4. SLEEPNET: Automated Sleep Staging System via Deep Learning, 2017. Paper
  5. SLEEPER: interpretable Sleep staging via Prototypes fromExpert Rules, 2019. Paper
  6. Neural network analysis of sleep stages enablesefficient diagnosis of narcolepsy, 2018. Paper Code
  7. SleepEEGNet: Automated Sleep Stage Scoring with Sequence to Sequence Deep Learning Approach, 2019. Paper Code

About

Sleep Stage Classification using Attention

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%