braingnn

Train and evaluate BrainGNN graph neural networks on fMRI connectivity matrices for phenotype prediction.

89|5|Updated Mar 25, 2026
One-click install
npx skills add https://github.com/CUHK-AIM-Group/NeuroDiscovery --skill braingnn-cuhk-aim-group
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: braingnn
Source: https://github.com/CUHK-AIM-Group/NeuroDiscovery/tree/main/skills/brain_gnn
Command: npx skills add https://github.com/CUHK-AIM-Group/NeuroDiscovery --skill braingnn-cuhk-aim-group

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires torch, torch-geometric, numpy, pandas, and includes scripts (resource) components.

What problem does it solve? Running BrainGNN for fMRI-based phenotype prediction requires careful handling of graph construction, Fisher-z connectivity transforms, and PyTorch Geometric compatibility, which this Skill codifies into a reproducible training and evaluation workflow. ## Core Features & Use Cases - Graph construction and training: Builds full ROI-level graphs from per-subject .pt connectivity files and trains BrainGNN with K-fold cross-validation for classification or regression. - Multi-model benchmarking: Scripts compare BrainGNN against BNT, BrainNetCNN, LGGNN, IBGNN, and ComBrainTF across multiple atlases on lifespan age regression. - Hypothesis-driven validation: Maps knowledge-graph hypotheses to HCP phenotype labels and AAL-116 ROI masks for region-guided subgraph training and edge boosting. - Use Case: A researcher with preprocessed HCP fMRI data trains BrainGNN on the Schaefer-100 atlas to predict gender, then sweeps atlases to compare accuracy and inspect interpretable pooling scores. ## Quick Start Ask the agent to train BrainGNN on the aal_116 atlas with the HCP gender labels CSV using 5-fold cross-validation and report test accuracy.

Frequently Asked Questions about braingnn

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I train BrainGNN on fMRI connectivity data?

Run the train.py script with an atlas name, a labels CSV, and a subjects file, choosing classification or regression via the --task flag. The script auto-infers ROI count and input dimensions from the first subject's .pt file and runs K-fold cross-validation.

What input format does BrainGNN expect for fMRI data?

Each subject needs a .pt file containing a Fisher-z transformed FC matrix, time series, edge index, and edge attributes, stored under data/braingnn_input/<atlas>/. The adapter inverts Fisher-z with torch.tanh, zeros the diagonal, and builds a full graph with absolute Pearson r edge weights.

Does BrainGNN work on Windows without torch_sparse?

Yes, this reimplementation removes the torch_sparse dependency by replacing spspmm-based adjacency squaring with add_self_loops and remove_self_loops. It runs directly on Windows with PyTorch Geometric 2.3 or later.

Why does BrainGNN training diverge or produce NaN losses?

Divergence usually comes from unnormalized Fisher-z node features feeding message-passing layers without normalization. Fixes include per-subject input z-scoring, LayerNorm after the GNN encoder, gradient clipping at 1.0, and early abort when validation MAE exceeds a threshold.

How do I fix stale PyG cache after changing BrainGNN data?

Delete the data/braingnn_cache/<atlas>/ directory before retraining, since PyG InMemoryDataset caches processed graphs. The sweep_atlases.py script handles this cache invalidation automatically.

Can BrainGNN combine fMRI connectivity with T1 structural features?

Yes, the --include-t1 flag appends z-scored gray-matter volume from per-subject .npz files as an extra node feature column. The T1 files must match the atlas and contain gm_volume_mm3 arrays aligned with the ROI count.