Sleep Stage Classification using CNN + Attention mechanism (Transformers)
We use the EEG Fpz-Cz single channel data to classify the sleep
- 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
We are using the expanded Sleep-EDF database from https://physionet.org/content/sleep-edfx/1.0.0/
- EEG Fpz-Cz
- EEG Pz-Oz
- EOG horizontal
- Resp oro-nasal
- EMG submental
- Temp rectal
- Event marker
- Download raw PSG file and hypnogram file from PhysioNet.
- 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.
- Load the label CSV and the signal CSV into Spark (PySpark).
- Remove unknown labels, only keep stages W, N1, N2, N3, N4, and REM.
- Segment the signals into 30s epochs.
- Save the channel signals and corresponding label as NPZ file for models.
- CNN
- Attention on RNN
- GAN?
- Automatic Sleep Stage Scoring Using Time-Frequency Analysis and Stacked Sparse Autoencoders, 2015. Paper
- Automatic Sleep Stage Scoring with Single-Channel EEG Using Convolutional Neural Networks, 2016. Paper
- Learning Sleep Stages from Radio Signals: A Conditional Adversarial Architecture, 2017. Paper
- SLEEPNET: Automated Sleep Staging System via Deep Learning, 2017. Paper
- SLEEPER: interpretable Sleep staging via Prototypes fromExpert Rules, 2019. Paper
- Neural network analysis of sleep stages enablesefficient diagnosis of narcolepsy, 2018. Paper Code
- SleepEEGNet: Automated Sleep Stage Scoring with Sequence to Sequence Deep Learning Approach, 2019. Paper Code