Evolving Boundary-Loss Schedules for Unseen Scanners

Segmenting organs with faint, blurry edges, such as the pancreas, the heart wall, or atrial scar, depends heavily on a few hand-set training knobs. These are how strongly to weight a loss that penalizes errors at the boundary, when to switch that loss on, and which fraction of the hardest pixels to focus on. Published values were tuned by trial and error on one dataset. Nobody knows whether they survive a move to a hospital with a different scanner, or to a different MRI sequence where tissue brightness flips. We propose to treat these knobs as a short time-varying schedule. We search it with an evolutionary method, meaning a population of training runs that are scored, copied, and randomly perturbed. The key change is the scoring rule: each run is judged by how well it traces boundaries on a hospital it never trained on, not by in-domain accuracy.

The bet is that the boundary-loss weight interacts strongly with how much the training images are randomized in brightness and contrast. Shape-based boundary supervision should only help across scanners when the network is also prevented from relying on appearance. If that is true, tuning one knob at a time will miss the good region. A covariance-adapting evolution strategy that learns correlated moves should find it, and the schedules it finds should transfer to a third, held-out hospital.

Core Claim

The proposal makes two claims. The first is empirical and currently unknown. Distance-map boundary losses can either help or hurt under scanner and sequence shift, depending on how much appearance randomization is applied alongside them. The second is methodological. A population search over a joint schedule (boundary weight over time, hardest-pixel fraction, and contrast-randomization strength) beats both the published fixed schedules and equal-budget random search on unseen-site boundary accuracy. It does so only when its fitness signal comes from a held-out site.

The training loss we search over is

$$ L_t = (1-\alpha_t)\, L_{\text{GDL}} + \alpha_t\, L_{\text{B}} + \beta\, L_{\text{TopK}(k)}, $$

where $L_{\text{GDL}}$ is the generalized Dice loss over whole regions, $L_{\text{B}}$ is the signed-distance boundary loss, $\alpha_t$ is a boundary weight that depends on training epoch $t$, and $L_{\text{TopK}(k)}$ is cross-entropy restricted to the fraction $k$ of highest-error pixels, weighted by $\beta$. The boundary loss comes from Boundary loss for highly unbalanced segmentation. The hardest-pixel loss is used, with a fixed $k=10\%$, in Automatically Segment the Left Atrium and Scars from LGE-MRIs Using a Boundary-focused nnU-Net.

The searched genome has six parameters. Three shape the ramp of $\alpha_t$: its start epoch, its slope, and its ceiling. The other three are $k$, $\beta$, and the strength $s$ of random intensity and contrast remapping applied to the training images. The randomization is in the style of the synthetic-appearance training of Towards Automatic Abdominal MRI Organ Segmentation: Leveraging Synthesized Data Generated From CT Labels.

Where This Sits

The work rests on three groups of papers, each playing a different role.

The first group motivates the gap. The boundary-loss paper reports gains on ISLES stroke lesions, from 0.575 to 0.656 Dice. It also notes that $\alpha$ must follow a manual ramp or training collapses before the object is located. The atrial-scar paper chose $k=10\%$ by hand and says the right value depends on noise and contrast. CrossPan: A Comprehensive Benchmark for Cross-Sequence Pancreas MRI Segmentation and Generalization shows pancreas Dice falling from above 0.85 in-domain to below 0.02 across MRI sequences. In that benchmark histogram matching and standard domain generalization barely help, and boundary losses were never tried. Together these establish two facts: boundary-loss knobs matter, and their behaviour under shift is untested.

The second group comes closest to our method, and we differ from it in specific ways. Data Poisoning Attack Defense and Evolutionary Domain Adaptation for Federated Medical Image Segmentation, known as AdaShield-FL, uses the Covariance Matrix Adaptation Evolution Strategy (CMA-ES) to balance a segmentation loss against a feature-alignment loss across federated clients. Its segmentation loss is plain Dice plus cross-entropy, and its alignment step needs raw MRI k-space data. We use the same family of optimizer on a different target: the boundary-supervision schedule and its interaction with appearance randomization, with an explicit out-of-site fitness.

Auto-FedRL: Federated Hyperparameter Optimization for Multi-institutional Medical Image Segmentation tunes learning rates and aggregation weights with a reinforcement-learning agent and never touches loss structure. Effective Regularization Through Evolutionary Loss-Function Metalearning evolves per-pixel classification losses on CIFAR. It supplies the idea that evolved losses regularize, but it contains no spatial or boundary terms and no distribution shift.

The third group constrains the design. Beyond Pooling: Matching for Robust Generalization under Data Heterogeneity shows that naively pooling sites can hurt generalization. We therefore keep site identity explicit in how training and validation sites are split, rather than tuning on a pooled validation set.

CrossPan also creates a tension we take seriously. Contrast inversion between T1- and T2-weighted MRI may be beyond what any loss schedule can repair. We treat cross-sequence transfer as a stress test where we expect only partial recovery, not as the headline setting.

Research Program

We build on nnU-Net-style 3D pipelines, referenced through The Medical Segmentation Decathlon, so that the backbone and preprocessing are fixed and only the genome varies.

The search runs inside a single training budget, in the style of population-based training. Eight model copies train in parallel. Every fixed number of epochs, each copy is scored by a fitness function: mean boundary Dice plus a normalized 95th-percentile Hausdorff distance, measured on a validation site that is excluded from training. Low-fitness copies inherit the weights of high-fitness copies and receive new genomes sampled from a CMA-ES distribution. That distribution is re-estimated from the surviving genomes, so it learns which knobs should move together.

Data are split three ways by site. Training sites supply gradients, one validation site supplies fitness, and a test site is never seen by either. Every split is rotated, leave-one-site-out, so that results do not hinge on one lucky site.

The analysis has three parts. We map fitness over the $(\alpha_{\max}, s)$ plane on a coarse grid to see whether a ridge of good settings exists, which is what the interaction hypothesis predicts. We record the evolved schedules per target site to see whether they differ systematically by vendor or sequence. We also test whether a schedule evolved for one held-out site transfers to another without re-searching.

Baselines

The do-nothing reference is the default nnU-Net configuration with regional losses only, trained on the same sites. It shows how much any boundary supervision adds under shift.

The second reference is the published fixed recipes. One is the generalized Dice plus boundary loss with the linear $\alpha$ ramp of Boundary loss for highly unbalanced segmentation. The other is the hardest-pixel loss with $k=10\%$ from Automatically Segment the Left Atrium and Scars from LGE-MRIs Using a Boundary-focused nnU-Net. Both are run with and without contrast randomization at a single hand-chosen strength. These are what a practitioner would actually use. The boundary-loss paper's reported single-domain gain (0.575 to 0.656 Dice on ISLES) and the scar paper's 90.51% atrial-cavity Dice on LAScarQS are in-domain figures. We reproduce them only as sanity checks, not as targets under shift.

The strongest competitor is equal-budget random search over the same six-dimensional genome with the same held-out-site fitness. It gets eight full training runs, matching the eight-copy population, and the final pick is made on the validation site. In practice random search often matches evolutionary methods at low dimension. Beating it is therefore the real test of whether evolution, rather than simply searching at all, matters.

For the cross-sequence stress test, the strongest number in the file is MedSAM2 zero-shot at 0.47 to 0.59 Dice on CrossPan. Unadapted supervised models fall below 0.02 there (CrossPan). For held-out-vendor boundary metrics on M&Ms, no reported result was found on Lacuna. The only M&Ms figure, AdaShield-FL's 82.7% Dice under attack, is a different setting and is not comparable.

Two ablations isolate the key ingredients. In the first, the same population search uses in-domain validation fitness instead of held-out-site fitness. This tests whether the out-of-site scoring is what matters. In the second, CMA-ES is replaced by an isotropic genetic algorithm with no learned covariance. This tests whether correlated moves along the predicted $(\alpha, s)$ ridge are needed.

We count the proposal as winning only under specific conditions. On the never-seen test site, it must beat random search on boundary Dice and HD95 by more than the spread across three seeds, in a majority of leave-one-site-out rotations. The in-domain-fitness ablation must lose to it.

Why not just…?

Why not just use the published ramp and $k=10\%$? This is plausible when the target site resembles the training sites. The scar paper itself reports that the right $k$ shifts with noise and contrast, which is exactly what changes across vendors. The do-nothing and fixed-recipe baselines answer this directly. If they match the evolved schedules on unseen sites, the conclusion is that boundary knobs are robust to shift. That would itself answer an open question raised by CrossPan.

Why not just random search? This is the real threat, and we do not argue around it. With six genes and eight trials, random search may find the ridge by chance. Population search has one structural advantage: it adapts the schedule during a run, so the start epoch and ramp can respond to when the coarse object is located, which a fixed trial cannot do. If equal-budget random search ties, we will report that the contribution is the held-out-site fitness and the interaction finding, not the optimizer.

Why not just use a foundation model such as MedSAM2? On the hardest shift in the file, MedSAM2 reaches only 0.47 to 0.59 Dice on CrossPan, far from in-domain accuracy above 0.85. It also offers no mechanism for boundary-specific tuning. We include it as a reference and test whether fine-tuning it with the evolved schedule helps.

Why not just harmonize intensities or pool all sites? CrossPan reports that histogram matching gives negligible gains across sequences. Beyond Pooling shows that pooling can confound generalization. Our contrast-randomization gene subsumes the harmonization knob, and the site-explicit splits avoid the pooling trap.

Proposed Experiments

The primary setting is M&Ms cardiac MRI with leave-one-vendor-out splits across Siemens, Philips, GE, and Canon. Myocardium boundaries are thin and low-contrast, making it the cleanest test of scanner shift. The second setting is cross-site pancreas CT, using MSD Pancreas, NIH Pancreas, and the multi-site structure cited by DB-MSMUNet, which reports 87.59% and 89.47% in-domain Dice there. The stress test is CrossPan: first across centers within one sequence, then across sequences, where the comparison bar is MedSAM2's 0.47 to 0.59 Dice.

Metrics are region Dice, boundary Dice within a fixed millimetre band, and 95th-percentile Hausdorff distance, all on the never-seen site. We report variance over three seeds per rotation.

The decisive checks are four.

The interaction map must show a diagonal ridge, meaning high boundary weight helps only at high contrast randomization. If it does not, the core mechanistic claim is wrong.

The held-out-fitness population must beat its in-domain-fitness twin on the third site. If it does not, the out-of-site scoring adds nothing.

The CMA-ES version must beat both random search and the isotropic genetic algorithm at equal budget. If it does not, the optimizer is incidental and we say so.

On CrossPan cross-sequence transfer, we predict the evolved schedule clearly beats the unadapted model below 0.02 Dice. We do not expect it to reach in-domain accuracy. Exceeding MedSAM2's range would be strong evidence that shape-based boundary supervision, paired with appearance randomization, transfers across contrast inversion.