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, smap, im_size, grid_size=None, numpoints=6, n_shift=None,
table_oversamp=2**10, kbwidth=2.34, order=0, norm='None',
coil_broadcast=False, coilpack=False, matadj=False):
super(SenseNufftModule, 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):
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['coilpack'] = self.coilpack
interpob['matadj'] = self.matadj
return interpob
class MriSenseNufft(SenseNufftModule):
"""Non-uniform FFT forward PyTorch module with SENSE.
This object multiplies sensitivity coils and then applies a Kaiser-Bessel
kernel NUFFT. It is implemented as a PyTorch module.
Args:
smap (tensor): Sensitivity coils of size (batch_size, real/imag,) +
im_size.
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.
instead of the one used on layer initialization.
Returns:
tensor: x computed at off-grid locations in om.
"""
interpob = self._extract_sense_interpob()
if smap is None:
smap = self.smap_tensor
y = MriSenseNufftFunction.apply(x, smap, om, interpob, interp_mats)
return y
class AdjMriSenseNufft(SenseNufftModule):
"""Non-uniform FFT adjoint PyTorch module with SENSE.
This object applies a NUFFT adjoint, then a SENSE adjoint.
Args:
smap (tensor): Sensitivity coils of size (batch_size, real/imag,) +
im_size.
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.