apply_girf#

mrinufft.trajectories.apply_girf(*, girf: NDArray, freqs: NDArray, gradients: NDArray | None = None, trajectory: NDArray | None = None, acq: Acquisition | None = None, girf_affine: NDArray | None = None, delay: float = 0.0, t_start: float = -0.001) → tuple[NDArray, NDArray][source]#

Predict the encoding actually played, using a GIRF.

Exactly one of gradients or trajectory must be provided. The gradients or trajectory played are returned in the same form as the input, along with the deviations of all the field terms from the nominal encoding. These are expanded on spherical harmonics in the frame of the image: on its axes, in m, from its voxel acq.img_size // 2. See Gradient Impulse Response Function (GIRF) for the model and its conventions.

Parameters:
  • girf (NDArray) – Gradient impulse response function, with shape (3, n_terms, n_freqs): girf[i, j] is the transfer function from the gradient axis i to the field term j, given by spherical_harmonics(). n_terms is 4, 9 or 16, for complete orders up to 1, 2 or 3.

  • freqs (NDArray) – Frequencies of girf in Hz, uniformly spaced from 0. The response is taken as zero above freqs[-1].

  • gradients (NDArray, optional) – Nominal gradients in T/m on the axes of the image, with shape (n_shots, n_samples, dim), dim being 2 or 3.

  • trajectory (NDArray, optional) – Nominal normalized trajectory, with shape (n_shots, n_samples, dim).

  • acq (Acquisition, optional) – Acquisition configuration, providing the sampling interval of the inputs (acq.raster_time), the gyromagnetic ratio, the normalization of trajectory, and the position and orientation of the image (acq.affine). If None, the default acquisition is used.

  • girf_affine (NDArray, optional) – Affine (4, 4) from the physical coordinates of acq.affine to the coordinates of the GIRF: the axes of the gradient coils, from the origin of the field measurement. If None, they are the same.

  • delay (float, optional) – Extra delay applied to the responses, in s. The default is 0.

  • t_start (float, optional) – Time in s at which the impulse responses start, in (-1/df, 0] with df the step of freqs. They are taken as zero outside of [t_start, t_start + 1/df). The default is -1 ms.

Returns:

  • gradients (NDArray) – If gradients is provided, the gradients played at the centre of the image in T/m, with the same shape and axes as the input.

  • trajectory (NDArray) – If trajectory is provided, the normalized trajectory played, wrapped into [-acq.norm_factor, acq.norm_factor), with the same shape and axes as the input.

  • fields (NDArray) – Deviations of the field terms from the nominal encoding, in T/m^l for a term of order l, at the gradient raster: shape (n_shots, n_samples, n_terms) for gradients, and (n_shots, n_samples - 1, n_terms), between the samples, for trajectory.

Raises:

ValueError – If none or both of gradients and trajectory are provided, if girf and freqs are inconsistent, if t_start is out of range, or if the affines are not rigid.

Return type:

tuple[NDArray, NDArray]

Notes

The data are compensated for the phase accrued by the zeroth order, and the higher orders are included in the reconstruction with mrinufft.extras.compute_girf_interpolators(). Gradients are taken as zero outside of the input: as the response to the pre-phasers leaks into the readout, they should be included in the input and cropped from the output.

Example using apply_girf:#

GIRF-based correction of the encoding

GIRF-based correction of the encoding