tools.warp

Contents

tools.warp#

bartorch.tools.warp()#

Resample input through a displacement field: out[p] = input(p + displacement[p]).

Positions and displacements are in voxels along axes; the grid is zero outside [0, n - 1]. BART’s interpolate -D.

Parameters:
  • input (torch.Tensor) – Image to resample.

  • displacement (torch.Tensor) – Real, (..., len(axes)): component i is the displacement along axes[i]. The leading shape aligns right against input.shape, equal to it along axes and one or equal elsewhere.

  • axes (int or tuple of int) – The last len(axes) axes, in any order.

  • order ({0, 1, 3}, default=1) – Nearest neighbour, linear, or Keys cubic; see bartorch.interpolate().

Returns:

The shape of input.

Return type:

torch.Tensor

Raises:

ValueError – If axes are not the trailing axes or displacement does not match input.