DMC-BrainMap Registration Predictor

A convolutional model that proposes an initial projective alignment between a mouse histological section and its corresponding Allen Mouse Brain Atlas reference slice. The model is designed for the prediction-assisted registration workflow in DMC-BrainMap.

Versions

Version File Architecture Parameters DMC-BrainMap support SHA-256
v2.0.0 (recommended) dmc-brainmap-registration-predictor-v2.0.0.pt Residual feature pyramid 13,976,840 0.2.1 and later 89b5e9b0a3aa407155ed4c789b6840d26e2ebfbfe931c32de3a8ae8352823ab3
v1.0.0 dmc-brainmap-registration-predictor-v1.0.0.pt PairSpatialHomographyNet 2,336,200 0.1.8 and later f24893d0a5d335ccfee2c354245cfefef935424f0d7c8010e9efbc0560496d18

On the same held-out test sections, v2.0.0 reduced the mean point error from 20.3 to 15.9 pixels and improved every test animal (see Evaluation).

v2.0.0 requires DMC-BrainMap 0.2.1 or later. Earlier releases can load only v1.0.0 and report that a v2.0.0 file is not a supported model.

Both checkpoints are inference-only files containing model_config and model_state_dict and support safe loading with torch.load(..., weights_only=True). The v2.0.0 file also records training provenance and aggregate validation metrics.

Model details

Property v2.0.0 v1.0.0
Model type Pairwise 2D projective-registration regressor Pairwise 2D projective-registration regressor
Architecture Residual feature pyramid with paired feature fusion PairSpatialHomographyNet
Parameters 13,976,840 2,336,200
File size 56 MB 9 MB
CPU time per prediction About 0.6-1 s About 0.03 s
Framework PyTorch PyTorch
Supported atlas Allen Mouse Brain Atlas 10 um, BrainGlobe version 1.2 Same
Validated input size 1140 x 800 pixels (width x height) Same
Developed by Xiao Cao Xiao Cao
License BSD-3-Clause BSD-3-Clause

CPU times are for one 1140 x 800 section on a desktop processor (Intel Core i9-11900KF, two to eight threads), excluding the one-time model loading. Slower computers take longer.

Training and model code are maintained in xiao-1011/sharpy-model. v2.0.0 was trained at source commit 23e370b in run v3-pyramid-A-seed43. v1.0.0 is tied to source commit 0a80f4f and training run baseline-005-spatial-augmented-200ep.

Intended use

The model provides an initial registration suggestion inside DMC-BrainMap:

  1. the user selects the appropriate atlas slice;
  2. the model predicts a sample-to-atlas projective transformation;
  3. DMC-BrainMap displays a preview of the alignment; and
  4. the user reviews, accepts, or corrects the suggested registration points.

The prediction is an initialization aid, not a final registration or a replacement for visual quality control. It is not intended for clinical diagnosis, treatment decisions, or unattended quantitative analysis.

Model interface

Both versions share the same interface.

Inputs

Name Meaning Shape Type and range
sample Green-channel epifluorescence image of a histological section [batch, 1, 800, 1140] float32, [0, 1]
reference Corresponding grayscale atlas reference slice [batch, 1, 800, 1140] float32, [0, 1]

DMC-BrainMap converts image arrays to grayscale when required, divides pixel values by 255, and converts them to channels-first tensors. Although the networks use adaptive pooling, only 1140 x 800 pixel inputs have been trained and evaluated.

v2.0.0 treats the bounding rectangle of nonzero pixels in each image as the tissue or atlas region and masks the zero padding outside it. Dark pixels inside that rectangle are retained.

Output

The model returns [batch, 4, 2] sample-to-reference corner offsets in pixels. The corner order is:

  1. top left;
  2. top right;
  3. bottom right; and
  4. bottom left.

Offsets are bounded to +/-512 pixels with tanh. DMC-BrainMap converts the four displaced corners into a 3 x 3 projective homography and then into five editable registration-point pairs.

Architecture

v2.0.0

  • Separate input stems. The sample and the reference each pass through their own 7 x 7 stride-2 convolution (64 channels), group normalization, ReLU, and 3 x 3 stride-2 max pooling.

  • Shared residual feature pyramid. Both images then share a ResNet-18-style residual body with group normalization (64, 128, 256, and 512 channels). A feature-pyramid network produces 128-channel descriptors at 1/8, 1/16, and 1/32 of the input resolution.

  • Paired fusion at each pyramid level. The fusion input combines the sample and reference descriptors, their difference and product, normalized pixel coordinates, and both padding masks. Two convolution blocks reduce it to 64 channels. The 1/32 level has eight additional input channels reserved for correspondence features; they are zero in this release.

  • Regression head. Each level is adaptively pooled to 5 x 8. The three pooled maps are concatenated and passed through:

    7680 -> 256 -> 256 -> 8
    

    The eight outputs are reshaped into four (x, y) corner offsets.

