Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, im_size, grid_size=None, numpoints=6, n_shift=None,
table_oversamp=2**10, kbwidth=2.34, order=0, norm='None',
coil_broadcast=False, matadj=False):
super(KbNufftModule, self).__init__()
self.im_size = im_size
if grid_size is None:
self.grid_size = tuple(np.array(self.im_size) * 2)
else:
self.grid_size = grid_size
if n_shift is None:
self.n_shift = tuple(np.array(self.im_size) // 2)
else:
self.n_shift = n_shift
if isinstance(numpoints, int):
self.numpoints = (numpoints,) * len(self.grid_size)
else:
self.numpoints = numpoints
self.alpha = tuple(np.array(kbwidth) * np.array(self.numpoints))
if isinstance(order, int) or isinstance(order, float):
'real_interp_mats' and 'imag_interp_mats', each key containing
a list of interpolation matrices (see
mri.sparse_interp_mat.precomp_sparse_mats for construction).
If None, then a standard interpolation is run.
Returns:
tensor: x computed at off-grid locations in om.
"""
interpob = self._extract_nufft_interpob()
y = KbNufftFunction.apply(x, om, interpob, interp_mats)
return y
class AdjKbNufft(KbNufftModule):
"""Non-uniform FFT adjoint PyTorch module.
This object interpolates off-grid Fourier data to on-grid locations
using a Kaiser-Bessel kernel prior to inverse DFT. It is implemented as a
PyTorch module.
Args:
im_size (int or tuple of ints): Size of base image.
grid_size (int or tuple of ints, default=2*im_size): Size of the grid
to interpolate to.
numpoints (int or tuple of ints, default=6): Number of points to use
for interpolation in each dimension. Default is six points in each
direction.
n_shift (int or tuple of ints, default=im_size//2): Number of points to
shift for fftshifts.
table_oversamp (int, default=2^10): Table oversampling factor.
interpob['table'] = []
for i in range(len(self.table)):
interpob['table'].append(getattr(self, 'table_tensor_' + str(i)))
interpob['n_shift'] = self.n_shift_tensor
interpob['grid_size'] = self.grid_size_tensor
interpob['im_size'] = self.im_size_tensor
interpob['numpoints'] = self.numpoints_tensor
interpob['table_oversamp'] = self.table_oversamp_tensor
interpob['norm'] = self.norm
interpob['coil_broadcast'] = self.coil_broadcast
interpob['matadj'] = self.matadj
return interpob
class KbNufft(KbNufftModule):
"""Non-uniform FFT forward PyTorch module.
This object applies the FFT and interpolates a grid of Fourier data to
off-grid locations using a Kaiser-Bessel kernel. It is implemented as a
PyTorch module.
Args:
im_size (int or tuple of ints): Size of base image.
grid_size (int or tuple of ints, default=2*im_size): Size of the grid
to interpolate from.
numpoints (int or tuple of ints, default=6): Number of points to use
for interpolation in each dimension. Default is six points in each
direction.
n_shift (int or tuple of ints, default=im_size//2): Number of points to
shift for fftshifts.
table_oversamp (int, default=2^10): Table oversampling factor.