Clinical Context as a Filter on Fine Boundary Detail

Segmentation networks face a built-in tension. Their early layers see sharp edges and fine texture but cannot tell a real organ border from noise, while their deep layers know what tissue is present but have lost exact positions. The standard fix is to copy early, high-resolution features into the late stages through skip connections. In low-contrast medical images, such as thin heart walls on ultrasound or tumors that blend into surrounding tissue, those copied features carry a lot of texture that looks like a border but is not one. Whether a given faint gradient is a true border often depends on facts the image does not contain: which scanner vendor produced the scan, what disease the patient has, what tumor subtype was found at biopsy. Radiologists use this context all the time. Networks either ignore it or apply it uniformly to every pixel.

We propose that clinical metadata should act on one specific decision: at pixels where the network is uncertain about the boundary, it should control how much fine, high-frequency detail from the early layers is allowed into the prediction. It should not modulate whole feature maps globally. The claim is falsifiable. If it holds, metadata should improve surface-distance metrics much more than overlap metrics. The improvement should concentrate in subgroups whose boundary appearance differs, such as vendors or margin types. Shuffling metadata across patients should remove the improvement. Applying the same conditioning globally at matched capacity should do no better.

Core Claim

The obvious combination of these directions is to feed metadata into a boundary branch, for example to apply FiLM to an edge decoder. FiLM (feature-wise linear modulation) predicts a per-channel scale and shift from side information. The literature in this file has not done this. Metadata conditioning exists only in global or stage-wise forms:

Boundary-focused models are entirely image-only:

"FiLM the edge branch," however, is a weak idea. Edge branches already receive deep semantic features, and a skeptic would reasonably expect global FiLM to deliver the same benefit. We therefore target a narrower mechanism that global conditioning cannot reproduce by construction. Metadata gates the high-frequency part of the skip connection, and only inside the band where the coarse prediction is uncertain. This directly addresses two open problems in the file. The first is that shallow layers pass texture that mimics boundaries even under semantic attention. The second is that explicit edge branches overfit to spurious contours.

Mechanism

Let $S$ be a shallow, high-resolution skip feature map and $D$ the deep feature map. Let $U(\cdot)$ denote upsampling to the resolution of $S$, $B(\cdot)$ a fixed Gaussian blur, and $S_{hi} = S - B(S)$ the high-frequency residual of the skip features. Let $p$ be the upsampled coarse foreground probability, and $u = 1 - |2p - 1|$ the per-pixel uncertainty, which is 1 at $p = 0.5$ and 0 at confident pixels. Let $m$ be a learned embedding of the clinical metadata. The fused feature is

$$F = U(D) + B(S) + \big[(1-u) + u \odot g(U(D), m)\big] \odot S_{hi},$$

where $g$ is a small convolutional network ending in a sigmoid. It outputs a per-pixel, per-channel admission weight in $[0,1]$. Its input is the deep features, with $m$ broadcast spatially and concatenated.

The equation encodes three behaviors. Outside the uncertain band, the skip connection behaves exactly like an ordinary skip connection, as in Long et al.. The low-frequency part of the skip is always admitted. Metadata can only decide whether fine detail near the contested border is trusted.

This design reuses two existing ideas:

  • The uncertainty band follows the reverse-attention logic of Parallel Res2Net.
  • The gate follows semantic-guided suppression of shallow noise in Zhang et al..

The new element is that the gate depends on $m$, and it acts only on the high-frequency component. That gives the metadata a narrow, inspectable role.

Missing metadata is handled in two ways. During training, each field is randomly dropped and replaced by a learned "missing" token. With all fields missing, $g$ reduces to an image-only gate, so the model degrades to a vision-only boundary model rather than failing.

Research Program

We build the gate into a standard 2D U-Net decoder for cardiac data, with an auxiliary boundary loss. We use the same backbone for every baseline so that differences come from the conditioning pathway alone.

The primary benchmark is M&Ms-2. It is cardiac MRI from nine scanner models and three vendors, with five disease states, and was used by Compositional Segmentation. Vendor is the cleanest test of our hypothesis. Vendors differ in noise and edge sharpness, which is exactly what should change how much fine detail to trust. Disease state is a plausible geometric prior, for example wall thickening.

The second benchmark is CAMUS, a 500-patient echocardiography set with age, sex and ejection fraction (EF). Thin myocardial borders on ultrasound are a canonical low-contrast case. CAMUS also requires care: ejection fraction is computed from the ventricular segmentation itself, so conditioning on it leaks the answer. We therefore condition only on age and sex. We run EF conditioning separately and report it as an explicit leakage control, to show what a spurious metadata gain looks like.

If the spinal cord tumor MRI set from FiLM U-Net can be obtained, it provides the sharpest test of margin priors. That set covers 343 scans with histology labels, contrasting infiltrative astrocytomas with well-circumscribed hemangioblastomas. Its public availability is not established in the file, so it is a contingent third arm.

We deliberately leave text-report conditioning, iterative refinement in the style of RecycleNet, and 3D pancreatic CT out of the core study. PanTS ( PanTS: The Pancreatic Tumor Segmentation Dataset) names multimodal integration as an open problem but does not supply EHR fields we can rely on. The aim is one clean causal test of where metadata helps, not a large system.

Baselines

Do-nothing reference. The first reference point is the shared U-Net with plain skip connections and Dice plus cross-entropy loss, given no metadata. Every gain is reported relative to it.

Strongest image-only boundary competitor. The second is the same backbone with an image-only uncertainty-band gate plus the auxiliary edge loss. This is our model with $m$ removed, functionally a reverse-attention and edge-branch design in the spirit of MISNet and DB-MSMUNet. It is also the key ablation, because it isolates whether the metadata, rather than the gate, does the work.

Strongest existing metadata method. The third is CMFI from Compositional Segmentation of Cardiac Images Leveraging Metadata. That paper reports a 91.72% average Dice on M&Ms-2, and 90.02% without the metadata module. We will reimplement CMFI on our backbone and report both the published figure and our reproduction. For CAMUS, no reported result was found on Lacuna for CMFI or any other method. The comparison there rests on our own runs.

Global FiLM. The fourth is global FiLM at every decoder stage, following Benefits of Linear Conditioning. That paper reports an average 5.1% Dice improvement on its spinal tumor data. Its parameter count will be matched to ours by widening the conditioning network.

Additional ablations. We also run three variants of our gate:

  • the gate applied to the full skip rather than only $S_{hi}$;
  • the gate applied everywhere rather than only in the uncertain band;
  • metadata routed through global FiLM and through our gate simultaneously.

Fairness protocol. All models get the same splits and augmentation. Each gets the same number of hyperparameter trials (twenty, random search over learning rate and loss weights), the same training epochs, and five seeds.

What counts as winning. Our model beats the competitors only if two conditions hold. First, it improves 95th-percentile Hausdorff distance (HD95) and normalized surface distance over both CMFI and global FiLM, beyond seed variance. Second, it is not worse in Dice. Matching CMFI's Dice while improving surface metrics counts as support. Improving Dice alone does not.

Why not just…?

Why not just apply FiLM globally, as prior work does? This is the main threat. The CMFI ablation shows metadata is worth about 1.7 Dice points on M&Ms-2, and nothing in the file says where in the image that gain arises. If global FiLM at matched capacity equals our band-restricted gate on HD95 and surface distance, our mechanism claim is wrong and we will report it that way. One further check discriminates the two. We compute the surface-distance improvement restricted to the uncertain band and outside it. Our hypothesis predicts the gain concentrates in the band. Global FiLM has no reason to show that pattern.

Why not just use a strong vision-only boundary model and more data? PanTS shows that scale and richer anatomical labels move pancreatic results substantially without any metadata. Image-only boundary designs already generalize well; MISNet's drop on ETIS is 16.8% versus over 38% for others. Two experiments answer this. The image-only gate baseline measures what the architecture does without metadata. A test-time metadata shuffle measures what the trained model actually draws from $m$. If shuffling leaves performance intact, the metadata is decorative.

Why not just train a separate model per vendor or per disease? This is the simplest way to use categorical metadata. It may work when groups are large. M&Ms-2 has a few vendors but many scanner-by-disease cells, and per-group models cut the training data for each model sharply. We train per-vendor models as an additional baseline. Our prediction is that they match us only for the largest vendor and fall behind on the smaller ones.

Why not just add a boundary loss to the conditioned network? A boundary loss on top of global FiLM changes what is penalized, not what evidence reaches the boundary. We include the auxiliary edge loss in every boundary-aware baseline, so this comparison is already built in.

Decisive Checks

We evaluate four metrics:

  • Dice;
  • HD95;
  • normalized surface distance at a 1-pixel tolerance;
  • IoU restricted to a fixed-width band around the ground-truth contour.

All are reported overall and per vendor or disease subgroup, with seed-level confidence intervals.

The study rests on four checks:

  1. Band-restricted gain. Against parameter-matched global FiLM, the advantage must appear in surface metrics and in-band IoU.
  2. Metadata shuffle. Permuting $m$ across test patients must erase the advantage over the image-only gate.
  3. Counterfactual swap. Changing the vendor or disease token for a fixed image should move predicted contours, mainly inside the band, while leaving confident interiors nearly unchanged. For disease swaps, the direction of movement should be anatomically sensible, such as a thicker myocardium under hypertrophic cardiomyopathy.
  4. Gate tracks image character. The mean gate value per vendor should correlate with an independent measure of that vendor's high-frequency noise energy.

The CAMUS EF-leakage run serves as calibration. It shows how large a spurious gain can look, so that the age and sex results are read against it.

If the first two checks fail, the conclusion is that clinical context helps segmentation globally, if at all, but not by changing the interpretation of boundary detail. That negative result would still tell future multimodal designs where not to spend their complexity.