Uzair Shah commited on
Commit
13c53b1
Β·
1 Parent(s): cf84204

Add files via upload

Browse files
Files changed (1) hide show
  1. README.md +150 -0
README.md ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GraPHFormer: A Multimodal Graph Persistent Homology Transformer for the Analysis of Neuroscience Morphologies
2
+
3
+ **CVPR 2026 (Main Track)**
4
+
5
+ Uzair Shah, Marco Agus, Mahmoud Gamal, Mahmood Alzubaidi, Corrado Cali, Pierre J. Magistretti, Abdesselam Bouzerdoum, Mowafa Househ
6
+
7
+ [[Paper]](https://arxiv.org/abs/2603.20970)
8
+
9
+ ---
10
+
11
+ ## Overview
12
+
13
+ GraPHFormer is a multimodal self-supervised framework for neuronal morphology analysis that jointly models **topological** and **structural** information from neuron reconstructions. It combines:
14
+
15
+ - **Vision branch**: A three-channel persistence image (unweighted, persistence-weighted, and radius-weighted topological densities) processed by a frozen DINOv2-ViT-S backbone.
16
+ - **Graph branch**: A TreeLSTM encoder that captures geometric and radial attributes from the morphological skeleton graph.
17
+
18
+ The two branches are aligned in a shared embedding space using CLIP-style contrastive learning with a symmetric InfoNCE loss. Persistence-space augmentations are used during training to maintain topological meaning across views.
19
+
20
+ GraPHFormer achieves state-of-the-art performance on five of six neuronal morphology benchmarks spanning both self-supervised and supervised settings.
21
+
22
+ ## Repository Structure
23
+
24
+ ```
25
+ GraPHFormer/
26
+ β”œβ”€β”€ train.py # Self-supervised pretraining
27
+ β”œβ”€β”€ finetune.py # Supervised fine-tuning
28
+ β”œβ”€β”€ setup.py
29
+ β”œβ”€β”€ scripts/
30
+ β”‚ └── prepare_data.py # Data preprocessing pipeline
31
+ └── graphformer/
32
+ β”œβ”€β”€ models/
33
+ β”‚ β”œβ”€β”€ clip_model.py # CLIP-style dual-branch model
34
+ β”‚ β”œβ”€β”€ image_encoder.py # DINOv2 / ResNet image encoders
35
+ β”‚ β”œβ”€β”€ tree_encoder.py # TreeLSTM graph encoder
36
+ β”‚ β”œβ”€β”€ fusion.py # Multimodal fusion heads
37
+ β”‚ └── finetune_model.py # Fine-tuning wrapper
38
+ β”œβ”€β”€ data/
39
+ β”‚ β”œβ”€β”€ dataset.py # NeuronTreeDataset
40
+ β”‚ └── persistence_image.py # Persistence image computation
41
+ β”œβ”€β”€ losses/
42
+ β”‚ β”œβ”€β”€ infonce.py
43
+ β”‚ └── contrastive.py
44
+ └── augmentations/
45
+ β”œβ”€β”€ tree_augmentations.py # Graph-space augmentations
46
+ └── persistence_augmentations.py # Topology-preserving image augmentations
47
+ ```
48
+
49
+ ## Installation
50
+
51
+ ```bash
52
+ pip install -e .
53
+ ```
54
+
55
+ **Dependencies**: Python >= 3.8, PyTorch >= 1.10, torchvision >= 0.11, DGL >= 0.8, scikit-learn, networkx, nltk, Pillow, tqdm, numpy.
56
+
57
+ ## Data Preparation
58
+
59
+ Dataset downloading and preprocessing follow the [TreeMoCo](https://proceedings.neurips.cc/paper_files/paper/2022/hash/9f989633ffbd47a83caddacad0f0261f-Abstract-Conference.html) paper (NeurIPS 2022). Please refer to the [TreeMoCo GitHub repository](https://github.com/TencentAILabHealthcare/NeuronRepresentation) for instructions on downloading the three datasets: BIL (Brain Image Library), ACT (Allen Cell Types), and JML (Janelia MouseLight).
60
+
61
+ Once the raw SWC files are in place, run the preprocessing script:
62
+
63
+ ```bash
64
+ python scripts/prepare_data.py
65
+ ```
66
+
67
+ This normalizes soma position/orientation/scale, removes axon compartments, computes branch-level features, and creates 10-fold cross-validation splits.
68
+
69
+ ## Training
70
+
71
+ ### Self-Supervised Pretraining
72
+
73
+ ```bash
74
+ python train.py \
75
+ --exp_name my_experiment \
76
+ --dataset all_wo_others \
77
+ --image_encoder dinov2_vits14 \
78
+ --tree_model double \
79
+ --embed_dim 128 \
80
+ --batch_size 128 \
81
+ --epochs 100 \
82
+ --lr 3e-4 \
83
+ --use_knn_eval \
84
+ --eval_jm --eval_act
85
+ ```
86
+
87
+ Key options:
88
+
89
+ | Argument | Default | Description |
90
+ |---|---|---|
91
+ | `--image_encoder` | `resnet18` | `dinov2_vits14`, `resnet18`, `resnet50`, `persistencevit` |
92
+ | `--tree_model` | `double` | TreeLSTM variant: `ori`, `v2`, `double` |
93
+ | `--embed_dim` | `128` | Shared embedding dimension |
94
+ | `--loss_type` | `clip` | `clip`, `infonce`, `ntxent`, `triplet` |
95
+ | `--use_persistence_aug` | off | Enable persistence-space augmentations |
96
+ | `--knn_fusion` | `concat` | How to combine modalities for KNN eval |
97
+
98
+ Tree augmentations: `--aug_rotate`, `--aug_flip`, `--aug_jitter_coords`, `--aug_drop_tree`, `--aug_skip_parent_node`, `--aug_swap_sibling_subtrees`
99
+
100
+ ### Fine-Tuning
101
+
102
+ ```bash
103
+ python finetune.py \
104
+ --exp_name my_finetune \
105
+ --pretrained_checkpoint work_dir/my_experiment/best_BIL.pth \
106
+ --dataset bil_6_classes \
107
+ --mode multimodal \
108
+ --fusion_mode concat \
109
+ --epochs 50 \
110
+ --lr 1e-4
111
+ ```
112
+
113
+ Fine-tuning modes: `multimodal`, `image_only`, `tree_only`. Fusion modes: `concat`, `add`, `cross_attention`, `gated`, `cmf`, `mhcma`.
114
+
115
+ Two-stage training (linear probe then full fine-tune):
116
+
117
+ ```bash
118
+ python finetune.py \
119
+ --exp_name my_finetune \
120
+ --pretrained_checkpoint work_dir/my_experiment/best_BIL.pth \
121
+ --dataset bil_6_classes \
122
+ --linear_probe_epochs 10 \
123
+ --epochs 50
124
+ ```
125
+
126
+ ## Benchmarks
127
+
128
+ Evaluated on six datasets:
129
+
130
+ | Dataset | Task | Classes |
131
+ |---|---|---|
132
+ | BIL-6 | Brain region classification | 6 |
133
+ | ACT-4 | Cortical layer classification | 4 |
134
+ | JML-4 | Brain region classification | 4 |
135
+ | N7 | Neuron type classification | 7 |
136
+ | M1-Cell | Cell type classification | β€” |
137
+ | M1-REG | Cortical region classification | β€” |
138
+
139
+ GraPHFormer achieves state-of-the-art on 5/6 benchmarks, outperforming topology-only, graph-only, and morphometrics baselines.
140
+
141
+ ## Citation
142
+
143
+ ```bibtex
144
+ @inproceedings{shah2026graphformer,
145
+ title = {GraPHFormer: A Multimodal Graph Persistent Homology Transformer for the Analysis of Neuroscience Morphologies},
146
+ author = {Shah, Uzair and Agus, Marco and Gamal, Mahmoud and Alzubaidi, Mahmood and Cali, Corrado and Magistretti, Pierre J. and Bouzerdoum, Abdesselam and Househ, Mowafa},
147
+ booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR) (Main Track)},
148
+ year = {2026}
149
+ }
150
+ ```