Skip to content

MHersche/eegnet-based-embedded-bci

Repository files navigation

Copyright (C) 2020 ETH Zurich, Switzerland. SPDX-License-Identifier: Apache-2.0. See LICENSE file for details.

Authors: Xiaying Wang, Michael Hersche

An Accurate EEGNet-based Motor-Imagery Brain--Computer Interface for Low-Power Edge Computing

In this repository, we share the code for classifying MI data of the Physionet EEG Motor Movement/Imagery Dataset using EEGNet. For details, please refer to the papers below.

If this code proves useful for your research, please cite

Xiaying Wang, Michael Hersche, Batuhan Tömekce, Burak Kaya, Michele Magno, Luca Benini, "An Accurate EEGNet-based Motor-Imagery Brain--Computer Interface for Low-Power Edge Computing", in IEEE International Symposium on Medical Measurements and Applications (MEMEA), 2020.

Installing Dependencies

You will need a machine with a CUDA-enabled GPU and the Nvidia SDK installed to compile the CUDA kernels. Further, we have used conda as a python package manager and exported the environment specifications to dependency.yml. You can recreate our environment by running

conda env create -f dependency.yml -n mybciEnv 

Make sure to activate the environment before running any code.

If get a batchnormalization error when running the code, follow the instructions by gurjar112 here:

change "()" to "[ ]" in line no 1908,1910,1914, 1918 in anaconda3/envs/mybciEnv/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py (e.g. beta = tf.reshape(beta, [-1])) and have 'channels_last' in keras.json

Download Physionet Dataset

EEGNet: Download the .edf files of the Physionet EEG Motor Movement/Imagery Dataset here, unpack it, and put into the folder dataset/

Train and Validate Global and Subject-specific Models

Global models are trained and validated in main_global.py. Results are in results/your-global-experiment/stats and global models in results/your-experiment-name/model.

$ (mybciEnv) python3 main_global.py

After having trained and stored the global model, they can be refined by doing subject-specific transfer learning (SS-TL) using main_ss.py.

$ (mybciEnv) python3 main_ss.py

Plots

A notebook with selected plots is available under plot_nbook/.

License and Attribution

Please refer to the LICENSE file for the licensing of our code.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published