File size: 3,477 Bytes
196bee3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | # 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
``` |