tools.register_nonrigid

tools.register_nonrigid#

bartorch.tools.register_nonrigid()#

Displacement field from reference into moved, by greedy SyN or TV-L1 optical flow.

Magnitudes are registered. BART’s estmotion.

Parameters:
  • reference (torch.Tensor) – Images of the same shape, at most eight axes.

  • moved (torch.Tensor) – Images of the same shape, at most eight axes.

  • axes (int or tuple of int) – Axes to register along.

  • levels (int, default=None) – Gaussian pyramid levels, one to five; BART’s default is three.

  • optical_flow (bool, default=False) – TV-L1 optical flow instead of greedy SyN.

  • tv_weight (float, default=None) – TV regularization of the optical flow; BART’s default is 0.01.

  • max_flow (float, default=None) – Bound on the flow magnitude of the optical flow.

Returns:

  • field (torch.Tensor) – Real, shape (*reference.shape, len(axes)); component i is the displacement in voxels along axes[i], such that moved(p + field[p]) ≈ reference(p). What bartorch.tools.warp() takes: warp(moved, field, axes) resamples moved onto reference.

  • inverse_field (torch.Tensor or None) – Same layout, reference(p + inverse_field[p]) ≈ moved(p); None with optical_flow, for which BART computes no inverse.

Raises:

ValueError – If the images differ in shape or have more than eight axes, levels is outside one to five, or tv_weight or max_flow is given without optical_flow.