v1.0.0

The sample and reference tensors are concatenated into a two-channel input. Five convolution blocks each use a 3 x 3 stride-2 convolution, batch normalization, and ReLU:

2 -> 24 -> 48 -> 96 -> 96 -> 192 channels

The resulting feature map is adaptively pooled to 5 x 8, flattened, and passed through the regression head:

7680 -> 256 -> 256 -> 8

The eight outputs are reshaped into four (x, y) corner offsets. Exact machine-readable v1.0.0 settings are provided in config.json. For v2.0.0, the same settings are stored in the checkpoint's model_config.

Training data

v1.0.0

The dataset contains 5,613 registered sections from 87 adult C57BL/6J mice of both sexes. Sections were imaged using epifluorescence microscopy in the green channel (EGFP spectral range). Reference slices were generated from the Allen Mouse Brain Atlas 10 um, BrainGlobe version 1.2.

Target registrations were created with SHARPy-track inside DMC-BrainMap and reviewed by Felix Jung, Xiao Cao, and Loran Heymans. Mean target registration error below 4 pixels (approximately 40 um at the atlas resolution) was considered acceptable. Projective fits with landmark-fit RMSE above 60 pixels were excluded, removing 296 candidate sections.

The split was performed by animal, so no animal appears in more than one split:

Split Animals Sections
Training 61 4,015
Validation 13 745
Test 13 853

The split used seed 42 with nominal 70%/15%/15% folder-level allocation.

v2.0.0

v2.0.0 was trained on the v1.0.0 data plus an additional data set, model-data-v2, of 1,166 registered sections from 32 mice, which adds a greater variety of sections. Reference slices use the same atlas and version.

The original training, validation, and test animals were kept in their v1.0.0 splits. The model-data-v2 animals were assigned whole to one split, so no animal appears in more than one split, and no animal appears in both data sets. Two model-data-v2 animals were excluded entirely because all of their sections were rejected during review.

Sections whose target transform moves an image corner by more than the model's +/-512 pixel output range were excluded from training and evaluation, removing 14 original sections (5 of them from the test split).

Split Animals Sections
Training 83 (61 original, 22 model-data-v2) 4,816
Validation 18 (13 original, 5 model-data-v2) 922
Test 18 (13 original, 5 model-data-v2) 1,027

Data availability

The training images are owned by the DMC-BrainMap group but are unpublished and are not distributed with this model. Users can adapt the public training code to fine-tune the model with their own appropriately licensed paired images and registrations.

Training procedure

Settings shared by both versions:

  • Maximum epochs: 200, with early stopping (patience 20, minimum improvement 0.03).
  • Checkpoint selection: lowest validation composite loss.
  • Batch size: 4.
  • Optimizer: AdamW, learning rate 1e-4, weight decay 1e-4.
  • Scheduler: ReduceLROnPlateau, factor 0.5, patience 6, minimum learning rate 5e-7.
  • Hardware: NVIDIA GeForce RTX 3070 Ti.

The primary objective is Smooth L1 reprojection loss over an 8 x 8 grid sampled within the non-black tissue bounding box, inset by 2%. A second Smooth L1 loss on the four projected image corners is included with weight 0.25.

Training-only moderate damage augmentation simulates missing tissue, tears, cracks, folds, exposure changes, brightness and contrast variation, gamma variation, and image noise.

Setting v2.0.0 v1.0.0
Early stopping After epoch 59 After epoch 111
Selected checkpoint Epoch 39 Epoch 91
Seed 43 42
Network precision BF16 mixed precision; FP32 output scaling and geometry FP32
Software Python 3.14, PyTorch 2.12.0 with CUDA 13.0 Python 3.14, PyTorch 2.12.0 with CUDA 13.0

v2.0.0 is the best of three otherwise identical training runs (seeds 42, 43, and 44), chosen by validation mean reprojection error. Its validation mean reprojection error was 15.49 pixels. Across the three seeds, validation error was 15.71 +/- 0.23 pixels, compared with 18.73 +/- 0.13 pixels for three retrained runs of the v1.0.0 architecture on the same data, and every validation animal improved in every seed. Inference in FP32 on the CPU, as in DMC-BrainMap, matched BF16 validation error to within 0.002 pixels.

For v1.0.0, the training-curve figure annotates the lowest validation mean reprojection error, reached at epoch 111. The released checkpoint is epoch 91 because validation composite loss, rather than mean reprojection error, was the configured selection metric. The full v1.0.0 settings are recorded in training/training_config.json.

Evaluation

Errors compare the predicted projective transform with the quality-controlled target transform on an 8 x 8 grid inside the non-black tissue bounding box.

Test results

Both versions were evaluated once, with the same code and FP32 precision, on the v2.0.0 held-out test split: 1,027 sections from 18 animals. Neither model was trained or selected on these animals.

