MIR.models.TransMorphLDDMM

class MIR.models.TransMorphLDDMM(*args, **kwargs)[source]

TransMorph with an LDDMM (time-varying velocity field) transformation model.

Parameters:
  • config – TransMorph configuration (see configs_TransMorph); config.img_size is the size of the network input.

  • param – 'shooting' (predict initial momentum, geodesic shooting) or 'tvf' (predict a velocity field at every time step, relaxation).

  • time_steps – Number of integration steps of the flow.

  • kernel – See FourierKernel. Kernel parameters are expressed in network-input voxels. Ignored when sigmas is given.

  • alpha – See FourierKernel. Kernel parameters are expressed in network-input voxels. Ignored when sigmas is given.

  • gamma – See FourierKernel. Kernel parameters are expressed in network-input voxels. Ignored when sigmas is given.

  • power – See FourierKernel. Kernel parameters are expressed in network-input voxels. Ignored when sigmas is given.

  • sigma – See FourierKernel. Kernel parameters are expressed in network-input voxels. Ignored when sigmas is given.

  • kernel_weights – See FourierKernel. Kernel parameters are expressed in network-input voxels. Ignored when sigmas is given.

  • sigmas – Gaussian standard deviations of a spatially varying kernel (region-specific LDDMM, the LDDMM counterpart of TransMorph-SPR). A small head on the decoder features predicts per-voxel kernel weights; the output dict then also contains kernel_weights and the omt penalty to add to the loss. None = stationary kernel.

  • weight_smooth_sigma – See SpatiallyVaryingKernel.

  • omt_power – See SpatiallyVaryingKernel.

  • spr – None, 'kernel' or 'energy': add the TransMorph-SPR head (sigma_0..2 convs + sigmoid, one weight map lam in (0, 1]) on the decoder features. 'kernel' maps lam to the per-voxel kernel scale of the spatially varying kernel (sigmas required, 1 = smoothest); 'energy' weights the kinetic-energy integrand by lam with a stationary kernel. The output dict then contains spr_weight for the Beta prior.

  • int_scale – Integrate the flow on a grid int_scale times finer than the network input ('shooting' only). The returned fields are at that resolution.

  • swin_type – Only 'swin' is supported.

Forward inputs:
  • inputs – Tuple (mov, fix) of tensors [B, 1, D, H, W].

  • return_dict – If True, return a dict with flow, inv_flow, energy, energies and momentum (shooting) / pre_velocities (tvf), plus kernel_weights and omt with a spatially varying kernel.

Forward outputs:

Dense displacement field [B, 3, D*int_scale, H*int_scale, W*int_scale] (or a dict).

__init__(config, param='shooting', time_steps=7, kernel='helmholtz', alpha=2.0, gamma=1.0, power=2, sigma=2.0, kernel_weights=None, sigmas=None, weight_smooth_sigma=1.0, omt_power=2.0, spr=None, int_scale=1, swin_type='swin')[source]

Methods

__init__(config[, param, time_steps, ...])

encode(mov, fix)

Shared TransMorph encoder/decoder up to the half-resolution feature map.

forward(inputs[, return_dict])

Predict the momentum (shooting) or per-step pre-velocities (tvf) and integrate the flow.

Attributes

spatially_varying

Whether self.kernel is a SpatiallyVaryingKernel.