Local Gradient Dominance as a Cause of Folding in Learned Image Registration

Deformable image registration warps one scan so that it lines up with another. Learned registration networks are trained by adding two losses. A similarity loss pulls the warped image toward the target. A smoothness penalty keeps the warp physically plausible. When the smoothness penalty loses, the warp folds: neighbouring points swap order and tissue is locally inverted, which shows up as a non-positive Jacobian determinant. Folding makes volumetric measurements such as brain atrophy meaningless. The field usually treats this as a regularization-capacity problem and responds with a larger global weight on smoothness, a diffeomorphic parameterization, or a post-hoc unfolding layer. We propose a different explanation, borrowed from multi-task learning. Folding is a local case of gradient dominance. At a small number of voxels, typically sharp intensity edges, the similarity gradient is orders of magnitude larger than the smoothness gradient, so the optimizer effectively ignores the regularizer there. Elsewhere the two are balanced.

The proposal has two parts. First, we measure whether folding co-locates with a high voxel-wise ratio of similarity to smoothness gradient, computed on the predicted velocity field. Second, if it does, we fix it during training with a voxel-wise gradient rebalancing rule. The rule is applied at the network's output field, before backpropagation into the backbone. Because of where it sits, it costs one extra cheap gradient computation rather than the multiple backbone backward passes that multi-task balancers need. It adds nothing at inference, unlike post-hoc correction. The deliverable is a better accuracy-versus-folding trade-off: higher Dice at matched folding rates, letting a model run with a much weaker global smoothness weight without paying in topology.

Core Claim

Write the network output as a stationary velocity field $v$, integrated to a deformation $\phi=\exp(v)$ by scaling-and-squaring (repeatedly composing a small displacement with itself). Training minimizes $\mathcal{L}_{\text{sim}}(\phi) + \lambda \mathcal{L}_{\text{reg}}(v)$. Both losses are sums over voxels, so their gradients with respect to the output, $g_{\text{sim}}(x)=\partial \mathcal{L}_{\text{sim}}/\partial v(x)$ and $g_{\text{reg}}(x)=\lambda\,\partial \mathcal{L}_{\text{reg}}/\partial v(x)$, are spatial vector fields, not single vectors. We claim the local dominance ratio

$$\rho(x)=\frac{\big(K_\sigma * \|g_{\text{sim}}\|\big)(x)}{\big(K_\sigma * \|g_{\text{reg}}\|\big)(x)+\epsilon},$$

where $K_\sigma$ is a Gaussian smoothing kernel of width $\sigma$ and $\epsilon$ is a small constant, predicts where folding will appear later in training. We smooth with $K_\sigma$ because the regularizer's gradient at a voxel depends on its neighbours, so a pointwise ratio would be noisy. We also claim that capping $\rho$ by boosting the regularizer only where it is dominated removes most folding while keeping alignment accuracy. The training update replaces $g_{\text{reg}}(x)$ with $w(x)\,g_{\text{reg}}(x)$, where

$$w(x)=\min\big(w_{\max},\ \max(1,\ \bar\rho(x)/\tau)\big),$$

$\bar\rho$ is an exponential moving average of $\rho$ across training steps, $\tau$ is the tolerated dominance ratio, and $w_{\max}$ bounds the boost. Away from dominated regions $w=1$ and training is unchanged. The combined output gradient is then backpropagated once through the backbone.

Relation to Prior Work

Several papers motivate the framing. Multi-task optimization work shows that when one task's gradient norm dwarfs another's, the summed update follows the dominant task and the weaker one stalls. Injecting Imbalance Sensitivity for Multi-Task Learning argues that this imbalance, rather than directional conflict, is the main bottleneck. Conflict-Averse Gradient Descent shows that purely directional methods such as PCGrad and MGDA stall at poor points when scales differ. GradNorm and RotoGrad rescale task gradients toward common magnitudes. All four treat each task gradient as one global vector over the shared parameters. Their balancing therefore cannot tell a ventricle border from white matter. They also need a separate backbone backward pass per objective, which is expensive in 3D. We reuse their core diagnosis, norm disparity silencing an objective, but move the balancing to the spatial output field. There the "tasks" are the two loss terms, and their gradients are cheap to separate.

The closest registration work bounds the proposal. Multi-Objective Learning for Deformable Image Registration already treats registration as a tug-of-war between similarity, smoothness and landmarks. It balances them with hypervolume-driven global loss weights across several decoder heads. The authors use plain displacement fields, retain 0.05% folding, and leave diffeomorphic constraints and spatial adaptivity open. We differ on both counts: one decoder, a diffeomorphic parameterization, and voxel-wise rather than global weights. TM-SPR is the most direct competitor. It learns a spatially varying regularization map $\Lambda$ with a decoder under Beta priors, and its prior hyperparameters are tuned by Bayesian optimization. Our $w(x)$ is also a spatial regularization weight, but it is read off the optimization dynamics rather than predicted from image content. It has no learned parameters and exists only during training. Whether this difference matters is an empirical question, and we test it head-on below. Towards Positive Jacobian supplies the post-hoc alternative, a matrix-exponential and Poisson unfolding layer. It fixes the output but not the training dynamics, and it adds inference cost.

The method backbone comes from Probabilistic diffeomorphic VoxelMorph, which introduced differentiable scaling-and-squaring, and from TransMorph, which pairs a Swin-transformer encoder with diffeomorphic variants. DiTASK is the only file entry joining "diffeomorphism" and "multi-task interference." It applies diffeomorphisms to weight singular values and does not measure gradient magnitudes, so it is a different problem that shares vocabulary.

One finding cuts against us. TransMorph's diffeomorphic variants already report 0% non-positive Jacobians. Scaling-and-squaring alone may therefore leave little folding to remove at the usual regularization weights. We accept this and target the regime where it bites. As the global $\lambda$ is lowered to gain alignment, large velocity spikes cause discretization error in the composition steps and folding returns. The claim is about the shape of the Dice-versus-folding curve, not about any single operating point.

Research Program

The first stage is diagnostic and can falsify the premise. We train TransMorph-diff and VoxelMorph-diff on OASIS and on the LUMIR brain data at a sweep of global $\lambda$ values. At checkpoints we log three maps: $g_{\text{sim}}$, $g_{\text{reg}}$, and the Jacobian determinant. We then ask whether high $\bar\rho$ at step $t$ predicts $\det J_\phi \le 0$ at step $t+\Delta$. We compare it against two competing predictors, image-gradient magnitude and current velocity magnitude, using area under the ROC curve. We also measure how the similarity gradient changes in norm and spatial concentration as it backpropagates through the $T$ composition steps of scaling-and-squaring. This tests the file's Gap 1, which proposes that the exponential layer itself distorts relative gradient scales. If $\rho$ predicts folding no better than image edges do, the mechanism is wrong. In that case we would report the negative result and the method would reduce to edge-aware regularization.

The second stage builds the rebalancing rule above as a drop-in hook on the output velocity. Computing $g_{\text{sim}}$ and $g_{\text{reg}}$ separately requires only backpropagating each loss to $v$. The regularizer's gradient is analytic, and the similarity gradient passes through the warp and integration layers but not the backbone. We then run one backbone backward pass on the combined gradient. We study a sensitivity grid over $\tau$, $w_{\max}$ and $\sigma$, and test whether one setting transfers across brain, lung and whole-body data. Transfer without retuning is the practical advantage we claim over TM-SPR's Bayesian sweeps. We also test the mirror variant, which attenuates $g_{\text{sim}}$ instead of boosting $g_{\text{reg}}$, since the two behave differently under adaptive optimizers.

Baselines

The naive reference is the same backbone trained with a single global $\lambda$, swept over at least six values. This gives a full Dice-versus-folding curve rather than one hand-picked point. Every other method is compared against this curve at matched folding rates.

The strongest existing method on the heterogeneous-anatomy question is TM-SPR. Its reported results are a target registration error of 1.356 mm on lung 4DCT and a Dice of 0.677 on autoPET whole-body CT, against 0.661 for TransMorph, per TM-SPR. We will retrain it from its described setup on the same splits with the TransMorph backbone. Its prior hyperparameters get the same number of tuning trials we give $\tau$ and $w_{\max}$. Beating it means a lower lung TRE or a higher autoPET Dice at equal or lower folding, with one set of hyperparameters across datasets. If we only match it without any tuning, that is a weaker but still useful result.

On OASIS, the strongest folding-specific baseline is the post-hoc layer of Towards Positive Jacobian. It reports reducing non-positive Jacobians from 0.6895% to 0.0207% at Dice around 0.80, with about 1.2 s of added GPU time. We apply it to the same backbone. Beating it means reaching comparable folding at equal Dice with zero inference overhead, or showing that the two combine additively.

For the global multi-task balancers, we run GradNorm and CAGrad on the two-term registration loss with full per-loss backbone gradients. This isolates whether spatial resolution matters beyond norm balancing as such. We also report wall-clock time and memory.

On LUMIR, the reference is the reported Dice of 77.34%, HD95 of 3.3415 mm and non-diffeomorphic volume of 0.0001% from the Learn2Reg 2024 solution. We use it as context rather than as a retrained baseline, because its architecture differs.

The key ablation replaces $\bar\rho$ with a fixed, image-derived weight map, a regularization boost proportional to the smoothed intensity-gradient magnitude of the fixed image, tuned identically. A second ablation sets $\sigma=0$ to test the neighbourhood smoothing. A third removes the moving average to test robustness to mini-batch noise.

Why not just…?

Why not just tune the global $\lambda$ harder? A single scalar has to serve both the edge voxels where similarity dominates and the homogeneous voxels where it does not. TM-SPR documents exactly this conflict at sliding lung interfaces, and Grewal et al. report that grid search clusters solutions rather than tracing the trade-off. The global-$\lambda$ curve is our naive baseline. If our curve does not lie strictly above it at matched folding, the proposal fails.

Why not just use an edge-aware or learned spatial regularization map, as TM-SPR does? This is the real threat, because our $w(x)$ is, in effect, a spatial regularization weight. The difference is that $\rho$ also reflects residual mismatch and amplification through the composition steps, which a map computed from image content cannot see. Whether that matters is settled by two comparisons. The image-gradient ablation tests a hand-made content map, and the TM-SPR comparison tests a learned one. If the content map matches us, we will say so; the diagnostic stage would already have warned us.

Why not just unfold the output afterwards? Post-hoc unfolding works on folding counts, but it adds inference latency. It also leaves the trained network producing near-folded fields that are then corrected away from what the network intended. We test both alone and combined. If post-hoc correction plus a low global $\lambda$ dominates every training-time rule, that is a legitimate negative finding for our approach.

Why not just apply GradNorm or CAGrad to the two losses? These methods balance one global norm per loss. In registration the dominance is concentrated in a few percent of voxels, so a global rescaling either over-smooths everywhere or under-protects the edges. They also need full backbone backward passes per loss. The direct comparison measures both accuracy and cost.

Decisive Checks

Three results decide the project. The first is whether $\bar\rho$ predicts future folding better than image-edge magnitude does on OASIS and LUMIR. The second is whether the rebalanced model's Dice-versus-folding curve lies above the global-$\lambda$ curve and above the image-derived map on OASIS, measured by Dice and percentage of non-positive Jacobians. The third is whether a single setting of $\tau$ and $w_{\max}$, chosen on brain data, matches or beats retuned TM-SPR on lung 4DCT and autoPET, measured by TRE, Dice and folding. If the first check fails, we stop and publish the diagnostic. If the first holds but the third fails, the contribution narrows to a cheap, parameter-free alternative to post-hoc unfolding for brain registration.