bartorch.interpolate

Contents

bartorch.interpolate#

bartorch.interpolate(input, coord, axes, *, order=1)#

Sample input at the voxel positions coord along axes.

out[..., q, ...] = sum_j input[..., j, ...] w(coord[q, i] - j_i) over the axes, where w is the kernel of order. Positions are array indices: coord = 2.0 is the sample input[2]. The grid is zero outside [0, n - 1], so a position within one kernel radius of the edge is weighted against zeros.

Parameters:
  • input (torch.Tensor)

  • coord (torch.Tensor) – Real positions of shape (..., len(axes)); component i of the last axis is the position along axes[i]. The leading shape is aligned right against input.shape: along each of axes it is the output size, along every other axis it is one (the positions are shared) or the input’s size. Along an axis outside the last three (bart interpolate -x sizes only BART dims 0-2) the output size must equal the input’s.

  • axes (int or tuple of int) – Axes interpolated over.

  • order ({0, 1, 3}) – Nearest neighbour (-N, rounds half up), linear, or Keys cubic with a = -1/2 (-C).

Returns:

input.shape with each of axes replaced by coord’s size there.

Return type:

torch.Tensor

Examples

>>> line = interpolate(image, torch.tensor([[1.5, 2.0]]), axes=(-2, -1))  # (1, 1)