All Projects → CVxTz → Eeg_classification

CVxTz / Eeg_classification

Licence: apache-2.0
EEG Sleep stage classification using CNN with Keras

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Eeg classification

Braindecode
Outdated, see new https://github.com/braindecode/braindecode
Stars: ✭ 284 (+425.93%)
Mutual labels:  convolutional-neural-networks, eeg
Arl Eegmodels
This is the Army Research Laboratory (ARL) EEGModels Project: A Collection of Convolutional Neural Network (CNN) models for EEG signal classification, using Keras and Tensorflow
Stars: ✭ 422 (+681.48%)
Mutual labels:  convolutional-neural-networks, eeg
Eeglearn
A set of functions for supervised feature learning/classification of mental states from EEG based on "EEG images" idea.
Stars: ✭ 469 (+768.52%)
Mutual labels:  convolutional-neural-networks, eeg
Jsi Gan
Official repository of JSI-GAN (Accepted at AAAI 2020).
Stars: ✭ 42 (-22.22%)
Mutual labels:  convolutional-neural-networks
Computervision Recipes
Best Practices, code samples, and documentation for Computer Vision.
Stars: ✭ 8,214 (+15111.11%)
Mutual labels:  convolutional-neural-networks
Keras Sincnet
Keras (tensorflow) implementation of SincNet (Mirco Ravanelli, Yoshua Bengio - https://github.com/mravanelli/SincNet)
Stars: ✭ 47 (-12.96%)
Mutual labels:  convolutional-neural-networks
Estimated Depth Map Helps Image Classification
Depth estimation with neural network, and learning on RGBD images
Stars: ✭ 52 (-3.7%)
Mutual labels:  convolutional-neural-networks
Hardhat Detector
A convolutional neural network implementation of a script that detects whether an individual is wearing a hardhat or not.
Stars: ✭ 41 (-24.07%)
Mutual labels:  convolutional-neural-networks
Deepseqslam
The Official Deep Learning Framework for Route-based Place Recognition
Stars: ✭ 49 (-9.26%)
Mutual labels:  convolutional-neural-networks
Ml In Tf
Get started with Machine Learning in TensorFlow with a selection of good reads and implemented examples!
Stars: ✭ 45 (-16.67%)
Mutual labels:  convolutional-neural-networks
Yolo tensorflow
🚖 Object Detection (YOLOv1) implentation in tensorflow, with training, testing and video features.
Stars: ✭ 45 (-16.67%)
Mutual labels:  convolutional-neural-networks
Antsrnet
Medical image analysis framework merging ANTsR and deep learning
Stars: ✭ 42 (-22.22%)
Mutual labels:  convolutional-neural-networks
Switchnorm segmentation
Switchable Normalization for semantic image segmentation and scene parsing.
Stars: ✭ 47 (-12.96%)
Mutual labels:  convolutional-neural-networks
Dynamic Gcnn
Dynamic Graph Convolutional Neural Network for 3D point cloud semantic segmentation
Stars: ✭ 42 (-22.22%)
Mutual labels:  convolutional-neural-networks
Numpy Convnet
A small and pure Numpy Convolutional Neural Network library.
Stars: ✭ 50 (-7.41%)
Mutual labels:  convolutional-neural-networks
Yann
This toolbox is support material for the book on CNN (http://www.convolution.network).
Stars: ✭ 41 (-24.07%)
Mutual labels:  convolutional-neural-networks
Tensorflow Cnn Time Series
Feeding images of time series to Conv Nets! (Tensorflow + Keras)
Stars: ✭ 49 (-9.26%)
Mutual labels:  convolutional-neural-networks
Yolo Object Detection Tensorflow
YOLO: Real-Time Object Detection using Tensorflow and easy to use
Stars: ✭ 45 (-16.67%)
Mutual labels:  convolutional-neural-networks
Svhn Cnn
Google Street View House Number(SVHN) Dataset, and classifying them through CNN
Stars: ✭ 44 (-18.52%)
Mutual labels:  convolutional-neural-networks
Meshcnn
Convolutional Neural Network for 3D meshes in PyTorch
Stars: ✭ 1,032 (+1811.11%)
Mutual labels:  convolutional-neural-networks

DOI

EEG_classification

Description of the approach : https://towardsdatascience.com/sleep-stage-classification-from-single-channel-eeg-using-convolutional-neural-networks-5c710d92d38e

Sleep Stage Classification from Single Channel EEG using Convolutional Neural Networks


Photo by Paul M on Unsplash

Quality Sleep is an important part of a healthy lifestyle as lack of it can cause a list of issues like a higher risk of cancer and chronic fatigue. This means that having the tools to automatically and easily monitor sleep can be powerful to help people sleep better.
Doctors use a recording of a signal called EEG which measures the electrical activity of the brain using an electrode to understand sleep stages of a patient and make a diagnosis about the quality if their sleep.

In this post we will train a neural network to do the sleep stage classification automatically from EEGs.

Data

In our input we have a sequence of 30s epochs of EEG where each epoch has a label {“W”, “N1”, “N2”, “N3”, “REM”}.

Fig 1 : EEG Epoch

Fig 2 : Sleep stages through the night

This post is based on a publicly available EEG Sleep data ( Sleep-EDF ) that was done on 20 subject, 19 of which have 2 full nights of sleep. We use the pre-processing scripts available in this repo and split the train/test so that no study subject is in both at the same time.

The general objective is to go from a 1D sequence like in fig 1 and predict the output hypnogram like in fig 2.

Model Description

Recent approaches [1] use a sub-model that encodes each epoch into a 1D vector of fixed size and then a second sequential sub-model that maps each epoch’s vector into a class from {“W”, “N1”, “N2”, “N3”, “REM”}.

Here we use a 1D CNN to encode each Epoch and then another 1D CNN or LSTM that labels the sequence of epochs to create the final hypnogram. This allows the prediction for an epoch to take into account the context.

Sub-model 1 : Epoch encoder

Sub-model 2 : Sequential model for epoch classification

The full model takes as input the sequence of EEG epochs ( 30 seconds each) where the sub-model 1 is applied to each epoch using the TimeDistributed Layer of Keras which produces a sequence of vectors. The sequence of vectors is then fed into a another sub-model like an LSTM or a CNN that produces the sequence of output labels.
We also use a linear Chain CRF for one of the models and show that it can improve the performance.

Training Procedure

The full model is trained end-to-end from scratch using Adam optimizer with an initial learning rate of 1e⁻³ that is reduced each time the validation accuracy plateaus using the ReduceLROnPlateau Keras Callbacks.

Accuracy Training curves

Results

We compare 3 different models :

  • CNN-CNN : This ones used a 1D CNN for the epoch encoding and then another 1D CNN for the sequence labeling.
  • CNN-CNN-CRF : This model used a 1D CNN for the epoch encoding and then a 1D CNN-CRF for the sequence labeling.
  • CNN-LSTM : This ones used a 1D CNN for the epoch encoding and then an LSTM for the sequence labeling.

We evaluate each model on an independent test set and get the following results :

  • CNN-CNN : F1 = 0.81, ACCURACY = 0.87
  • CNN-CNN-CRF : F1 = 0.82, ACCURACY =0.89
  • CNN-LSTM : F1 = 0.71, ACCURACY = 0.76

The CNN-CNN-CRF outperforms the two other models because the CRF helps learn the transition probabilities between classes. The LSTM based model does not work as well because it is most sensitive to hyper-parameters like the optimizer and the batch size and requires extensive tuning to perform well.

Ground Truth Hypnogram

Predicted Hypnogram using CNN-CNN-CRF

Source code available here : https://github.com/CVxTz/EEG_classification

I look forward to your suggestions and feedback.

[1] DeepSleepNet: a Model for Automatic Sleep Stage Scoring based on Raw Single-Channel EEG

How to cite:

@software{mansar_youness_2020_4060151,
  author       = {Mansar Youness},
  title        = {CVxTz/EEG\_classification: v1.0},
  month        = sep,
  year         = 2020,
  publisher    = {Zenodo},
  version      = {v1.0},
  doi          = {10.5281/zenodo.4060151},
  url          = {https://doi.org/10.5281/zenodo.4060151}
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].