Skip to content

atickeeeuiu/Multilayer-Graph-Transformer-Network

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Multilayer-Graph-Transformer-Network

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.

Model idea

This code implements a dual-graph EEG emotion recognition pipeline:

  1. Physical graph: a structural/prior graph created over EEG feature nodes.
  2. Functional graph: a correlation-based graph built from extracted EEG features.
  3. Multilayer-GTCN model: each graph branch uses TransformerConv and GCNConv; the two learned graph representations are concatenated for three-class emotion classification.

Repository structure

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

Installation

Create and activate a conda environment:

conda create -n eeg_gtcn python=3.10 -y
conda activate eeg_gtcn

Install PyTorch according to your CUDA version. Example for CUDA 12.1:

pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121

Install the remaining packages:

pip install -r requirements.txt

If torch-geometric does not install correctly, install it using the official PyTorch Geometric command that matches your PyTorch and CUDA version.

Dataset setup

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.

Run training

From the project root:

python scripts/run_train.py --config configs/config.yaml

The pipeline will:

  1. Load SEED EEG .mat files.
  2. Apply bandpass filtering.
  3. Perform subject-wise normalization.
  4. Segment EEG trials with baseline correction.
  5. Extract HFD, entropy, and differential entropy features.
  6. Apply fold-wise scaling and PCA.
  7. Build physical and functional graph views.
  8. Train the Multilayer-GTCN model using stratified K-fold cross-validation.
  9. Save reports, trained fold models, confusion matrix, accuracy/loss curves.

Outputs

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

Important notes

  • 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.

Project name

The project is named EEG-Multilayer-GTCN because the code is based on the MultilayerGTCN model using TransformerConv and GCNConv.

Citation

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

About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors