When a medical segmentation model meets images from a scanner vendor it never saw in training, it usually fails quietly. It does not crash. It draws a confident but wrong boundary, often on the hardest slices, such as the base and apex of the heart. This proposal adds a second output head that predicts, for every voxel, its signed distance to the organ boundary: negative inside, positive outside. A true distance field obeys a simple geometric law. Its spatial gradient has magnitude one everywhere near the boundary. That law holds no matter what the image looks like, so how badly the predicted field breaks it is a check that needs no labels and is computed from the model's own output on the new scanner.
The core claim is that, under vendor shift, the places where the distance head breaks this law, or disagrees in sign with the ordinary per-voxel classification head, are the places where the segmentation is wrong. If that holds, the same signal can do two jobs at inference time with no weight updates. It can flag unreliable cases for quality control, and it can locally correct the boundary by trusting whichever head is more self-consistent at each location. That would make it a cheap alternative to test-time adaptation, which fine-tunes the network on every incoming scan.
Core Claim
The proposal makes three claims, from the most testable to the most ambitious.
The first is about detection. Train a network with a standard one-hot classification head plus a bounded signed-distance head. Then measure two things at test time: the eikonal residual of the distance head, and its sign disagreement with the classification head. ("Eikonal" refers to the equation stating that a distance field's gradient has unit magnitude.) The claim is that this measure localizes boundary errors on an unseen vendor better than softmax entropy and comparably to an ensemble, at a fraction of the cost.
The second is about correction. A training-free fusion of the two heads, weighted by local consistency, lowers boundary error on unseen vendors. The relevant errors are the 95th-percentile Hausdorff distance and the average symmetric surface distance, measured on top of a strong nnU-Net trained with aggressive intensity augmentation.
The third is about mechanism. The benefit is concentrated in the regimes where the M&Ms challenge left residual error: the basal and apical slices and the completely unseen Canon vendor.
Concretely, let $\hat{s}(x)$ be the distance head's output at voxel $x$ after inverting the tanh bound used during training. Let $p(x)$ be the classification head's foreground probability. Let $B$ be a narrow band around the predicted boundary, where the clipped distance is still a true distance. The per-voxel inconsistency is
$$ r(x) = \big|\, \|\nabla \hat{s}(x)\| - 1 \,\big| + \beta \,\mathbf{1}\!\left[\operatorname{sign}(\hat{s}(x)) \neq \operatorname{sign}(0.5 - p(x))\right], \quad x \in B, $$
where $\beta$ weights sign disagreement against the gradient-norm violation. Averaging $r$ over $B$ gives a per-case reliability score. For correction, the fused level set $\hat{s}(x) + \lambda(r(x))\,(\phi_p(x) - \hat{s}(x))$ is thresholded at zero. Here $\phi_p$ is the signed distance transform of the classification head's mask, and $\lambda$ moves toward one wherever the distance head is locally implausible.
Relation to Prior Work
Four papers supply the method, and in each case the open part is behavior under shift. Boundary loss for highly unbalanced segmentation weights softmax outputs by a precomputed distance map and gains about 8% Dice on ISLES, but its multi-center brain data is evaluated with pooled splits. It also uses distance only as a training signal and never as a quantity checked at test time. Hot-Distance combines one-hot heads with tanh-bounded signed-distance heads to exploit partial labels, and we reuse its two-head design directly. Its purpose is annotation efficiency, not shift, and it does not use agreement between heads as a signal. Calibrating on Medical Segmentation Model through Signed Distance shows that DiceCE-trained models are badly overconfident at boundaries, with foreground ECE of 0.137 versus 0.039 with its signed-distance calibration loss on ACDC. It is evaluated only in-domain, and its authors note that its assumed distance-to-probability relationship breaks under heavy noise. Our proposal turns that weakness into the measurement: we do not assume the relationship holds, we measure where it fails. Deep Distance Map Regression Network and E2Net also supervise with distance maps, and both are tested within LiTS-style data. We need neither the pretrained auxiliary regressor of the former nor the two-stage cropping of the latter.
Three papers motivate the proposal and constrain it. The M&Ms challenge establishes that intensity augmentation inside nnU-Net is the main lever against vendor shift, shrinking the unseen-vendor drop from about 6% to 1.5%. No top team used distance supervision, and errors persisted at the base and apex. That result rules out pitching distance supervision as a replacement for augmentation, so our method must sit on top of it. Gradient-Map-Guided Adaptive Domain Generalization shows that boundary structure survives even an intensity-inverting change of MRI sequence. Its Sobel-based input reaches 85.4% Dice from bSSFP to T2, but only with per-scan test-time adaptation and class priors. We keep its insight that geometry is the invariant part of the image, but place the geometry in the output rather than the input, and correct without gradient steps. MS-Net reduces multi-site prostate boundary error with per-site normalization, but needs to know each scan's site at inference. Our check needs no site information.
The closest conceptual neighbor is Deep Poincare Map. It encodes the left-ventricle boundary as an attracting cycle of a vector field and transfers zero-shot from Sunnybrook to STACOM, with Dice of 0.74 against 0.66 for the best baseline. It also argues that a field-structured output generalizes better than per-pixel labels. However, it needs a seed point, handles one 2D structure, and offers no self-check.
Research Program
We build one model family on nnU-Net with the M&Ms-style intensity augmentation pipeline: histogram matching, gamma, and noise. To it we add a tanh-bounded signed-distance head per class, in the Hot-Distance style. The distance head is trained with regression to the clipped ground-truth distance plus an eikonal penalty inside the band. That penalty makes "the gradient has unit magnitude" something the network learns to satisfy on the training vendors, so any violation on a new vendor is informative.
For multi-class anatomy such as the left ventricle, myocardium, and right ventricle, we add a cheap consistency term. Adjacent structures' distance fields should cross zero at the same place where they share a boundary. This catches errors at the myocardium–blood-pool interface.
The analysis has three parts. First, we test whether the inconsistency map $r$ localizes errors: voxel-level error detection inside the band, and case-level ranking of Dice and HD95. Second, we test whether consistency-weighted fusion improves boundaries without hurting overlap. Third, we test whether gains concentrate on unseen vendors and difficult slices, as the mechanism predicts, rather than appearing uniformly as a generic regularization effect. The fusion and residual are computed by finite differences and a distance transform, adding seconds per volume rather than the minutes of per-scan optimization.
Baselines
The naive reference point is nnU-Net with Dice plus cross-entropy and its default augmentation, trained on M&Ms vendors A and B. It shows the size of the shift gap that M&Ms reports, roughly 6% on unseen vendors.
The strongest existing competitor for accuracy is nnU-Net with the aggressive intensity augmentation used by the winning M&Ms teams. Their reported left-ventricle Dice is roughly 0.88 to 0.92 across vendors, with the unseen-vendor drop reduced to about 1.5% (M&Ms). It is the right opponent because it already absorbs most of the intensity shift. We retrain it ourselves on the same splits, with the same augmentation, epochs, and five-fold ensembling budget as our model. Beating it means a statistically significant reduction in HD95 and average surface distance on vendor D and on basal and apical slices, with Dice no worse than 0.5 points lower. A Dice tie with clearly better boundaries counts as a win, because boundary error is where M&Ms says the residual problem lives.
For error detection, the competitors are softmax entropy from the same network and a five-member deep ensemble's disagreement. The ensemble is the strongest, at five times the inference cost. Beating entropy and matching the ensemble on area under the risk–coverage curve at one-fifth the cost counts as success. No reported result was found on Lacuna for label-free error detection on M&Ms.
For the severe-shift setting, the competitor is GMR+PITTA, at 85.4% average Dice from bSSFP to T2 on MS-CMRSeg (Gradient-Map-Guided Adaptive Domain Generalization). We run it with the authors' recipe and report Dice together with wall-clock time per volume. We do not expect to beat it on Dice without adaptation. Success there is closing most of the gap at under a tenth of its latency, or adding our fusion on top of PITTA and improving it.
For in-domain calibration, the reference is the signed-distance calibration loss (SDC), with ACDC foreground ECE of 0.039 (Calibrating through Signed Distance). We run it as a training loss on the same backbone and evaluate it out-of-domain, which its authors did not.
Two ablations isolate the key ingredient. The first trains the distance head without the eikonal penalty, testing whether the learned unit-gradient property is what makes violations informative. The second uses Kervadec's boundary loss as a pure training regularizer with no test-time check. This separates "distance supervision regularizes training" from "distance self-consistency checks inference."
Why not just…?
Why not just add a boundary loss and stop there? This is the obvious version of the intersection and may well give a small out-of-domain gain. But Boundary loss uses distance only during training, so it provides no inference-time signal and no correction. The boundary-loss ablation measures exactly this. If it matches the full method on surface-distance metrics under shift, the correction claim fails and only the detection claim remains.
Why not just rely on intensity augmentation, as the M&Ms winners did? This is the most serious threat to the correction claim. The M&Ms residual gap of 1.5% Dice may leave little room. Our answer is that the residual error is boundary-localized and slice-localized, which Dice averages away. That is why we judge on HD95 and average surface distance, broken down by slice position. If augmentation alone already brings these to parity on vendor D, we will report correction as unnecessary and keep detection as the contribution. Even a well-augmented model still needs to flag its failures.
Why not just use softmax entropy or an ensemble to find errors? Entropy is free but tracks the classification head's own overconfidence, which Calibrating through Signed Distance documents at boundaries. That is the wrong place to be confident. Ensembles are probably as good as our check but cost several forward passes. The risk–coverage comparison settles this directly. If entropy matches the eikonal residual, the detection claim is false.
Why not just do test-time adaptation? It works, as the 85.4% from GMR+PITTA shows. But it requires gradient updates per scan and class priors that break under unusual pathology. We compare at matched accuracy and report latency, and we also test the two as complements rather than rivals.
Proposed Experiments
The primary experiment is M&Ms. We train on vendors A and B, use vendor C only for evaluation (not as unlabeled training data, to keep the setting zero-shot), and test on C and on the unseen vendor D. We report Dice, HD95, and average surface distance per structure, per vendor, and per slice position, plus pixel-wise ECE as defined by the calibration paper.
The decisive check is a pre-registered prediction about vendor D. The case-level correlation between mean $r$ and HD95 should exceed the corresponding correlation for entropy. The fusion's HD95 gain should be larger on vendor D than on vendors A and B. If gains are flat across vendors, the improvement is generic regularization, not shift-specific correction, and the mechanism claim is rejected.
The second setting is the multi-site prostate MRI data used by MS-Net, run leave-one-site-out. MS-Net reports 91.66% Dice and 0.77 mm average surface distance with site labels and in-distribution sites. That is an upper reference, not a like-for-like comparison, since our model never sees the test site or its identifier.
The stress test is MS-CMRSeg from bSSFP to T2, where the source-only Dice is 4.9%. We expect the distance head itself to collapse there. The question is whether $r$ still rises enough to flag the collapse, which tests whether the check fails loudly rather than silently.
A final extension is cross-modality small-organ evaluation on AMOS, training on CT and testing on MRI. AMOS reports a drop of over 20% on unseen-scanner MRI. We would ask whether the inconsistency map concentrates on the duodenum and adrenal glands, where that drop is worst.
References
- Boundary loss for highly unbalanced segmentation
- Hot-Distance: Combining One-Hot and Signed Distance Embeddings for Segmentation
- Calibrating on Medical Segmentation Model through Signed Distance
- Deep Distance Map Regression Network with Shape-Aware Loss for Imbalanced Medical Image Segmentation
- E2Net: An Edge Enhanced Network for Accurate Liver and Tumor Segmentation on CT Scans
- Multi-Centre, Multi-Vendor and Multi-Disease Cardiac Segmentation: The M&Ms Challenge
- Gradient-Map-Guided Adaptive Domain Generalization for Cross Modality MRI Segmentation
- MS-Net: Multi-Site Network for Improving Prostate Segmentation With Heterogeneous MRI Data
- The Deep Poincaré Map: A Novel Approach for Left Ventricle Segmentation
- AMOS: A Large-Scale Abdominal Multi-Organ Benchmark for Versatile Medical Image Segmentation