All Projects → zhangks98 → eeg-adapt

zhangks98 / eeg-adapt

Licence: other
Source Code for "Adaptive Transfer Learning with Deep CNN for EEG Motor Imagery Classification".

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to eeg-adapt

EEG-Motor-Imagery-Classification-CNNs-TensorFlow
EEG Motor Imagery Tasks Classification (by Channels) via Convolutional Neural Networks (CNNs) based on TensorFlow
Stars: ✭ 125 (+290.63%)
Mutual labels:  eeg, motor-imagery
eeg-rsenet
Motor Imagery EEG Signal Classification Using Random Subspace Ensemble Network
Stars: ✭ 24 (-25%)
Mutual labels:  eeg, motor-imagery
Eeglab
EEGLAB is an open source signal processing environment for electrophysiological signals running on Matlab and developed at the SCCN/UCSD
Stars: ✭ 233 (+628.13%)
Mutual labels:  eeg
thesis
MSc thesis on: Classifying brain activity using EEG and automated time tracking of computer use (using ActivityWatch)
Stars: ✭ 44 (+37.5%)
Mutual labels:  eeg
eeguana
A package for manipulating EEG data in R.
Stars: ✭ 16 (-50%)
Mutual labels:  eeg
ganglion-ble
Web Bluetooth client for the Ganglion brain-computer interface by OpenBCI
Stars: ✭ 27 (-15.62%)
Mutual labels:  eeg
connectomemapper3
Connectome Mapper 3 is a BIDS App that implements full anatomical, diffusion, resting/state functional MRI, and recently EEG processing pipelines, from raw T1 / DWI / BOLD , and preprocessed EEG data to multi-resolution brain parcellation with corresponding connection matrices.
Stars: ✭ 45 (+40.63%)
Mutual labels:  eeg
Brainstorm3
Brainstorm software: MEG, EEG, fNIRS, ECoG, sEEG and electrophysiology
Stars: ✭ 213 (+565.63%)
Mutual labels:  eeg
Deep-Learning-for-BCI
Resources for Book: Deep Learning for EEG-based Brain-Computer Interface: Representations, Algorithms and Applications
Stars: ✭ 63 (+96.88%)
Mutual labels:  eeg
pyRiemann
Python machine learning package based on sklearn API for multivariate data processing and statistical analysis of symmetric positive definite matrices via Riemannian geometry
Stars: ✭ 470 (+1368.75%)
Mutual labels:  eeg
ScouseTom
Open Source EIT system using Keithley 6221 current source and EEG systems
Stars: ✭ 17 (-46.87%)
Mutual labels:  eeg
rteeg
[DEPRECATED: use MNE-Python] Python module to stream and analyze EEG data in real-time
Stars: ✭ 28 (-12.5%)
Mutual labels:  eeg
pybv
A lightweight I/O utility for the BrainVision data format, written in Python.
Stars: ✭ 18 (-43.75%)
Mutual labels:  eeg
brain-powered
With the Brain Powered honourscourse at the UvA we aimed to control a drone using brain signals, measured by means of EEG, only.
Stars: ✭ 13 (-59.37%)
Mutual labels:  eeg
eeg-explorer
Visual EEG readings from the Muse EEG Headset
Stars: ✭ 35 (+9.38%)
Mutual labels:  eeg
AttnSleep
[IEEE TNSRE] "An Attention-based Deep Learning Approach for Sleep Stage Classification with Single-Channel EEG"
Stars: ✭ 76 (+137.5%)
Mutual labels:  eeg
Moabb
Mother of All BCI Benchmarks
Stars: ✭ 214 (+568.75%)
Mutual labels:  eeg
EEG convolutional neural net
A convolutional neural network developed in python using the Keras machine learning framework used to categorize brain signal based on what a user was looking at when the EEG data was collected.
Stars: ✭ 20 (-37.5%)
Mutual labels:  eeg
EEGReader
EEG Reader is an Android mobile application, which reads EEG signal from NeuroSky mobile device connected to smartphone via Bluetooth.
Stars: ✭ 36 (+12.5%)
Mutual labels:  eeg
hnn-core
Simulation and optimization of neural circuits for MEG/EEG source estimates
Stars: ✭ 24 (-25%)
Mutual labels:  eeg

