Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def forward(ctx, y, om, interpob, interp_mats=None):
"""Apply NUFFT adjoint.
This function wraps ifft_and_scale_on_gridded_data and AdjKbInterpFunction
for PyTorch autograd.
"""
x = AdjKbInterpFunction.apply(y, om, interpob, interp_mats)
scaling_coef = interpob['scaling_coef']
grid_size = interpob['grid_size']
im_size = interpob['im_size']
norm = interpob['norm']
x = ifft_and_scale_on_gridded_data(
x, scaling_coef, grid_size, im_size, norm)
ctx.save_for_backward(om)
ctx.interpob = interpob
ctx.interp_mats = interp_mats
return x
This function wraps ifft_and_scale_on_gridded_data and AdjKbInterpFunction
for PyTorch autograd.
"""
om, = ctx.saved_tensors
interpob = ctx.interpob
interp_mats = ctx.interp_mats
scaling_coef = interpob['scaling_coef']
grid_size = interpob['grid_size']
im_size = interpob['im_size']
norm = interpob['norm']
interp_mats = ctx.interp_mats
x = AdjKbInterpFunction.apply(y, om, interpob, interp_mats)
x = ifft_and_scale_on_gridded_data(
x, scaling_coef, grid_size, im_size, norm)
return x, None, None, None
Args:
y (tensor): The off-grid k-space data.
om (tensor, optional): A new set of omega coordinates to
interpolate from in radians/voxel.
interp_mats (dict, default=None): A dictionary with keys
'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: The DFT of the signal.
"""
interpob = self._extract_interpob()
x = AdjKbInterpFunction.apply(y, om, interpob, interp_mats)
return x