MRITorchKbNufft#

class mrinufft.operators.interfaces.torchkbnufft.MRITorchKbNufft(samples, shape, density=False, n_coils=1, n_batchs=1, smaps=None, eps=1e-06, squeeze_dims=True, use_gpu=False, osf=2, **kwargs)[source]#

Bases: FourierOperatorBase

MRI Transform Operator using Torch NUFFT.

This class provides a Non-Uniform Fast Fourier Transform (NUFFT) operator for MRI data, utilizing the torchkbnufft library for performing the computations. It supports both CPU and GPU computations.

Parameters:
  • samples (Tensor) – The sample locations of shape Nsamples x N_dimensions. It should be C-contiguous.

  • shape (tuple) – Shape of the image space.

  • density (bool or Tensor, optional) – Density compensation support. Default is False. - If a Tensor, it will be used for density. - If True, the density compensation will be automatically estimated using the fixed point method (“pipe”). - If False, density compensation will not be used.

  • n_coils (int, optional) – Number of coils. Default is 1.

  • n_batchs (int, optional) – Number of batches. Default is 1.

  • smaps (Tensor, optional) – Sensitivity maps. Default is None.

  • eps (float, optional) – A small epsilon value for numerical stability. Default is 1e-6.

  • squeeze_dims (bool, optional) – If True, tries to remove singleton dimensions for batch and coils. Default is True.

  • use_gpu (bool, optional) – Whether to use the GPU. Default is False.

  • osf (int, optional) – Oversampling factor. Default is 2.

  • **kwargs (dict) – Additional keyword arguments.

Methods

__init__

adj_op

Backward Operation.

cg

Conjugate Gradient method to solve the inverse problem.

check_shape

Validate the shapes of the image or k-space data against operator shapes.

compute_density

Compute the density compensation weights and set it.

compute_smaps

Compute the sensitivity maps and set it.

data_consistency

Compute the data consistency.

get_lipschitz_cst

Return the Lipschitz constant of the operator.

make_autograd

Make a new Operator with autodiff support.

op

Forward operation.

pipe

Compute the density compensation weights for a given set of kspace locations.

with_autograd

Return a Fourier operator with autograd capabilities.

with_off_resonance_correction

Return a new operator with Off Resonnance Correction.

Attributes

autograd_available

available

cpx_dtype

Return complex floating precision of the operator.

density

Density compensation of the operator.

dtype

Return floating precision of the operator.

interfaces

n_batchs

Number of coils for the operator.

n_coils

Number of coils for the operator.

n_samples

Return the number of samples used by the operator.

ndim

Number of dimensions in image space of the operator.

norm_factor

Normalization factor of the operator.

samples

Return the samples used by the operator.

shape

Shape of the image space of the operator.

smaps

Sensitivity maps of the operator.

uses_density

Return True if the operator uses density compensation.

uses_sense

Return True if the operator uses sensitivity maps.

backend

op(data, out=None)[source]#

Forward operation.

Parameters:

data (Tensor)

Returns:

Tensor

Return type:

Non-uniform Fourier transform of the input image.

Note

This function uses torch internally, and will convert all its array argument to torch tensors, but will respect the device they are allocated on. The outputs will be converted back to the original array module and device.

adj_op(coeffs, out=None)[source]#

Backward Operation.

Parameters:

coeffs (Tensor)

Return type:

Tensor

Note

This function uses torch internally, and will convert all its array argument to torch tensors, but will respect the device they are allocated on. The outputs will be converted back to the original array module and device.

data_consistency(data, obs_data)[source]#

Compute the data consistency.

Parameters:
  • data (Tensor) – Image data

  • obs_data (Tensor) – Observed data

Returns:

The data consistency error in image space.

Return type:

Tensor

Note

This function uses torch internally, and will convert all its array argument to torch tensors, but will respect the device they are allocated on. The outputs will be converted back to the original array module and device.

classmethod pipe(kspace_loc, volume_shape, num_iterations=10, osf=2, normalize=True, use_gpu=False, **kwargs)[source]#

Compute the density compensation weights for a given set of kspace locations.

Parameters:
  • kspace_loc (Tensor) – the kspace locations

  • volume_shape (tuple) – the volume shape

  • num_iterations (int default 10) – the number of iterations for density estimation

  • osf (float or int) – The oversampling factor the volume shape

  • normalize (bool) – Whether to normalize the density compensation. We normalize such that the energy of PSF = 1

  • use_gpu (bool, default False) – Whether to use the GPU

Note

This function uses torch internally, and will convert all its array argument to torch tensors, but will respect the device they are allocated on. The outputs will be converted back to the original array module and device.