Contextual Transformer-Based Modeling of Harmful Brain Activity in EEG
WaveEEG is a long-context EEG classification framework designed to detect and categorize clinically relevant harmful brain activity patterns in continuous multichannel EEG.
The approach adapts a speech-pretrained Wave2Vec2.0 transformer to raw EEG signals, enabling contextual modeling over extended temporal windows that are critical for identifying periodic and rhythmic abnormalities.
This repository provides a reference implementation and full experimental analysis corresponding to the WaveEEG framework.
Project repository:
https://github.com/Deepak-Mewada/WaveEEG
HMS Harmful Brain Activity Classification (HBAC)
Dataset usage is subject to the original HMS/Kaggle terms and conditions.
WaveEEG/
│
├── WaveEEG.py
│ Main training and evaluation script implementing the WaveEEG model
│
├── posthoc_analysis.py
│ Post-hoc analysis and extended visualization utilities
│
├── README.md
│ Repository documentation
│
├── per_class_metrics.csv
│ Per-class precision, recall, F1-score, and support
│
├── Figures (PNG / PDF)
│ ├── 01_accuracy_loss_curves.*
│ ├── 02_f1_kappa_curves.*
│ ├── 03_confusion_matrix.*
│ ├── 04_confusion_matrix_normalized.*
│ ├── 05_per_class_metrics.*
│ ├── 06_roc_curves.*
│ ├── 07_precision_recall_curves.*
│ ├── 07_calibration_curve.*
│ ├── t-SNE visualizations (true labels, confidence, correctness)
All figures are generated automatically by the evaluation pipeline and are suitable for direct inclusion in manuscripts or supplementary material.
WaveEEG operates on fixed-length EEG segments extracted from continuous recordings:
The design explicitly targets EEG patterns defined by sustained temporal organization over tens of seconds.
Install dependencies:
pip install torch transformers numpy pandas scikit-learn
Update the dataset path in WaveEEG.py:
CONFIG["base_dir"] = "/path/to/hms-hbac"
Train and evaluate the model:
python WaveEEG.py
All metrics, figures, and tables are generated automatically.
This software is provided for research purposes only.
Not a medical device.
Not approved for clinical diagnosis or treatment.
Outputs must not be used for patient care decisions.
If you use this code or build upon this work, please cite:
Deepak Mewada et al.
Transformer-Based Contextual Modeling of Harmful Brain Activity in Multichannel EEG
2025
For questions or issues related to the implementation, please open a GitHub issue in this repository.
5 commits
Python
100.0%
Contextual Transformer-Based Modeling of Harmful Brain Activity in EEG
WaveEEG is a long-context EEG classification framework designed to detect and categorize clinically relevant harmful brain activity patterns in continuous multichannel EEG.
The approach adapts a speech-pretrained Wave2Vec2.0 transformer to raw EEG signals, enabling contextual modeling over extended temporal windows that are critical for identifying periodic and rhythmic abnormalities.
This repository provides a reference implementation and full experimental analysis corresponding to the WaveEEG framework.
Project repository:
https://github.com/Deepak-Mewada/WaveEEG
HMS Harmful Brain Activity Classification (HBAC)
Dataset usage is subject to the original HMS/Kaggle terms and conditions.
WaveEEG/
│
├── WaveEEG.py
│ Main training and evaluation script implementing the WaveEEG model
│
├── posthoc_analysis.py
│ Post-hoc analysis and extended visualization utilities
│
├── README.md
│ Repository documentation
│
├── per_class_metrics.csv
│ Per-class precision, recall, F1-score, and support
│
├── Figures (PNG / PDF)
│ ├── 01_accuracy_loss_curves.*
│ ├── 02_f1_kappa_curves.*
│ ├── 03_confusion_matrix.*
│ ├── 04_confusion_matrix_normalized.*
│ ├── 05_per_class_metrics.*
│ ├── 06_roc_curves.*
│ ├── 07_precision_recall_curves.*
│ ├── 07_calibration_curve.*
│ ├── t-SNE visualizations (true labels, confidence, correctness)
All figures are generated automatically by the evaluation pipeline and are suitable for direct inclusion in manuscripts or supplementary material.
WaveEEG operates on fixed-length EEG segments extracted from continuous recordings:
The design explicitly targets EEG patterns defined by sustained temporal organization over tens of seconds.
Install dependencies:
pip install torch transformers numpy pandas scikit-learn
Update the dataset path in WaveEEG.py:
CONFIG["base_dir"] = "/path/to/hms-hbac"
Train and evaluate the model:
python WaveEEG.py
All metrics, figures, and tables are generated automatically.
This software is provided for research purposes only.
Not a medical device.
Not approved for clinical diagnosis or treatment.
Outputs must not be used for patient care decisions.
If you use this code or build upon this work, please cite:
Deepak Mewada et al.
Transformer-Based Contextual Modeling of Harmful Brain Activity in Multichannel EEG
2025
For questions or issues related to the implementation, please open a GitHub issue in this repository.
5 commits
Python
100.0%