EEG-Multilayer-GTCN is a modular deep learning project for EEG-based emotion recognition using graph transformer and GCN layers to model physical and functional EEG connectivity.
This code implements a dual-graph EEG emotion recognition pipeline:
- Physical graph: a structural/prior graph created over EEG feature nodes.
- Functional graph: a correlation-based graph built from extracted EEG features.
- Multilayer-GTCN model: each graph branch uses
TransformerConvandGCNConv; the two learned graph representations are concatenated for three-class emotion classification.
EEG-Multilayer-GTCN/
├── configs/
│ └── config.yaml
├── data/
│ └── .gitkeep
├── outputs/
│ └── .gitkeep
├── plots/
│ └── .gitkeep
├── scripts/
│ └── run_train.py
├── src/
│ └── eeg_multilayer_gtcn/
│ ├── __init__.py
│ ├── config.py
│ ├── data_loader.py
│ ├── preprocessing.py
│ ├── features.py
│ ├── graphs.py
│ ├── models.py
│ ├── train.py
│ ├── evaluate.py
│ ├── plots.py
│ └── utils.py
├── legacy/
│ └── original_single_file_script.py
├── .gitignore
├── requirements.txt
├── pyproject.toml
└── README.md
Create and activate a conda environment:
conda create -n eeg_gtcn python=3.10 -y
conda activate eeg_gtcnInstall PyTorch according to your CUDA version. Example for CUDA 12.1:
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121Install the remaining packages:
pip install -r requirements.txtIf torch-geometric does not install correctly, install it using the official PyTorch Geometric command that matches your PyTorch and CUDA version.
Do not upload SEED .mat files to GitHub. Keep the dataset locally on your computer.
Edit configs/config.yaml:
data:
seed_path: "G:/SEED/Preprocessed_EEG/exp1"
label_file_path: "G:/SEED/Preprocessed_EEG/exp1/label.mat"Change these paths according to your computer.
From the project root:
python scripts/run_train.py --config configs/config.yamlThe pipeline will:
- Load SEED EEG
.matfiles. - Apply bandpass filtering.
- Perform subject-wise normalization.
- Segment EEG trials with baseline correction.
- Extract HFD, entropy, and differential entropy features.
- Apply fold-wise scaling and PCA.
- Build physical and functional graph views.
- Train the Multilayer-GTCN model using stratified K-fold cross-validation.
- Save reports, trained fold models, confusion matrix, accuracy/loss curves.
Generated files are saved in:
outputs/
plots/
Example outputs:
outputs/results.json
outputs/best_model_fold_1.pt
plots/accuracy_curve.png
plots/loss_curve.png
plots/confusion_matrix_3class.png
- Dataset files are excluded by
.gitignore. - Config-based paths make the project safe for public GitHub upload.
- Scaling, PCA are applied inside each fold to reduce data leakage.
- For large datasets, use a sparse graph setting instead of a fully complete graph to avoid memory problems.
The project is named EEG-Multilayer-GTCN because the code is based on the MultilayerGTCN model using TransformerConv and GCNConv.
If this work is useful for your research, please cite:
@ARTICLE{10.3389/fnhum.2025.1715410,
AUTHOR={Rahman, S. M. Atoar and Khalil, Md Ibrahim and Zhou, Hui and Ding, Ziyun and Guo, Yu },
TITLE={Exploring physical and functional EEG connectivity with multilayer graph transformer convolutional networks for emotion recognition},
JOURNAL={Frontiers in Human Neuroscience},
VOLUME={Volume 19 - 2025},
YEAR={2026},
URL={https://www.frontiersin.org