tidiane-camaret/EEGClip

29

stars

197

commits

Jupyter Notebook

primary language

Oct 6, 2025

updated

README

EEG-CLIP: Learning EEG Representations from Natural Language Descriptions

EEG-CLIP is a contrastive learning framework that aligns EEG time series data with their corresponding clinical text descriptions in a shared embedding space. Inspired by CLIP (Contrastive Language-Image Pretraining), EEG-CLIP enables versatile EEG representation learning for improved pathology detection and other downstream tasks in low-data regimes.

EEG-CLIP results on the age classification task

Quick Start

Installation

# Clone the repository
git clone https://github.com/tidiane-camaret/EEGClip.git
cd EEGClip

# Install dependencies
pip install -r requirements.txt
pip install -e .

Note: You may need to modify paths to datasets and pretrained models in configs/preprocess_config.py

1. Preprocessing

Generate text embeddings using the ClinicalBERT model:

python scripts/text_preprocessing/text_embedding.py

2. Training EEGClip

Train the EEGClip model on the TUH EEG Abnormal Corpus:

python scripts/eegclip_train_eval.py

3. Evaluation

3.1 Standard Classification

Train and evaluate a classifier using the frozen EEG encoder:

python scripts/classif/classification_tuh.py

Options:

  • --task_name: Classification task (pathological, age, gender, etc.)
  • --train_frac: Control size of training data for few-shot experiments
  • --weights: Select pretrained weights
  • --freeze_encoder: Toggle EEG encoder freezing

3.2 Zero-shot Classification

Evaluate the model's ability to classify EEG recordings using only text prompts without additional training:

python scripts/classif/classification_zero_shot_tuh.py

Citation

If you use EEG-CLIP in your research, please cite our paper:

@ARTICLE{10.3389/frobt.2025.1625731,
AUTHOR={Camaret Ndir, Tidiane  and Schirrmeister , Robin T.  and Ball , Tonio },
TITLE={EEG-CLIP: learning EEG representations from natural language descriptions},
JOURNAL={Frontiers in Robotics and AI},
VOLUME={Volume 12 - 2025},
YEAR={2025},
URL={https://www.frontiersin.org/journals/robotics-and-ai/articles/10.3389/frobt.2025.1625731},
DOI={10.3389/frobt.2025.1625731},
ISSN={2296-9144}]

Dataset

This work uses the Temple University Hospital (TUH) EEG Corpus:

@article{obeid_temple_2016,
  title={The Temple University Hospital EEG Data Corpus},
  volume={10},
  journal={Frontiers in Neuroscience},
  author={Obeid, Iyad and Picone, Joseph},
  year={2016},
  pages={196}
}

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributors

tidiane-camaret

194 commits

rachanaaaa

3 commits

tidiane-camaret/EEGClip

29

stars

197

commits

Jupyter Notebook

primary language

Oct 6, 2025

updated

README

EEG-CLIP: Learning EEG Representations from Natural Language Descriptions

EEG-CLIP is a contrastive learning framework that aligns EEG time series data with their corresponding clinical text descriptions in a shared embedding space. Inspired by CLIP (Contrastive Language-Image Pretraining), EEG-CLIP enables versatile EEG representation learning for improved pathology detection and other downstream tasks in low-data regimes.

EEG-CLIP results on the age classification task

Quick Start

Installation

# Clone the repository
git clone https://github.com/tidiane-camaret/EEGClip.git
cd EEGClip

# Install dependencies
pip install -r requirements.txt
pip install -e .

Note: You may need to modify paths to datasets and pretrained models in configs/preprocess_config.py

1. Preprocessing

Generate text embeddings using the ClinicalBERT model:

python scripts/text_preprocessing/text_embedding.py

2. Training EEGClip

Train the EEGClip model on the TUH EEG Abnormal Corpus:

python scripts/eegclip_train_eval.py

3. Evaluation

3.1 Standard Classification

Train and evaluate a classifier using the frozen EEG encoder:

python scripts/classif/classification_tuh.py

Options:

  • --task_name: Classification task (pathological, age, gender, etc.)
  • --train_frac: Control size of training data for few-shot experiments
  • --weights: Select pretrained weights
  • --freeze_encoder: Toggle EEG encoder freezing

3.2 Zero-shot Classification

Evaluate the model's ability to classify EEG recordings using only text prompts without additional training:

python scripts/classif/classification_zero_shot_tuh.py

Citation

If you use EEG-CLIP in your research, please cite our paper:

@ARTICLE{10.3389/frobt.2025.1625731,
AUTHOR={Camaret Ndir, Tidiane  and Schirrmeister , Robin T.  and Ball , Tonio },
TITLE={EEG-CLIP: learning EEG representations from natural language descriptions},
JOURNAL={Frontiers in Robotics and AI},
VOLUME={Volume 12 - 2025},
YEAR={2025},
URL={https://www.frontiersin.org/journals/robotics-and-ai/articles/10.3389/frobt.2025.1625731},
DOI={10.3389/frobt.2025.1625731},
ISSN={2296-9144}]

Dataset

This work uses the Temple University Hospital (TUH) EEG Corpus:

@article{obeid_temple_2016,
  title={The Temple University Hospital EEG Data Corpus},
  volume={10},
  journal={Frontiers in Neuroscience},
  author={Obeid, Iyad and Picone, Joseph},
  year={2016},
  pages={196}
}

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributors

tidiane-camaret

194 commits

rachanaaaa

3 commits

Languages

Jupyter Notebook

99.4%