Official implementation of "On the Role of Low-Level Visual Features in EEG-Based Image Reconstruction" .
conda env create -f environment.yml
conda activate BCIpip install wandb
pip install einops
pip install open_clip_torch
pip install transformers==4.28.0.dev0
pip install diffusers==0.24.0
pip install braindecode==0.8.1In this study, we directly used the preprocessed EEG data and the VAE latents provided by [Li et al.](https://arxiv.org/abs/2403.07721#:~:text=In%20this%20study%2C%20we%20present%20an%20end-to-end[...] which can be downloaded on their Huggingface. The raw visual stimuli can be downloaded on OSF.
After downloading, your data directories should look like:
EEG_data/
├── sub-01/
│ ├── preprocessed_eeg_training.npy
│ ├── preprocessed_eeg_test.npy
├── sub-02/
│ ├── preprocessed_eeg_training.npy
│ ├── preprocessed_eeg_test.npy
# First modify the Config file to speficy data folders
vi data_config.json
# Train the stage-1 high-level models for the 10 subjects
bash EEG_stage1_highlevel.sh --gpu 0 --data_path [your EEG path]
# Train the stage-2 diffusion models for the 10 subjects
bash EEG_stage2_highlevel.sh --gpu 0 --data_path [your EEG path] --save_modelbash EEG_stage1_lowlevel.sh --gpu 0 --data_path [your EEG path] --save_modelThese scripts will create csv files that store the configuration and the metric values across models and subjects. And the first 30 reconstructions will also be saved.
# Low-level reconstruction
bash EEG_lowlevel_metrics.sh
# High-level reconstruction
bash EEG_highlevel_metrics.sh
# Two-level reconstruction
bash EEG_final_metrics.shThe paper for this code has been published. Please cite the published version (DOI: 10.1109/MLSP62443.2025.11204210) when using this code or the reported results.
Suggested citation (plain text):
On the Role of Low-Level Visual Features in EEG-Based Image Reconstruction. Junkai Yang, Arno Onken, 2025. IEEE MLSP. DOI: 10.1109/MLSP62443.2025.11204210
BibTeX template for this work (published):
@inproceedings{yang2025_lowlevel_eeg,
title = {On the Role of Low-Level Visual Features in EEG-Based Image Reconstruction},
author = {Yang, J. and Coauthor, A. and Coauthor, B.},
booktitle = {Proceedings of the 2025 IEEE International Workshop on Machine Learning for Signal Processing (MLSP)},
year = {2025},
doi = {10.1109/MLSP62443.2025.11204210},
url = {https://doi.org/10.1109/MLSP62443.2025.11204210},
note = {Code: https://github.com/jyang635/EEG_decoding}
}This project is licensed under the MIT License - see the LICENSE file for details.
For questions or issues, please:
- Open an issue on GitHub
- Contact: [[email protected]]