# xuexiongluomq/brainmm architecture

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

- Interactive diagram: https://gitdiagram.com/xuexiongluomq/brainmm
- Repository: https://github.com/xuexiongluomq/brainmm

## Overview

BrainMM is a multi-modal brain-graph learning and classification framework. Its principal workflow loads a dataset, prepares modality-specific graphs and node features, batches subjects, then trains and evaluates a graph model that combines modality encodings with a shared representation and attention-based classification. The README documents HIV, bipolar-disorder, and PPMI datasets; the tree includes a PPMI data file, while dataset preprocessing is implemented in the shared loader. The graph follows shown calls and imports; it does not infer wiring for unsampled code.

Main entry points: [`main.py`](https://github.com/xuexiongluomq/brainmm/blob/main/main.py) (Model and experiment runner), [`process_data.py`](https://github.com/xuexiongluomq/brainmm/blob/main/process_data.py) (Graph loader), [`models/enc_dec.py`](https://github.com/xuexiongluomq/brainmm/blob/main/models/enc_dec.py) (Modality encoders), [`models/shareLayer.py`](https://github.com/xuexiongluomq/brainmm/blob/main/models/shareLayer.py) (Shared representation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Data preparation"]
  node_dataset[("Brain graph datasets")]
  node_loader["Graph loader<br/>[process_data.py]"]
  node_features["Node features<br/>[feat.py]"]
  node_ppmi_data["PPMI link data<br/>[PPMI_link.txt]"]
end

subgraph group_learning["Graph learning"]
  node_encdec["Modality encoders<br/>[enc_dec.py]"]
  node_gcn["Graph convolution<br/>[gcn.py]"]
  node_shared["Shared representation<br/>[shareLayer.py]"]
  node_attention["Representation attention<br/>[attentionLayer.py]"]
  node_classifier["Subject classifier<br/>[main.py]"]
end

subgraph group_experiment["Training and evaluation"]
  node_config["Experiment settings<br/>[config.py]"]
  node_runner["Model and experiment runner<br/>[main.py]"]
  node_metrics["Evaluation metrics<br/>[main.py]"]
end

node_researcher(("Researcher"))

node_researcher -->|"runs"| node_runner
node_dataset -->|"loads graphs"| node_loader
node_loader -->|"computes features"| node_features
node_runner -->|"loads data"| node_loader
node_runner -->|"reads settings"| node_config
node_runner -->|"invokes encoders"| node_encdec
node_encdec -->|"applies convolution"| node_gcn
node_runner -->|"builds shared features"| node_shared
node_shared -->|"uses decoder utilities"| node_encdec
node_runner -->|"weights representations"| node_attention
node_runner -->|"classifies subjects"| node_classifier
node_runner -->|"evaluates predictions"| node_metrics

click node_loader "https://github.com/xuexiongluomq/brainmm/blob/main/process_data.py"
click node_features "https://github.com/xuexiongluomq/brainmm/blob/main/feat.py"
click node_config "https://github.com/xuexiongluomq/brainmm/blob/main/config.py"
click node_runner "https://github.com/xuexiongluomq/brainmm/blob/main/main.py"
click node_encdec "https://github.com/xuexiongluomq/brainmm/blob/main/models/enc_dec.py"
click node_gcn "https://github.com/xuexiongluomq/brainmm/blob/main/models/gcn.py"
click node_shared "https://github.com/xuexiongluomq/brainmm/blob/main/models/shareLayer.py"
click node_attention "https://github.com/xuexiongluomq/brainmm/blob/main/models/attentionLayer.py"
click node_classifier "https://github.com/xuexiongluomq/brainmm/blob/main/main.py"
click node_metrics "https://github.com/xuexiongluomq/brainmm/blob/main/main.py"
click node_ppmi_data "https://github.com/xuexiongluomq/brainmm/blob/main/data/PPMI/PPMI_link.txt"

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_dataset,node_loader,node_features,node_ppmi_data toneBlue
class node_encdec,node_gcn,node_shared,node_attention,node_classifier toneAmber
class node_config,node_runner,node_metrics toneMint
class node_researcher toneIndigo
```

## Components

### Data preparation

- **Brain graph datasets**
- [Graph loader](https://github.com/xuexiongluomq/brainmm/blob/main/process_data.py): `process_data.py`
- [Node features](https://github.com/xuexiongluomq/brainmm/blob/main/feat.py): `feat.py`
- [PPMI link data](https://github.com/xuexiongluomq/brainmm/blob/main/data/PPMI/PPMI_link.txt): `data/PPMI/PPMI_link.txt`

### Graph learning

- [Modality encoders](https://github.com/xuexiongluomq/brainmm/blob/main/models/enc_dec.py): `models/enc_dec.py`
- [Graph convolution](https://github.com/xuexiongluomq/brainmm/blob/main/models/gcn.py): `models/gcn.py`
- [Shared representation](https://github.com/xuexiongluomq/brainmm/blob/main/models/shareLayer.py): `models/shareLayer.py`
- [Representation attention](https://github.com/xuexiongluomq/brainmm/blob/main/models/attentionLayer.py): `models/attentionLayer.py`
- [Subject classifier](https://github.com/xuexiongluomq/brainmm/blob/main/main.py): `main.py`

### Training and evaluation

- [Experiment settings](https://github.com/xuexiongluomq/brainmm/blob/main/config.py): `config.py`
- [Model and experiment runner](https://github.com/xuexiongluomq/brainmm/blob/main/main.py): `main.py`
- [Evaluation metrics](https://github.com/xuexiongluomq/brainmm/blob/main/main.py): `main.py`

### Other components

- **Researcher**

## Connections

- Researcher → Model and experiment runner: runs (evidence: `README.md`)
- Brain graph datasets → Graph loader: loads graphs (evidence: `README.md`)
- Graph loader → Node features: computes features (evidence: `process_data.py`)
- Model and experiment runner → Graph loader: loads data (evidence: `main.py`)
- Model and experiment runner → Experiment settings: reads settings (evidence: `main.py`)
- Model and experiment runner → Modality encoders: invokes encoders (evidence: `main.py`)
- Modality encoders → Graph convolution: applies convolution (evidence: `models/enc_dec.py`)
- Model and experiment runner → Shared representation: builds shared features (evidence: `main.py`)
- Shared representation → Modality encoders: uses decoder utilities (evidence: `models/shareLayer.py`)
- Model and experiment runner → Representation attention: weights representations (evidence: `main.py`)
- Model and experiment runner → Subject classifier: classifies subjects (evidence: `main.py`)
- Model and experiment runner → Evaluation metrics: evaluates predictions (evidence: `main.py`)
