mri.operators.fourier.utils.processing#

Common tools for MRI image reconstruction.

convert_mask_to_locations(mask)[source]#

Return the converted Cartesian mask as sampling locations.

Parameters

mask (numpy.ndarray, {0,1}) – ND matrix, not necessarly a square matrix.

Returns

samples_locations – samples location between [-0.5, 0.5[ of shape MxN where M is the number of 1 values in the mask.

Return type

numpy.ndarray

convert_locations_to_mask(samples_locations, img_shape)[source]#

Return the converted the sampling locations as Cartesian mask.

Parameters
  • samples_locations (numpy.ndarray) – samples locations between [-0.5, 0.5[.

  • img_shape (tuple of int) – shape of the desired mask, not necessarly a square matrix.

Returns

mask – 2D matrix, not necessarly a square matrix.

Return type

numpy.ndarray, {0,1}

normalize_frequency_locations(samples, Kmax=None)[source]#

This function normalizes the sample locations between [-0.5; 0.5[ for the non-Cartesian case.

Parameters
  • samples (numpy.ndarray) – Unnormalized samples

  • Kmax (int, float, array-like or None) – Maximum Frequency of the samples locations is supposed to be equal to base Resolution / (2* Field of View)

Returns

normalized_samples – Same shape as the parameters but with values between [-0.5; 0.5[

Return type

numpy.ndarray

discard_frequency_outliers(kspace_loc, kspace_data)[source]#

This function discards the samples outside [-0.5; 0.5[ for the non-Cartesian case.

Parameters
  • kspace_loc (numpy.ndarray) – The sample locations previously normalized around [-0.5; 0.5[ using Kmax.

  • kspace_data (numpy.ndarray) – The samples corresponding to kspace_loc defined above.

Returns

  • reduced_kspace_loc (numpy.ndarray) – The sample locations reduced strictly to [-0.5; 0.5[ by discarding outliers.

  • reduced_kspace_data (numpy.ndarray) – The samples corresponding to reduced_kspace_loc defined above.

gridded_inverse_fourier_transform_nd(kspace_loc, kspace_data, grid, method)[source]#

This function calculates the gridded Inverse fourier transform from Interpolated non-Cartesian data into a cartesian grid

Parameters
  • kspace_loc (numpy.ndarray) – The N-D k_space locations of size [M, N]

  • kspace_data (numpy.ndarray) – The k-space data corresponding to k-space_loc above

  • grid (numpy.ndarray) – The Gridded matrix for which you want to calculate k_space Smaps

  • method ({'linear', 'nearest', 'cubic'}) – Method of interpolation for more details see scipy.interpolate.griddata documentation

Returns

The gridded inverse fourier transform of given kspace data

Return type

np.ndarray

gridded_inverse_fourier_transform_stack(kspace_data_sorted, kspace_plane_loc, idx_mask_z, grid, volume_shape, method)[source]#

This function calculates the gridded Inverse fourier transform from Interpolated non-Cartesian data into a cartesian grid. However, the IFFT is done similar to Stacked Fourier transform. We expect the kspace data to be limited to a grid on z, we calculate the inverse fourier transform by- 1) Grid data in each plane (for all points in a plane) 2) Interpolate data along z, if we have undersampled data along z 3) Apply an IFFT on the 3D data that was gridded and interpolated in z.

Parameters
  • kspace_data_sorted (numpy.ndarray) – The sorted k-space data corresponding to kspace_plane_loc above

  • kspace_plane_loc (numpy.ndarray) – The N-D k_space locations of size [M, N]. These hold locations only in plane, extracted using get_stacks_fourier function

  • idx_mask_z (numpy.ndarray) – contains the indices of the acquired Fourier plane. Extracted using get_stacks_fourier function

  • grid (tuple) – The Gridded matrix for which you want to calculate k_space Smaps. Should be given as a tuple of ndarray

  • volume_shape (tuple) – Reconstructed volume shape

  • method ({'linear', 'nearest', 'cubic'}, optional) – Method of interpolation for more details see scipy.interpolate.griddata documentation

Returns

The gridded inverse fourier transform of given kspace data

Return type

np.ndarray

check_if_fourier_op_uses_sense(fourier_op)[source]#

Utils function to check if fourier operator uses SENSE recon

Parameters
  • fourier_op (object of class FFT, NonCartesianFFT or Stacked3DNFFT in) –

  • mri.operators – the fourier operator for which we want to check if SENSE is supported

Returns

True if SENSE recon is being used

Return type

bool

estimate_density_compensation(kspace_loc, volume_shape, implementation='pipe', **kwargs)[source]#

Utils function to obtain the density compensator for a given set of kspace locations.

Parameters
  • kspace_loc (numpy.ndarray) – the kspace locations

  • volume_shape (numpy.ndarray) – the volume shape

  • implementation (str default 'pipe') – the implementation of the non-cartesian operator can be ‘pipe’ which needs gpuNUFFT or ‘cell_count’

  • kwargs (dict) – extra keyword arguments to be passed to the density compensation estimation