class KbInterp(im_size, grid_size=None, numpoints=6, n_shift=None, table_oversamp=1024, kbwidth=2.34, order=0.0, dtype=None, device=None)[source]

Non-uniform Kaiser-Bessel interpolation layer.

This object interpolates a grid of Fourier data to off-grid locations using a Kaiser-Bessel kernel. Mathematically, in one dimension it estimates \(Y_m, m \in [0, ..., M-1]\) at frequency locations \(\omega_m\) from \(X_k, k \in [0, ..., K-1]\), the oversampled DFT of \(x_n, n \in [0, ..., N-1]\). To perform the estimate, this layer applies

\[Y_m = \sum_{j=1}^J X_{\{k_m+j\}_K}u^*_j(\omega_m), \]

where \(u\) is the Kaiser-Bessel kernel, \(k_m\) is the index of the root offset of nearest samples of \(X\) to frequency location \(\omega_m\), and \(J\) is the number of nearest neighbors to use from \(X_k\). Multiple dimensions are handled separably. For a detailed description of the notation see Nonuniform fast Fourier transforms using min-max interpolation (JA Fessler and BP Sutton).

When called, the parameters of this class define properties of the kernel and how the interpolation is applied.

  • im_size is the size of the base image, analagous to \(N\) (used for calculating the kernel but not for the actual operation).

  • grid_size is the size of the grid prior to interpolation, analogous to \(K\). To reduce errors, NUFFT operations are done on an oversampled grid to reduce interpolation distances. This will typically be 1.25 to 2 times im_size.

  • numpoints is the number of nearest to use for interpolation, i.e., \(J\).

  • n_shift is the FFT shift distance, typically im_size // 2.

  • im_size (Sequence[int]) – Size of image with length being the number of dimensions.

  • grid_size (Optional[Sequence[int]]) – Size of grid to use for interpolation, typically 1.25 to 2 times im_size. Default: 2 * im_size

  • numpoints (Union[int, Sequence[int]]) – Number of neighbors to use for interpolation in each dimension.

  • n_shift (Optional[Sequence[int]]) – Size for fftshift. Default: im_size // 2.

  • table_oversamp (Union[int, Sequence[int]]) – Table oversampling factor.

  • kbwidth (float) – Size of Kaiser-Bessel kernel.

  • order (Union[float, Sequence[float]]) – Order of Kaiser-Bessel kernel.

  • dtype (Optional[dtype]) – Data type for tensor buffers. Default: torch.get_default_dtype()

  • device (Optional[device]) – Which device to create tensors on. Default: torch.device('cpu')


>>> image = torch.randn(1, 1, 8, 8) + 1j * torch.randn(1, 1, 8, 8)
>>> omega = torch.rand(2, 12) * 2 * np.pi - np.pi
>>> kb_ob = tkbn.KbInterp(im_size=(8, 8), grid_size=(8, 8))
>>> data = kb_ob(image, omega)
forward(image, omega, interp_mats=None)[source]

Interpolate from gridded data to scattered data.

Input tensors should be of shape (N, C) + grid_size, where N is the batch size and C is the number of sensitivity coils. omega, the k-space trajectory, should be of size (len(grid_size), klength) or (N, len(grid_size), klength), where klength is the length of the k-space trajectory.


If the batch dimension is included in omega, the interpolator will parallelize over the batch dimension. This is efficient for many small trajectories that might occur in dynamic imaging settings.

If your tensors are real-valued, ensure that 2 is the size of the last dimension.

  • image (Tensor) – Gridded data to be interpolated to scattered data.

  • omega (Tensor) – k-space trajectory (in radians/voxel).

  • interp_mats (Optional[Tuple[Tensor, Tensor]]) – 2-tuple of real, imaginary sparse matrices to use for sparse matrix KB interpolation (overrides default table interpolation).

Return type



image calculated at Fourier frequencies specified by omega.