# hennyjie/braingb architecture

> Architecture diagram of the GitHub repository hennyjie/braingb, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hennyjie/braingb
- Repository: https://github.com/hennyjie/braingb

## Overview

BrainGB is a framework for classifying brain-network graphs with graph neural networks. Its documented user workflow is to prepare subject labels and brain connectivity matrices, load and transform them into graph data, then run an experiment using a selectable model and pooling strategy. The graph separates dataset construction, feature transforms, model architectures, and supporting utilities. The README documents the experiment entry command, but its training implementation was not sampled; links into that runtime are therefore omitted.

Main entry points: [`src/dataset/brain_dataset.py`](https://github.com/hennyjie/braingb/blob/master/src/dataset/brain_dataset.py) (Graph dataset), [`src/dataset/transforms.py`](https://github.com/hennyjie/braingb/blob/master/src/dataset/transforms.py) (Feature transforms), [`src/dataset/brain_data.py`](https://github.com/hennyjie/braingb/blob/master/src/dataset/brain_data.py) (Brain graph data), [`src/dataset/abcd/load_abcd.py`](https://github.com/hennyjie/braingb/blob/master/src/dataset/abcd/load_abcd.py) (Cohort loaders)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Brain data"]
  node_brain_dataset["Graph dataset<br/>[brain_dataset.py]"]
  node_cohort_loaders["Cohort loaders<br/>[load_abcd.py]"]
  node_brain_data["Brain graph data<br/>[brain_data.py]"]
  node_maskable_list["Maskable lists<br/>[maskable_list.py]"]
end

subgraph group_features["Node features"]
  node_transforms["Feature transforms<br/>[transforms.py]"]
  node_transform_base["Transform interface<br/>[base_transform.py]"]
  node_dataset_utils["Graph transforms<br/>[utils.py]"]
end

subgraph group_models["GNN models"]
  node_brainnn["BrainNN model<br/>[brainnn.py]"]
  node_gat["Attention GNN<br/>[gat.py]"]
  node_gcn["Convolutional GNN<br/>[gcn.py]"]
  node_mlp["MLP model<br/>[mlp.py]"]
  node_pna["PNA model<br/>[pna.py]"]
  node_losses["Model losses<br/>[losses.py]"]
end

subgraph group_support["Training utilities"]
  node_bin_edges["Edge binning<br/>[bin_edges.py]"]
  node_get_y["Label extraction<br/>[get_y.py]"]
  node_mixup["Mixup augmentation<br/>[mixup.py]"]
end

node_researcher(("Researcher"))
node_input_matrices["Labels and matrices"]
node_experiment["Experiment runner<br/>[example_main.py]"]

node_researcher -->|"prepares"| node_input_matrices
node_researcher -->|"runs"| node_experiment
node_input_matrices -->|"provides inputs"| node_brain_dataset
node_brain_dataset -->|"loads cohort data"| node_cohort_loaders
node_brain_dataset -.->|"applies transform"| node_transforms
node_transforms -->|"transforms graph"| node_brain_data
node_transforms -->|"uses graph helpers"| node_dataset_utils
node_transforms -->|"implements interface"| node_transform_base
node_brain_dataset -->|"constructs graph data"| node_brain_data

click node_experiment "https://github.com/hennyjie/braingb/blob/master/examples/example_main.py"
click node_brain_dataset "https://github.com/hennyjie/braingb/blob/master/src/dataset/brain_dataset.py"
click node_cohort_loaders "https://github.com/hennyjie/braingb/blob/master/src/dataset/abcd/load_abcd.py"
click node_brain_data "https://github.com/hennyjie/braingb/blob/master/src/dataset/brain_data.py"
click node_maskable_list "https://github.com/hennyjie/braingb/blob/master/src/dataset/maskable_list.py"
click node_transforms "https://github.com/hennyjie/braingb/blob/master/src/dataset/transforms.py"
click node_transform_base "https://github.com/hennyjie/braingb/blob/master/src/dataset/base_transform.py"
click node_dataset_utils "https://github.com/hennyjie/braingb/blob/master/src/dataset/utils.py"
click node_brainnn "https://github.com/hennyjie/braingb/blob/master/src/models/brainnn.py"
click node_gat "https://github.com/hennyjie/braingb/blob/master/src/models/gat.py"
click node_gcn "https://github.com/hennyjie/braingb/blob/master/src/models/gcn.py"
click node_mlp "https://github.com/hennyjie/braingb/blob/master/src/models/mlp.py"
click node_pna "https://github.com/hennyjie/braingb/blob/master/src/models/pna.py"
click node_losses "https://github.com/hennyjie/braingb/blob/master/src/models/losses.py"
click node_bin_edges "https://github.com/hennyjie/braingb/blob/master/src/utils/bin_edges.py"
click node_get_y "https://github.com/hennyjie/braingb/blob/master/src/utils/get_y.py"
click node_mixup "https://github.com/hennyjie/braingb/blob/master/src/utils/mixup.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_brain_dataset,node_cohort_loaders,node_brain_data,node_maskable_list toneBlue
class node_transforms,node_transform_base,node_dataset_utils toneAmber
class node_brainnn,node_gat,node_gcn,node_mlp,node_pna,node_losses toneMint
class node_bin_edges,node_get_y,node_mixup toneRose
class node_researcher,node_input_matrices toneIndigo
class node_experiment toneTeal
```

## Components

### Brain data

- [Graph dataset](https://github.com/hennyjie/braingb/blob/master/src/dataset/brain_dataset.py): `src/dataset/brain_dataset.py`
- [Cohort loaders](https://github.com/hennyjie/braingb/blob/master/src/dataset/abcd/load_abcd.py): `src/dataset/abcd/load_abcd.py`
- [Brain graph data](https://github.com/hennyjie/braingb/blob/master/src/dataset/brain_data.py): `src/dataset/brain_data.py`
- [Maskable lists](https://github.com/hennyjie/braingb/blob/master/src/dataset/maskable_list.py): `src/dataset/maskable_list.py`

### Node features

- [Feature transforms](https://github.com/hennyjie/braingb/blob/master/src/dataset/transforms.py): `src/dataset/transforms.py`
- [Transform interface](https://github.com/hennyjie/braingb/blob/master/src/dataset/base_transform.py): `src/dataset/base_transform.py`
- [Graph transforms](https://github.com/hennyjie/braingb/blob/master/src/dataset/utils.py): `src/dataset/utils.py`

### GNN models

- [BrainNN model](https://github.com/hennyjie/braingb/blob/master/src/models/brainnn.py): `src/models/brainnn.py`
- [Attention GNN](https://github.com/hennyjie/braingb/blob/master/src/models/gat.py): `src/models/gat.py`
- [Convolutional GNN](https://github.com/hennyjie/braingb/blob/master/src/models/gcn.py): `src/models/gcn.py`
- [MLP model](https://github.com/hennyjie/braingb/blob/master/src/models/mlp.py): `src/models/mlp.py`
- [PNA model](https://github.com/hennyjie/braingb/blob/master/src/models/pna.py): `src/models/pna.py`
- [Model losses](https://github.com/hennyjie/braingb/blob/master/src/models/losses.py): `src/models/losses.py`

### Training utilities

- [Edge binning](https://github.com/hennyjie/braingb/blob/master/src/utils/bin_edges.py): `src/utils/bin_edges.py`
- [Label extraction](https://github.com/hennyjie/braingb/blob/master/src/utils/get_y.py): `src/utils/get_y.py`
- [Mixup augmentation](https://github.com/hennyjie/braingb/blob/master/src/utils/mixup.py): `src/utils/mixup.py`

### Other components

- **Researcher**
- **Labels and matrices**
- [Experiment runner](https://github.com/hennyjie/braingb/blob/master/examples/example_main.py): `examples/example_main.py`

## Connections

- Researcher → Labels and matrices: prepares (evidence: `README.md`)
- Researcher → Experiment runner: runs (evidence: `README.md`)
- Labels and matrices → Graph dataset: provides inputs (evidence: `README.md`)
- Graph dataset → Cohort loaders: loads cohort data (evidence: `src/dataset/brain_dataset.py`)
- Graph dataset → Feature transforms: applies transform
- Feature transforms → Brain graph data: transforms graph (evidence: `src/dataset/transforms.py`)
- Feature transforms → Graph transforms: uses graph helpers (evidence: `src/dataset/transforms.py`)
- Feature transforms → Transform interface: implements interface (evidence: `src/dataset/transforms.py`)
- Graph dataset → Brain graph data: constructs graph data (evidence: `src/dataset/brain_dataset.py`)
