scalesurfer-surface
Cortical surface reconstruction from T1-weighted MRI. Given a scan, the model writes each
hemisphere's white and pial surfaces in FreeSurfer format: 163,842 vertices per surface with
fsaverage7 (ico-7) topology, aligned with the conformed orig.mgz. It also writes vertex-wise
thickness and the Desikan-Killiany parcellation. On an RTX 5090 it takes about 2.6 s per scan
end to end.
This is release 1.1 of the MeshNet surface model in
ScaleSurfer. It has the same network and
training recipe as release 1.0, retrained on a larger, quality-controlled training set (see
Changes from 1.0). Release 1.0 stays available as the git tag
v1.0 of this repository.
Use
pip install -e ".[surface]" # from a clone of github.com/voytekresearch/scalesurfer
python scripts/predict_surfaces.py sub-01_T1w.nii.gz --out results/
from scalesurfer import ScaleSurfer
surfer = ScaleSurfer(["sub-01_T1w.nii.gz"], ["sub-01"], "results/", fs_version=8)
surfer.prepare_images() # conform to 1 mm 256^3
surfer.predict_volumes() # aparc+aseg from rphammonds/scalesurfer-v8 (the surface model's input)
surfer.predict_surfaces() # downloads this model on first use
Outputs per subject: surf/{lh,rh}.{white,pial,thickness,area,curv},
label/{lh,rh}.aparc.annot, label/{lh,rh}.cortex.label, and a provenance file
scalesurfer_surfaces.json.
Model
-
Input: the conformed T1 plus the 7-channel segmentation from the FreeSurfer 8 volume model
rphammonds/scalesurfer-v8. The surface model was trained on that model's segmentations, so use it rather than another segmentation. -
Architecture: MeshNet, 4.59 M parameters.
- A smoothed fsaverage template is placed from the segmentation's label centroids.
- A 3-D CNN encoder and a graph network on the mesh deform it coarse to fine, from ico-1 to ico-7.
- Two column refiners search along each vertex normal (±2 mm, then ±1 mm) for the white and pial boundaries.
-
Files:
meshnet.safetensorsholds the weights.config.jsonholds theMeshNetConfigand provenance. The fsaverage template ships with the code. -
Training: one pre-registered run of three stages (94,000 steps in total).
- Pretrain the base network.
- Train the column refiners with the base frozen.
- Fine-tune everything.
Every seed, setting and checkpoint was fixed before the run. The last checkpoint is the model; nothing was chosen on validation or test. Source checkpoint
meshnet_last.pt, sha25674030b5cd1227ad0…. -
Training data: 17,269 scans from 580 source datasets (754 FreeSurfer-version × site groups), referenced to their own FreeSurfer outputs (FreeSurfer 5.x: 1,578; 6: 7,336; 7.x: 7,976; 8.2: 379). Each FreeSurfer version gets an equal share of training draws; within a version, a site's share grows with the square root of its size. Sources are OpenNeuro, ABIDE I/II, HCP, CoRR, ADHD-200, HBN and Reproducible Brain Charts (BHRC, PNC).
Results (held-out test set)
There are 804 scans from 67 institutions, and none of these subjects was used in training. Each method is scored against the scan's own FreeSurfer surfaces. ASSD is the average symmetric surface distance, in mm; lower is better.
| method | ASSD median | ASSD mean | thickness MAE | HD95 | self-intersecting faces (%) |
|---|---|---|---|---|---|
| scalesurfer-surface 1.1 | 0.153 | 0.171 | 0.243 | 0.61 | 0.002 |
| DeepSurfer (reference brainmask) | 0.179 | 0.191 | 0.244 | 0.59 | 0.014 |
| DeepSurfer (raw T1) | 0.183 | 0.204 | 0.253 | 0.68 | 0.013 |
| BrainNet | 0.259 | 0.279 | 0.299 | 1.00 | 0.026 |
The pre-registered criterion was lower ASSD than both DeepSurfer arms and BrainNet in every FreeSurfer version (5, 6, 7, 8) and pooled. Each comparison uses the median paired difference, with a 95 % CI bootstrapped over institutions that must lie below 0. Release 1.1 met all 15 comparisons (also 15 of 15 without the 25 test scans flagged for reference problems).
| 1.1 minus baseline, median paired ASSD (mm) | DeepSurfer (brainmask) | DeepSurfer (raw T1) | BrainNet |
|---|---|---|---|
| FreeSurfer 5 (155 scans) | −0.024 | −0.032 | −0.089 |
| FreeSurfer 6 (372) | −0.023 | −0.027 | −0.107 |
| FreeSurfer 7 (229) | −0.026 | −0.031 | −0.101 |
| FreeSurfer 8 (48) | −0.011 | −0.022 | −0.081 |
| pooled (804) | −0.023 | −0.028 | −0.101 |
Speed: median 2.59 s per scan end to end on an RTX 5090: 0.57 s to conform, 0.46 s for segmentation and 1.53 s for the surfaces (48 test scans, median of three timing passes; single passes vary by about ±0.1 s). Release 1.0 measured 2.60 s in the same repeated timing.
Changes from 1.0
Same network, losses, schedule, split and evaluation. What changed:
- Training data audited and enlarged from 9,139 to 17,269 scans. Removed: references that miss more than 5 mL of cortex, same-version duplicate images, 5 training images that match a held-out image, and a few other failures (1,032 scans in all). Fixed: in 103 FreeSurfer 8 training pairs the input image sat half a voxel off its reference surfaces; those inputs were rebuilt from the raw OpenNeuro T1w with FreeSurfer 8.2's own conform step. Added: more OpenNeuro, INDI and Reproducible Brain Charts subjects.
- Training distance computed exactly (the old search overestimated pial distances by about 0.013 mm during training).
On the same 804 test scans (1.1 minus 1.0, median paired difference, 95 % CI over institutions): ASSD −0.0006 mm (CI −0.0011 to +0.00004, a tie), thickness MAE −0.0034 mm (better), with no FreeSurfer version worse on ASSD and thickness better on FreeSurfer 6, 7 and 8. The two releases are equally accurate on surface position; 1.1 is slightly better on thickness and is trained on cleaner data.
Limits
- Thickness: pooled thickness error ties DeepSurfer (brainmask). It is higher on FreeSurfer 8 (+0.011 mm) and per region (0.111 vs 0.100 mm). Check thickness-based findings against FreeSurfer.
- FreeSurfer 8: ASSD is 0.018 mm higher than the earlier ScaleSurfer M3 model, which 1.1 beats pooled and on FreeSurfer 5, 6 and 7.
- Scan types: trained on research-quality T1 of children and adults. It is untested on clinical scans, other contrasts, large lesions and infants.
- Determinism: GPU runs are not bit-for-bit deterministic. Repeated runs differ by about 0.003 mm per vertex on average.
Intended use and license
For non-commercial academic research. Several training datasets (for example HCP, ABIDE, HBN and Reproducible Brain Charts) have data-use terms that restrict commercial use. The fsaverage template is derived from FreeSurfer's and is distributed under the FreeSurfer license. This is not a medical device and is not for clinical decisions.