Codes for adaptation of a subject-independent deep convolutional neural network (CNN) based electroencephalography (EEG)-BCI system for decoding hand motor imagery (MI). Five schemes are presented, each of which fine-tunes an extensively trained, pre-trained model and adapt it to enhance the evaluation performance on a target subject.

Citation

@article{ZHANG20211,
title = "Adaptive transfer learning for EEG motor imagery classification with deep Convolutional Neural Network",
journal = "Neural Networks",
volume = "136",
pages = "1 - 10",
year = "2021",
issn = "0893-6080",
doi = "https://doi.org/10.1016/j.neunet.2020.12.013",
url = "http://www.sciencedirect.com/science/article/pii/S0893608020304305",
author = "Kaishuo Zhang and Neethu Robinson and Seong-Whan Lee and Cuntai Guan",
}

Summary of Results

Methodology Mean (SD) Median Range (Max-Min)
Subject-Specific 63.54 (14.25) 60.50 57.00 (100.00-43.00)
Subject-Independent 84.19 (9.98) 84.50 47.50 (99.50-52.00)
Subject-Adaptive
(Scheme 4, 80%)
86.89 (11.41) 88.50 44.00 (100.00-56.00)

A detailed subject-level result can be found in result_table.pdf

Resources

  • Raw Dataset: Link
  • Sample pre-trained subject-independent model: Link

Instructions

Install the dependencies

It is recommended to create a virtual environment with python version 3.7 and activate it before running the following:

pip install -r requirements.txt

Obtain the raw dataset

Download the raw dataset from the resources above, and save them to the same folder. To conserve space, you may only download files that ends with EEG_MI.mat.

Pre-process the raw dataset

The following command will read the raw dataset from the $source folder, and output the pre-processed data KU_mi_smt.h5 into the $target folder.

python preprocess_h5_smt.py $source $target

Training and evaluation

Subject-specific classification

usage: train_within.py [-h] [-gpu GPU] [-start START] [-end END] [-subj SUBJ [SUBJ ...]] datapath outpath

Subject-specific classification with KU Data

positional arguments:
  datapath              Path to the h5 data file
  outpath               Path to the result folder

optional arguments:
  -h, --help            show this help message and exit
  -gpu GPU              The gpu device index to use
  -start START          Start of the subject index
  -end END              End of the subject index (not inclusive)
  -subj SUBJ [SUBJ ...]
                        Explicitly set the subject number. This will override the start and end argument

To train the subject-specific model for all subjects, run

python train_within.py $datapath $outpath

Subject-independent classification

usage: train_base.py [-h] -fold FOLD [-gpu GPU] datapath outpath

Subject independent classification with KU Data

positional arguments:
  datapath    Path to the h5 data file
  outpath     Path to the result folder

optional arguments:
  -h, --help  show this help message and exit
  -fold FOLD  k-fold index, starts with 0
  -gpu GPU    The gpu device to use

The $fold index has a one-to-one mapping to the subject index, as we have shuffled the subjects in a pre-defined order (using random seed 20200205). This is listed in subj-to-fold.csv file.

To train the subject-independent model for all subjects, run

python train_base.py $datapath $outpath -fold $fold

for $fold ranging [0...53] inclusive.

This process is likely to take some time. We have provided some sample pre-trained models in the resources above.

Subject-adaptive classification

usage: train_adapt.py [-h] [-scheme SCHEME] [-trfrate TRFRATE] [-lr LR] [-gpu GPU] datapath modelpath outpath

Subject adaptative classification with KU Data

positional arguments:
  datapath          Path to the h5 data file
  modelpath         Path to the base model folder
  outpath           Path to the result folder

optional arguments:
  -h, --help        show this help message and exit
  -scheme SCHEME    Adaptation scheme
  -trfrate TRFRATE  The percentage of data for adaptation
  -lr LR            Learning rate
  -gpu GPU          The gpu device to use

As an example, to train the subject-adaptive model for all subjects using the default configuration (scheme 4, adaptation rate 100%, learning rate 0.0005), run:

python train_adapt.py $datapath $modelpath $outpath

The $modelpath corresponds to the result folder of the subject-independent classification, or the path to the pre-trained model.

Training on multiple GPUs

To speed up training, you can make use of multiple GPUs. In the tasks_* folder, we provide a sample script for training on 8 GPUs. To generate these scripts, run:

python generate.py
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].