GithubHelp home page GithubHelp logo

amrzhd / eegnet Goto Github PK

View Code? Open in Web Editor NEW
36.0 2.0 0.0 48 KB

This project focuses on implementing CNN model based on the EEGNet architecture with Pytorch library for classifying motor imagery tasks using EEG data.

License: MIT License

Jupyter Notebook 92.36% Python 7.64%
convolutional-neural-networks deep-learning depthwise-convolutions depthwise-separable-convolutions eeg eeg-signals eegnet python pytorch signal-processing

eegnet's Introduction

EEGNet for Motor Imagery Classification

Introduction

Welcome to the EEGNet for Motor Imagery Classification repository! This project focuses on implementing a convolutional neural network (CNN) model based on the EEGNet architecture for classifying motor imagery tasks using electroencephalography (EEG) data. The model is designed to classify between four different motor imagery classes: Left Hand, Right Hand, Foot, and Tongue.

Dataset

The EEG data used in this project is sourced from the BCI Competition IV 2a dataset. Key characteristics of the dataset include:

  • 22 Ag/AgCl Electrodes
  • Sampling Frequency: 250 Hz
  • Epoched Data: [3.75, 5,75] seconds
  • Frequency Range: 0.5 - 100 Hz
  • High Pass Filtered: Over 4Hz (Using FIR Filter)
  • 4 Classes: Left Hand, Right Hand, Foot, Tongue

List of Events

The following events are annotated in the dataset:

  • '1023': 1 Rejected trial
  • '1072': 2 Eye movements
  • '276': 3 Idling EEG (eyes open)
  • '277': 4 Idling EEG (eyes closed)
  • '32766': 5 Start of a new run
  • '768': 6 Start of a trial
  • '769': 7 Cue onset Left (class 1) : 0
  • '770': 8 Cue onset Right (class 2) : 1
  • '771': 9 Cue onset Foot (class 3) : 2
  • '772': 10 Cue onset Tongue (class 4): 3

Events 7, 8, 9, and 10 were chosen for the classification.

Model

The EEGNet model architecture used in this project is detailed below:

  • Block 1: Two sequential convolutional steps are performed. First, F1 2D convolutional filters of size (1, 32) are applied to capture frequency information at 2Hz and above. Then, a Depthwise Convolution of size (C, 1) is used to learn a spatial filter. Batch Normalization and ELU nonlinearity are applied, followed by Dropout for regularization. An average pooling layer is used for dimensionality reduction.
  • Block 2: Separable Convolution is used, followed by Pointwise Convolutions. Average pooling is used for dimension reduction.
  • Classification Block: Features are passed directly to a softmax classification with N units, where N is the number of classes in the data.

For further details, refer to the original EEGNet implementation.

Training Loop

  • Optimizer: Adam
  • Batch size: 128
  • Epochs: 500
  • Learning Rate: 0.001
  • Loss Function: Cross Entropy

K-Fold Cross Validation

  • 4 Folds
  • Resetting weights each time
  • SEM of the results is considered

Requirements

To run the code in this repository, make sure you have the following dependencies installed:

  • Python == 3.7 or 3.8
  • PyTorch == 2.3 (verified working with 2.0 - 2.3, both for CPU and GPU)
  • torch-summary == 1.4.5
  • mne >= 0.17.1
  • scikit-learn >= 0.20.1
  • matplotlib >= 2.2.3

Citing the Author

If you use this code or the EEGNet model architecture in your work, please cite the original paper of the orignal model:

Vernon J Lawhern, Amelia J Solon, Nicholas R Waytowich, Stephen M Gordon, Chou P Hung, Brent J Lance. EEGNet: a compact convolutional neural network for EEG-based brain–computer interfaces. Journal of Neural Engineering, 2018.

eegnet's People

Contributors

amrzhd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

eegnet's Issues

accuracy

Is there any error in the final accuracy of around 50%? How to improve classification accuracy

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.