| # Supplementary Material: EEGFaceSem |
|
|
| This repository contains the official implementation for the paper "EEGFaceSem". It provides the necessary code to reproduce the benchmarking results, generate images from latent vectors, and preprocess the dataset from raw files. |
|
|
| ## Introduction |
|
|
| This package, `EEGFaceSem`, provides tools to: |
| 1. Benchmark EEG classification models, including LDA, EEGNet, and our proposed EEGPT model. |
| 2. Generate facial images from EEG signals using a pretrained Progressive GAN model. |
| 3. Prepare the dataset from raw files. |
|
|
| ## Installation |
|
|
| To get started, clone this repository and install the package using pip. We recommend using a virtual environment. |
|
|
| ```bash |
| pip install -r requirements.txt |
| pip install . |
| ``` |
|
|
| ## Dataset |
|
|
| This project uses the EEGFaceSem dataset. Due to its size, the data is not included in this repository. |
|
|
| **Option 1: Download Processed Data (Recommended)** |
|
|
| You can download the preprocessed data files directly from OSF at [Link removed for review purposes] or Hugging Face at [Link removed for review purposes]. |
|
|
| Download the files and place them in the `data/processed/` directory. |
|
|
| **Option 2: Process Raw Data** |
|
|
| 1. Download the raw data from OSF at [Link removed for review purposes]. |
| 2. Place the downloaded files into the `data/raw/` directory. |
| 3. Run the preparation script: |
| ```python |
| import EEGFaceSem |
| |
| EEGFaceSem.prepare_data() |
| ``` |
| This will process the raw files and save the results in `data/processed/`, which will be used by the benchmark scripts. |
| |
| ## Usage |
|
|
| The core functionalities are exposed through the `EEGFaceSem` package. |
|
|
| ### Benchmarking |
|
|
| You can run the benchmarks for different models directly from Python. The results will be saved to a `logs/` directory. |
|
|
| ```python |
| import EEGFaceSem |
| |
| # Run the benchmark for the LDA model |
| EEGFaceSem.benchmark(models="LDA") |
| |
| # Run the benchmark for the EEGPT model |
| EEGFaceSem.benchmark_eegpt() |
| ``` |
|
|
| ### Image Generation from Latent Vectors |
|
|
| To generate an image from a latent vector using the pretrained Progressive GAN model, use the following function. |
|
|
| ```python |
| import EEGFaceSem |
| import numpy as np |
| images = EEGFaceSem.generate(np.random.randn(1, 512)) |
| images[0].save("generated_face.png") |
| ``` |
|
|
| ## Repository Structure |
|
|
| ``` |
| EEGFaceSem/ |
| ├── EEGFaceSem/ # The installable Python package |
| │ ├── __init__.py |
| │ ├── benchmark.py # Code for LDA, EEGNet benchmarks |
| │ ├── generation.py # Image generation logic |
| │ ├── preprocess.py # Data preparation script |
| │ ├── models.py # Model definitions |
| │ ├── utils.py # Data loading and utility functions |
| │ ├── EEGModels.py # EEGNet definitions |
| │ └── EEGPT/ # Submodule for EEGPT dependencies |
| │ └── ... |
| │ └── pgan/ # Submodule for Progressive GAN dependencies |
| │ └── ... |
| ├── data/ |
| │ ├── raw/ # (Empty) For raw data |
| │ └── processed/ # (Empty) For processed data |
| ├── models/ |
| │ ├── eegpt_mcae_58chs_4s_large4E.ckpt # (Empty) Pretrained EEGPT model to be downloaded |
| │ └── karras2018iclr-celebahq-1024x1024.pkl # (Empty) Pretrained Progressive GAN model to be downloaded |
| ├── scripts/ |
| │ └── summarize_results.py # Script to evaluate benchmark outputs |
| ├── README.md |
| ├── setup.py |
| └── requirements.txt |
| ``` |