Code to accompany our International Conference on Pattern Recognition (ICPR) paper entitled - Leveraging Synthetic Subject Invariant EEG Signals for Zero Calibration BCI.
generate_sisgan.py
- Our proposed SIS-GAN model for generating subject-invariant SSVEP-based EEG datatrain_subject_classifier.py
- Subject classification network for biometric pattern detectionssvep_classification.py
- SSVEP frequency classification networkplot_subject_softmax.py
- Subject-invariance evaluation using softmax probability analysismodels.py
- Neural network architectures for all models
utils.py
- Helper functions for data loading, logging, and model utilities
- Create a new uv environment with Python 3.12:
uv venv --python 3.12
- Install the required dependencies defined in pyproject.toml:
uv pip install -e .
Please follow the steps below to run the code to train the various components. Please read the Configuration section to understand how to modify the training parameters to suit real-world applications. The number of epochs is set to 1 by default for demonstration purposes, but you will need to increase this for meaningful results.
This is the main pipeline for zero-calibration BCI evaluation, where we simulate having an unseen subject:
Step 1: Create pretrained subject classification weights
uv run python -m sis_gan.train_subject_classifier --validation_strategy loo
This trains subject classifiers using leave-one-out cross-validation, creating pretrained weights for each "unseen" subject scenario.
Step 2: Generate synthetic EEG data
uv run python -m sis_gan.generate_sisgan
Trains the SIS-GAN using data from "seen" subjects (excluding the test subject) and generates synthetic SSVEP signals.
Step 3: Evaluate SSVEP classification performance
uv run python -m sis_gan.ssvep_classification
Tests how well SSVEP frequency classification works when trained on synthetic data and tested on real unseen subject data.
Step 4: Verify subject-invariance
uv run python -m sis_gan.plot_subject_softmax
Analyzes whether the generated synthetic data contains subject-specific biometric patterns. Low, uniformly distributed probabilities indicate successful subject-invariance.
If you only want to evaluate subject classification performance on the full dataset without running the complete pipeline:
uv run python -m sis_gan.train_subject_classifier --validation_strategy stratified
Performs standard train/test split (80/20) for subject classification evaluation across the entire dataset.
The sample_data
folder contains randomly generated data representing the shape of the input EEG data. Note: This is not real EEG data and is provided only for demonstration purposes.
Model configurations are controlled using YAML files in the config
directory. Modify these files to customize:
- Network architectures
- Training hyperparameters
- Data processing parameters
- Validation strategies
Note: By default, all models are only trained for a single epoch for demonstration purposes. Adjust the num_epochs
parameter in the config files to train for longer - you will need to increase the number of epochs for meaningful results.
uv pip install -e ".[dev]"
uv run pre-commit install
uv run pre-commit run --all-files
- Subject-Invariant: Generated data should not contain biometric patterns specific to individual subjects
- Zero-Calibration: Using synthetic data to train models for completely unseen subjects without any calibration data
- Leave-One-Out: Each subject is treated as "unseen" while others are used for training, simulating real-world deployment scenarios
Please cite the associated paper if you use this code:
@inproceedings{aznan2021leveraging,
title={Leveraging Synthetic Subject Invariant EEG Signals for Zero Calibration BCI},
author={Aznan, Nik Khadijah Nik and Atapour-Abarghouei, Amir and Bonner, Stephen and Connolly, Jason D and Breckon, Toby P},
booktitle={2020 25th International Conference on Pattern Recognition (ICPR)},
pages={10418--10425},
year={2021},
organization={IEEE}
}