Displacement vs. Diffeomorphic Transformations
Every registration network in my MIR toolkit predicts a vector field, and MIR lets you choose how that field becomes a transformation. Drag on the brain to push tissue around: your strokes build one field v, applied on the left as a displacement (φ = id + v) and on the right as a stationary velocity field (φ = exp(v), integrated by scaling and squaring). Push hard and watch which one tears.
Jacobian determinant |J| (below) measures local area change.
folded: |J| ≤ 0 (central difference)
folded, but missed by central differences; caught by the four one-sided stencils of the digital-diffeomorphism check
- Displacement: folded pixels
- –
- Displacement: inverse error
- –
- SVF: folded pixels
- –
- SVF: inverse error
- –
Folded pixels: central difference / digital-diffeomorphism check. Inverse error: mean residual of φ−1∘φ in pixels, using the naive inverse id − v for the displacement and exp(−v) for the SVF.
What you are looking at
A displacement model uses the network output directly: each pixel moves by v(x). It is simple and fast, but nothing stops neighbouring pixels from crossing. Where the field changes faster than the pixel spacing, the transformation folds, |J| becomes negative and the anatomy tears.
A stationary velocity field treats v as a velocity and integrates it: φ = exp(v). Scaling and squaring computes this with N compositions of a tiny step v/2N. Each small step is close to invertible, compositions of invertible maps stay invertible, and the inverse is simply exp(−v). Set the steps to 0 and the SVF reduces to the displacement; at 4–7 steps folding disappears.
Counting folds is itself subtle. The usual central-difference |J| can be positive even where the digital transformation folds. In Liu, Chen et al., IJCV 2024 we showed that in 2D four one-sided finite-difference determinants must all be positive (ten in 3D). Yellow pixels are folds that only this check finds.
The same choice in MIR
Every MIR model takes (moving, fixed) and returns a field; the transformation model is one argument away.
from MIR.models import VFA, SpatialTransformer
from MIR.models.registration_utils import VecInt
import MIR.models.configs_VFA as configs_VFA
cfg = configs_VFA.get_VFA_default_config(); cfg.img_size = (H, W)
disp_model = VFA(cfg, device='cuda') # phi = id + v
svf_model = VFA(cfg, device='cuda', SVF=True) # phi = exp(v), 7 steps
# or integrate any field yourself
flow = VecInt((H, W), nsteps=7)(velocity)
warped = SpatialTransformer((H, W))(moving, flow)
# 3D folding metrics, incl. the digital-diffeomorphism criteria
from MIR.accuracy_measures import digital_diffeomorphism- MIR guide: transformation models (displacement, SVF, time-varying fields, symmetric, LDDMM)
- MIR on GitHub · digital diffeomorphism code
This demo runs no network: the field is what you draw. The JavaScript mirrors MIR's VecInt and SpatialTransformer (bilinear, zero padding). Image: IXI (CC BY-SA 3.0).