calc_tensor_spmatrix¶
-
calc_tensor_spmatrix
(omega, im_size, grid_size=None, numpoints=6, n_shift=None, table_oversamp=1024, kbwidth=2.34, order=0.0)[source]¶ Builds a sparse matrix for interpolation.
This builds the interpolation matrices directly from scipy Kaiser-Bessel functions, so using them for a NUFFT should be a little more accurate than table interpolation.
This function has optional parameters for initializing a NUFFT object. See
KbNufft
for details.omega
should be of size(len(im_size), klength)
, whereklength
is the length of the k-space trajectory.
- Parameters
omega (
Tensor
) – k-space trajectory (in radians/voxel).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 timesim_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 – Data type for tensor buffers. Default:
torch.get_default_dtype()
device – Which device to create tensors on. Default:
torch.device('cpu')
- Return type
- Returns
2-Tuple of (real, imaginary) tensors for NUFFT interpolation.
Examples
>>> data = torch.randn(1, 1, 12) + 1j * torch.randn(1, 1, 12) >>> omega = torch.rand(2, 12) * 2 * np.pi - np.pi >>> spmats = tkbn.calc_tensor_spmatrix(omega, (8, 8)) >>> adjkb_ob = tkbn.KbNufftAdjoint(im_size=(8, 8)) >>> image = adjkb_ob(data, omega, spmats)