Test metric v1.0.0 v2.0.0
Mean point error 20.318 px (203 um) 15.943 px (159 um)
Median point error 15.391 px (154 um) 11.748 px (117 um)
95th percentile point error 52.757 px (528 um) 42.581 px (426 um)
Maximum point error 304.309 px (3.04 mm) 309.549 px (3.10 mm)
Mean corner error per image 40.810 px 33.449 px
Sections with mean error above 50 px 32 16

v2.0.0 had a lower mean error for all 18 test animals (by 1.3-12.7 pixels) and for 775 of the 1,027 test sections.

The test split includes 5 animals from model-data-v2. v1.0.0 was not trained on any model-data-v2 animals, so part of the v2.0.0 improvement reflects its additional training data as well as its architecture. The controlled three-seed validation comparison under Training procedure uses the same training data for both architectures.

Original v1.0.0 test result

The v1.0.0 release was evaluated on its own test split of 853 sections from the same 13 original test animals:

Test metric Pixels Approximate atlas distance
Mean point error 18.964 189.6 um
Median point error 14.211 142.1 um
95th percentile point error 49.035 490.3 um
Maximum point error 552.370 5.52 mm
Mean corner error per image 37.983 379.8 um

The 848 sections shared with the v2.0.0 test split reproduce these per-section errors to within 0.001 pixels. The 5 sections excluded for exceeding the output range were among the hardest for v1.0.0, with mean errors of 52-133 pixels each. See evaluation/test_summary.json for the full v1.0.0 aggregate results.

Pixel-to-distance values use the 10 um atlas resolution and are provided only as scale approximations.

Limitations

  • The original data come from adult C57BL/6J mouse sections imaged in the green/EGFP-range epifluorescence channel; model-data-v2 adds a greater variety of sections.
  • Only Allen Mouse Brain Atlas 10 um version 1.2 reference slices are supported.
  • The training and test images originate from the same overall data-creation workflow, although animals are separated across splits.
  • Performance may degrade for other strains, developmental stages, staining protocols, microscopes, channels, atlases, image sizes, or tissue preparation methods.
  • Damaged or incomplete sections, unusual contrast, acquisition artifacts, or selection of the wrong atlas slice may produce poor predictions.
  • The large maximum test errors show that individual predictions can fail substantially with either version. Every prediction must be reviewed before use.
  • Sections whose correct transform moves an image corner by more than 512 pixels cannot be represented by either version and were excluded from evaluation.
  • Evaluation measures agreement with fitted, manually reviewed target registrations; it is not an independent biological ground truth.

The models' approximately 16- to 20-pixel mean test errors should not be confused with the less-than-4-pixel mean TRE acceptance criterion applied to the manually reviewed target registrations. The model output is intended to initialize the subsequent reviewed registration.

Using the model with DMC-BrainMap

To use a released checkpoint:

  1. Download dmc-brainmap-registration-predictor-v2.0.0.pt from Files and versions. With DMC-BrainMap releases before 0.2.1, download dmc-brainmap-registration-predictor-v1.0.0.pt instead.
  2. Start DMC-BrainMap in napari.
  3. Open the registration widget and select Browse Model.
  4. Select the downloaded checkpoint and start the registration GUI.
  5. Use Predict to preview the alignment.
  6. Inspect and, when needed, correct the suggested registration points before saving.

The versioned artifacts can also be downloaded programmatically:

from huggingface_hub import hf_hub_download

checkpoint_path = hf_hub_download(
    repo_id="xiao-1011/dmc-brainmap-registration-predictor",
    filename="dmc-brainmap-registration-predictor-v2.0.0.pt",
    revision="v2.0.0",
)

For v1.0.0, use filename="dmc-brainmap-registration-predictor-v1.0.0.pt" and revision="v1.0.0".

Reproducibility files

These files describe v1.0.0. No additional files are distributed for v2.0.0; its settings and provenance are stored in the checkpoint.

Per-image metrics, manifests, and unpublished images are intentionally not distributed.

License

The model repository and released weights are licensed under the BSD 3-Clause License. This license does not grant rights to the unpublished training images or modify the terms of the Allen Mouse Brain Atlas and other third-party resources.

Copyright (c) 2026, DMC-BrainMap developers.

Citation

If this model or DMC-BrainMap contributes to scientific work, please cite:

Jung, F., Cao, X., Heymans, L., & Carlén, M. (2026). DMC-BrainMap is an open-source, end-to-end tool for multi-feature brain mapping in different species. Cell Reports Methods, 6(2), 101302. https://doi.org/10.1016/j.crmeth.2026.101302

Acknowledgment

Developed by Xiao Cao with assistance from OpenAI GPT-5.5 (v1.0.0) and Anthropic Claude Opus 5.5 (v2.0.0).

Links

Downloads last month
19
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support