When a medical segmentation network meets images from a new scanner, it often fails silently. It draws a confident but wrong organ contour, and the usual confidence signal (the softmax probability) stays high. This proposal tests a simple hypothesis about where those errors live. They come in two kinds. The first kind is jitter within a few millimetres of the predicted contour. The second kind is a region that is wrong through and through, where the network's internal features have drifted away from anything it saw in training.
A voxel's physical distance to the predicted contour catches the first kind. A voxel's distance to learned class "prototypes" (representative feature vectors of each organ) catches the second. The distance to the classifier's decision hyperplane cannot catch the second kind, because that margin grows without limit for drifted features. We propose a post-hoc error model for frozen segmenters. It combines physical boundary distance with a prototype-based feature margin, is fitted once on source-scanner data, and is tested on whether it still predicts errors on unseen scanners and sequences.
Core Claim
Existing geometric uncertainty methods each use one distance. Hyperplane and logit margins (Selective Classification Under Distribution Shifts) beat softmax for deciding when an image classifier should abstain under corruption shift. Signed distances to the ground-truth surface (Calibrating on Medical Segmentation Model through Signed Distance) fix boundary overconfidence during training, but only on in-domain splits. Geometric separation from nearby training points cuts calibration error sharply in 2D classification (A geometric method for improved uncertainty estimation in real-time), at the cost of caching the training set.
Our claim has two parts. First, under medical domain shift the share of error voxels far from the predicted contour grows, so any purely boundary-local score loses those errors. Second, a bounded prototype margin flags exactly those far errors, because it shrinks toward zero when a feature is far from every class. Hyperplane margins do the opposite.
The error model is estimated as a monotone function of two quantities, fitted on source calibration data only. The first is $s(v)$, the physical signed distance in millimetres of voxel $v$ to the predicted organ boundary. The second is the relative prototype margin
$$ \rho(v) = \frac{d_{\text{other}}(v) - d_{\text{pred}}(v)}{d_{\text{other}}(v) + d_{\text{pred}}(v)}, $$
where $d_{\text{pred}}(v)$ is the feature-space distance from $v$'s decoder embedding to the nearest prototype of its predicted class, and $d_{\text{other}}(v)$ is the distance to the nearest prototype of any other class. The margin $\rho$ lies in $[-1,1]$. It approaches 0 both near a class boundary and when both distances are large, which is the drifted-feature case. We also keep $d_{\text{pred}}$ itself as a third input, so the model can tell these two cases apart.
What would be new is threefold. The work combines physical and feature-space geometry for dense segmentation. It characterises where errors move under real scanner shift. And it tests whether a source-fitted geometric error map transfers across scanners without target labels, which is the open threshold problem named by the selective-classification paper.
Research Program
The base models are frozen segmenters: a 3D U-Net, nnU-Net, and, for comparison, a model trained with the signed-distance calibration loss. Keeping the weights frozen follows the regulatory argument in Adapt the Data, Not the Model: validated weights should not be touched.
Prototypes are built from penultimate decoder features on a sample of source training voxels. We run k-means per class with $K$ centroids per organ (default $K=8$). This replaces the full feature cache that makes nearest-neighbour separation expensive (A geometric method for improved uncertainty estimation in real-time). It also reuses the prototype idea that Prototype Learning for Out-of-Distribution Polyp Segmentation uses only to improve accuracy, and that Margin Preserving Self-Paced Contrastive Learning uses only as a training loss for adaptation with target data. We use prototypes solely as a test-time uncertainty measurement and need no target data.
The error model maps $(s, \rho, d_{\text{pred}})$ to an error probability. It is fitted by monotone (isotonic-style) regression on a held-out source split, which gives calibrated voxel error probabilities. Aggregating these probabilities over each organ gives an expected-Dice-loss score, which drives organ-level deferral to a radiologist.
The analysis half of the program matters as much as the method. For every shift we plot error rate against physical distance to the predicted contour and against $\rho$, both in-domain and shifted. The purpose is to verify, rather than assume, that errors migrate away from boundaries.
The shifts come from the file's benchmarks. We train on AMOS CT and test on held-out CT scanners and on MRI, where AMOS reports a drop of more than 20% mDice on unseen MRI scanners. We also run the cardiac bSSFP-to-LGE sequence shift and the TorchIO artifact corruptions used by Improved post-hoc probability calibration for out-of-domain MRI segmentation. Finally, we use the VS-Seg to CrossMoDA scanner shift from Limitations of Out-of-Distribution Detection in 3D Medical Image Segmentation.
We report the following metrics:
- Calibration: voxel ECE and the pixel-wise ECE with false-positive penalty from the signed-distance paper.
- Voxel selective prediction: area under the risk-coverage curve.
- Organ-level deferral: AUROC for detecting organs with Dice below 0.8.
- Error-escape rate: the fraction of wrong voxels left unflagged at a fixed budget of flagged voxels. This is the clinically relevant quantity.
Baselines
The naive reference point is per-voxel maximum softmax probability and entropy from the frozen model. Improving Uncertainty-based Out-of-Distribution Detection for Medical Image Segmentation shows how badly this can fail: maximum softmax gave AUROC 0.15 on spike artifacts and 0.31 on T1-Gd sequence mismatch for binary lesion models. Any method must clear this floor on every shift.
The strongest existing post-hoc calibrator for out-of-domain segmentation in the file is the shape-prior plus augmentation-instability temperature map of Improved post-hoc probability calibration for out-of-domain MRI segmentation. It reports ECE 15.37% against 16.78% for local temperature scaling on bSSFP-to-LGE, and 12.78% against 14.48% on corrupted images. We re-run it and local temperature scaling on the same frozen cardiac models and the same calibration split. On the cardiac benchmark, beating it means voxel ECE below 15.37% on LGE, and the comparison stays fair only if we reproduce its reported number first. On AMOS we expect its cardiac-specific shape autoencoder to struggle with pancreas and adrenal glands, as its authors anticipate. We will retrain the autoencoder on AMOS label maps rather than conceding the point.
The strongest geometric competitor is the dense logit margin and hyperplane margin of Selective Classification Under Distribution Shifts, applied per voxel. It needs no fitting, and it is the idea our claim most directly disputes. For this baseline, no reported result was found on Lacuna for dense 3D segmentation.
We also compare against a voxel feature Mahalanobis score, as studied for medical OOD in On the use of Mahalanobis distance for out-of-distribution detection, and a five-member deep ensemble. For the ensemble, Limitations of Out-of-Distribution Detection in 3D Medical Image Segmentation reports that deep OOD methods average FPR 0.59 at 95% TPR. Finally, we compare against a model trained with the signed-distance calibration loss, which reports in-domain ACDC foreground ECE 0.039 against 0.137 for DiceCE. We ask whether that advantage survives shift, and whether our post-hoc model still adds to it.
All post-hoc methods share the same frozen weights, the same source calibration split, and the same hyperparameter search budget, with no target labels. The ensemble gets five times the training compute, and we state that openly.
Three ablations isolate the key ingredients. The physical band alone flags voxels by $|s|$ only. The feature margin alone drops $s$. A variant replaces prototypes with the hyperplane margin while keeping $s$. If the full model does not beat the hyperplane-margin variant on error-escape rate under shift, the prototype ingredient is not earning its place.
Why not just…?
Why not just use temperature scaling or local temperature scaling? These methods rescale logits globally or per patch. Under shift, the confident wrong regions have large logits, so rescaling keeps their ranking unchanged. The Ouyang comparison shows local temperature scaling still at 16.78% ECE on LGE. Our error-escape metric tests this directly. If temperature-scaled entropy flags the far-from-boundary errors as well as $\rho$ does, the claim fails.
Why not just flag a band of a few millimetres around every predicted contour? This is the real threat. In-domain it is probably nearly as good as anything, because boundary voxels are the main failure locus, as the signed-distance paper argues. The first decisive analysis measures whether the share of error voxels beyond the band grows under AMOS MRI and LGE shift. If it does not, we report the band as sufficient and the proposal collapses into that negative finding, which is still useful for deployment.
Why not just use per-voxel logit or hyperplane margins? These are what worked for classification under shift. But for a linear final layer, the hyperplane margin of a feature pushed far from the data grows with the distance pushed, so drifted voxels look very safe. Our bounded prototype margin is built to behave the opposite way. The hyperplane-margin-plus-$s$ ablation settles this empirically. We will also report the correlation between hyperplane margin and error on far-from-boundary voxels specifically.
Why not just use deep ensembles or a whole-volume intensity histogram detector? Ensembles cost several times more and did poorly on 3D shift in the Kock benchmark. Intensity histograms with Mahalanobis distance matched or beat deep detectors there, but they score whole volumes and cannot say which organ or region to defer. We include the histogram detector as an organ-agnostic, volume-level reference. We will count the proposal useful at the volume level only if it matches that detector while also localising errors.
Decisive Experiments
The first check is the error-migration plot. For each shift we compare the error rate as a function of physical distance with its in-domain curve. The hypothesis predicts a heavier tail at large distances on AMOS MRI and on LGE. The same far-error voxels should show large hyperplane margins but $\rho$ near 0.
The second check is transfer. We fit the error model on AMOS CT source scanners only and measure calibration and error-escape rate on held-out CT scanners and on MRI. The hypothesis predicts that the full model's ECE rises less from source to target than softmax-based calibrators do, and that its error-escape rate at a 10% flag budget is lower than those of the band and hyperplane-margin ablations.
The third check is complementarity with training-time geometry. We apply the post-hoc model on top of the signed-distance-trained segmenter. This tells us whether boundary-aware training already removes the far errors, or whether they persist under scanner shift regardless of how well the boundaries were calibrated in-domain.
A clear failure of the first check would falsify the core claim before any method comparison. A failure of the second would tell us that source-fitted geometry, like softmax, does not transfer.
References
- Selective Classification Under Distribution Shifts
- Calibrating on Medical Segmentation Model through Signed Distance
- A geometric method for improved uncertainty estimation in real-time
- Adapt the Data, Not the Model: Input-Space Adaptation for Frozen Time-Series Predictors
- Prototype Learning for Out-of-Distribution Polyp Segmentation
- Margin Preserving Self-paced Contrastive Learning Towards Domain Adaptation for Medical Image Segmentation
- AMOS: A Large-Scale Abdominal Multi-Organ Benchmark for Versatile Medical Image Segmentation
- Improved Post-hoc Probability Calibration for Out-of-Domain MRI Segmentation
- Limitations of Out-of-Distribution Detection in 3D Medical Image Segmentation
- Improving Uncertainty-based Out-of-Distribution Detection for Medical Image Segmentation
- On the Use of Mahalanobis Distance for Out-of-distribution Detection with Neural Networks for Medical Imaging