This repo contains Matlab and Python code for the SBLEST (Sparse Bayesian Learning for End-to-End Spatio-Temporal-Filtering-Based Single-Trial EEG Classification) algorithm, as well as implementations of Convolutional Neural Networks (CNNs) used in the paper. Detailed information about the algorithms and CNN implementations can be found in W. Wang, F. Qi, D. Wipf, C. Can, T. Yu, Z. Gu, Y. Li, Z. Yu, W. Wu. Sparse Bayesian Learning for End-to-End EEG Decoding, IEEE Transactions on Pattern Analysis and Machine Intelligence, 2023, 10.1109/tpami.2023.3299568.
The data used in this repository is from Subject L1 (foot vs. tongue) in Dataset II, as mentioned in the referenced paper.
- Dataset2_L1_FootTongue_train.mat — This file contains the training data used in this repository.
- Dataset2_L1_FootTongue_test.mat — This file contains the test data used in this repository.
The MATLAB scripts provided in this section implement the SBLEST algorithm and have been tested with MATLAB R2018b.
-
SBLEST.m —Matlab code for the SBLEST algorithm.
-
SBLEST_main.m — An example code for classifying single-trial EEG data using SBLEST in Matlab.
-
To run the code, download and extract them into a folder of your choice, and navigate to this folder within MATLAB.
-
At the MATLAB command line, type
SBLEST_main
The Python scripts for SBLEST are implemented in PyTorch and have been fully tested with Python 3.9.
-
SBLEST_model.py —Python code for the SBLEST algorithm.
-
SBLEST_main.py — An example code for classifying single-trial EEG data using SBLEST in Python.
sCNN and dCNN are implemented in PyTorch using the braindecode package, which is provided at https://github.com/robintibor/braindecode.
EEGNet is implemented in TensorFlow using the Keras API, with the model provided at https://github.com/vlawhern/arl-eegmodels.
EEG-inception and EEGSym are also implemented in TensorFlow, with the models provided at https://github.com/esantamariavazquez/EEGInception and https://github.com/Serpeve/EEGSym, respectively.
-
sCNN_main.py — An example code for classifying single-trial EEG data using sCNN.
-
dCNN_main.py — An example code for classifying single-trial EEG data using dCNN.
-
EEGNet_main.py — An example code for classifying single-trial EEG data using EEGNet.
-
EEGModels.py — A model file used in the EEGNet implementation.
-
EEGInception_main.py — An example code for classifying single-trial EEG data using EEG-inception.
-
EEGInception.py — A model file used in the EEG-inception implementation.
-
EEGSym_main.py — An example code for classifying single-trial EEG data using EEGSym.
-
EEGSym_architecture.py — A model file used in the EEGSym implementation.
-
EEGSym_DataAugmentation.py — A python file for data augmentation used in the EEGSym implementation.
-
signal_target.py — A code for preprocessing the signal and target used in all the cNNs implementations.