Gradient Impulse Response Function (GIRF)#

In MR systems, the gradient system has imperfections that can make the effective k-space trajectories differ from the prescribed ones.

The fields played by the gradient chain differ from the nominal gradients: the amplifiers and coils have a limited bandwidth, eddy currents oppose fast changes, and each gradient coil also produces B0 and higher-order spatial terms. For non-Cartesian trajectories, reconstructing with the nominal k-space positions then causes blurring, shading or ghosting.

These imperfections are typically modeled as a linear time-invariant (LTI) system, characterized by the gradient impulse response function (GIRF) [Van13] [Add12].

Note

In mri-nufft, the GIRF can be read and applied with the following functions:

Tip

See the example GIRF-based correction of the encoding for a complete reconstruction.

Model#

Field terms#

During the acquisition, the longitudinal field departs from the main field \(B_0\) by

\[B(\boldsymbol{r}, t) = \Delta B_0(\boldsymbol{r}) + \sum_j b_j(t) P_j(\boldsymbol{r}),\]

where \(\boldsymbol{r} = (x, y, z)\) is the position on the axes of the GIRF (the axes of the gradient coils), relative to its origin (usually the isocentre).

  • \(\Delta B_0(\boldsymbol{r})\) is the static off-resonance, due to the magnetic susceptibility of the object and to the shim. It depends on the object, is measured with a field map, and is not described by the GIRF.

  • \(b_j(t) P_j(\boldsymbol{r})\) are the dynamic terms produced by the gradient chain, expanded on real spherical harmonics. They include the nominal gradients, and the GIRF predicts them from the gradients played. The B0 term \(j = 0\) is the dynamic part only, e.g. from eddy currents.

The terms follow the order and the unnormalized polynomials of the Skope field cameras (spherical_harmonics()), with \(r^2 = x^2 + y^2 + z^2\):

Terms

Order

\(P_j(\boldsymbol{r})\)

Unit of girf

0

0

\(1\)

m

1 - 3

1

\(x,\ y,\ z\)

1

4 - 8

2

\(xy,\ zy,\ 3z^2 - r^2,\ xz,\ x^2 - y^2\)

1/m

9 - 15

3

\(3yx^2 - y^3,\ xyz,\ 5yz^2 - yr^2,\ 5z^3 - 3zr^2,\) \(5xz^2 - xr^2,\ zx^2 - zy^2,\ x^3 - 3xy^2\)

1/m2

These polynomials are harmonic, and the terms up to a given order span all the harmonic polynomials up to that degree. apply_girf() handles complete orders: 4, 9 or 16 terms.

Transfer functions#

Each term responds linearly to the nominal gradients \(g_x, g_y, g_z\) on the axes of the GIRF,

\[b_j(t) = \sum_{i \in \{x, y, z\}} (h_{ij} * g_i)(t), \quad \text{with} \quad \mathrm{girf}[i, j](f) = \int h_{ij}(t)\, e^{-2\imath\pi f t}\, dt.\]

The self terms \(h_{xx}, h_{yy}, h_{zz}\) are close to a low-pass filter with a unit gain at 0 Hz, and the other terms are small. As the impulse responses are real, girf is stored for positive frequencies only.

Frames and affines#

GIRF coefficients are expressed in the axes of the scanner gradients. However, the reconstructed image may have a different position and orientation. The change of coordinates between the two frames is handled by the affine transform matrix. In MRI-NUFFT, this is handled in the Acquisition class: acq.affine maps the voxel indices to physical coordinates, as given by the raw data or a NIfTI header, and acq.fov / acq.img_size hold the size and resolution of the image.

When applying the GIRF, this is taken into account through the girf_affine argument of mrinufft.trajectories.apply_girf().

Note

The change of coordinates is a rigid transform: \(\boldsymbol{r} = R\boldsymbol{u} + \boldsymbol{r}_0\), with \(\boldsymbol{r}_0\) the centre of the image in the frame of the GIRF.

The nominal gradients, given on the image axes, are rotated by \(R\) to predict the fields, which are then expanded again in the frame of the image,

\[\sum_j b_j(t) P_j(R\boldsymbol{u} + \boldsymbol{r}_0) = \sum_j b'_j(t) P_j(\boldsymbol{u}).\]
Computing \(b_j'\) in closed form

A term of order \(l\) is a symmetric tensor \(T_j\) of rank \(l\) applied to the position,

\[P_j(\boldsymbol{r}) = T_j[\boldsymbol{r}, \dots, \boldsymbol{r}] = \sum_{i_1, \dots, i_l} T_{j, i_1 \dots i_l}\, r_{i_1} \cdots r_{i_l},\]

e.g. \(xz = \boldsymbol{r}^\top T \boldsymbol{r}\) with \(T_{xz} = T_{zx} = 1/2\) and zeros elsewhere. The polynomial is harmonic if and only if the tensor is traceless. As \(T_j\) is symmetric, the binomial theorem gives

\[P_j(R\boldsymbol{u} + \boldsymbol{r}_0) = \sum_{k=0}^{l} \binom{l}{k}\, T_j[\underbrace{\boldsymbol{r}_0, \dots, \boldsymbol{r}_0}_{l - k}, R\boldsymbol{u}, \dots, R\boldsymbol{u}].\]

The part of degree \(k\) in \(\boldsymbol{u}\) is the tensor \(T_j\) contracted \(l - k\) times with \(\boldsymbol{r}_0\), with its remaining indices contracted with \(R\). Both operations keep the tensors symmetric and traceless, so that each degree remains harmonic, and the \(b'_j\) are the coefficients of these tensors on the \(T_j\) of their order. Up to the second order, with \(\boldsymbol{g} = (b_x, b_y, b_z)\) and

\[\begin{split}Q = \begin{pmatrix} b_{x^2 - y^2} - b_{3z^2 - r^2} & b_{xy}/2 & b_{xz}/2 \\ b_{xy}/2 & -b_{x^2 - y^2} - b_{3z^2 - r^2} & b_{zy}/2 \\ b_{xz}/2 & b_{zy}/2 & 2 b_{3z^2 - r^2} \end{pmatrix},\end{split}\]

and \(\boldsymbol{g}', Q'\) built in the same way from the \(b'_j\),

\[b'_0 = b_0 + \boldsymbol{g} \cdot \boldsymbol{r}_0 + \boldsymbol{r}_0^\top Q\, \boldsymbol{r}_0, \qquad \boldsymbol{g}' = R^\top (\boldsymbol{g} + 2 Q\, \boldsymbol{r}_0), \qquad Q' = R^\top Q R.\]

The rotation keeps the orders, and the translation moves each order to the lower ones, with a factor \(r_0^{l - k}\). For instance, the \(xz\) term of a slice at \(z_0\) adds \(z_0 x\) to the gradient along \(x\), and \(3z^2 - r^2\) a phase in \(z_0^2\). This holds for reflections too.

In homogeneous coordinates, \(R\boldsymbol{u} + \boldsymbol{r}_0 = A\tilde{\boldsymbol{u}}\), with \(A = [R \mid \boldsymbol{r}_0]\) the first three rows of the affine and \(\tilde{\boldsymbol{u}} = (\boldsymbol{u}, 1)\). All the degrees then follow from \(\tilde{T}_j = T_j[A, \dots, A]\), which is symmetric: the part of degree \(k\) is \(\binom{l}{k}\) times its entries whose first \(l - k\) indices are the homogeneous one.

Computing \(b_j'\) by linear regression

The relation holds for all \(\boldsymbol{u}\). Evaluating the terms at \(N \geq n_\mathrm{terms}\) random points \(\boldsymbol{u}_n\) gives the linear system

\[P(R\boldsymbol{u}_n + \boldsymbol{r}_0) = P(\boldsymbol{u}_n)\, X, \qquad \boldsymbol{b}' = X \boldsymbol{b},\]

with \(P(\boldsymbol{u}_n)\) the row of the terms at \(\boldsymbol{u}_n\). Its least-squares solution is exact up to the rounding errors, as the points are generic. It needs no tensor, and the tests use it to check the closed form.

In MRI-NUFFT we use the closed-form expression, in homogeneous coordinates (_reexpansion in mrinufft/trajectories/girf.py, used by apply_girf()).

Deviations from the nominal encoding#

apply_girf() returns the trajectory played, and the fields of the deviations of the terms from the nominal encoding, \(b'_j - b'_{j,\mathrm{nominal}}\), in T/ml for a term of order \(l\), at the gradient raster: the nominal gradients are removed from the first-order terms before expanding them in the frame of the image. The reconstruction uses the phases they accrue since the start of the waveforms,

\[\phi_j(t) = 2\pi\gamma \int_0^t (b'_j - b'_{j,\mathrm{nominal}})(\tau)\, d\tau,\]

in rad/ml. At the samples of the trajectory, between which the fields are given,

phase = 2 * np.pi * acq.gamma * acq.raster_time * np.cumsum(fields, axis=1)
phase = np.pad(phase, ((0, 0), (1, 0), (0, 0)))

Off-centre, the zeroth order thus includes \(2\pi(\boldsymbol{k} - \boldsymbol{k}_\mathrm{nominal}) \cdot \boldsymbol{r}_0\). Being relative to the nominal encoding, these corrections apply on top of however the shift of the field of view is handled for the nominal trajectory, by the sequence or by the reconstruction.

Reconstruction#

Signal model#

With the NUFFT convention of MRI-NUFFT (The NUFFT Operator), where a field offset \(b\) adds \(e^{-2\imath\pi\gamma \int b}\), the data are

\[y(t) = e^{-\imath \phi_0(t)} \int x(\boldsymbol{u})\, e^{-2\imath\pi \boldsymbol{k}(t) \cdot \boldsymbol{u}}\, e^{-\imath \psi(\boldsymbol{u}, t)}\, d\boldsymbol{u}, \quad \text{with} \quad \psi(\boldsymbol{u}, t) = \sum_{j \geq 4} \phi_j(t) P_j(\boldsymbol{u}) + 2\pi\gamma \Delta B_0(\boldsymbol{u})\, t,\]

\(\boldsymbol{k}\) being the trajectory played, and \(t\) the time from the excitation, or from the reference echo time of the field map.

Order by order#

Zeroth order: a phase of the data

\(\phi_0\) is common to all positions: multiply the data, of all the coils, by np.exp(1j * phase[..., 0]). This is exact, and needs no change of the operator. As the phase accrued during the pre-phasers differs between shots, it must be integrated from the start of the waveforms, before cropping them.

First order: the trajectory

Use the trajectory played in the NUFFT [Van16], and recompute what derives from it: density compensation, sensitivity maps (from the compensated data), and the off-resonance interpolators. The trajectory is wrapped into [-acq.norm_factor, acq.norm_factor), which is exact for a discrete image, as its spectrum is periodic. Otherwise the gain above 1 of the gradients would push samples past the normalization, and the operators would then misread their units.

Higher orders and static off-resonance: an extended model

\(e^{-\imath\psi}\) depends on both time and position: the model is not a Fourier transform anymore [Wil11]. As for the off-resonance alone (Off-resonance correction model), it is approximated by \(\sum_\ell B_\ell(t) C_\ell(\boldsymbol{u})\), given to MRIFourierCorrected with interpolator=(B, C): each application then costs \(L\) NUFFTs. Both terms are approximated together by compute_girf_interpolators(), which integrates the fields as above, from the factorization of the static off-resonance given by get_orc_factorization().

Note

MRIFourierCorrected models the off-resonance as \(e^{2\imath\pi \Delta f(\boldsymbol{u}) t}\), \(\Delta f\) being its b0_map: with the sign convention of the trajectory, a field offset \(\Delta B_0\) corresponds to \(\Delta f = -\gamma\Delta B_0\).

Factorization of the higher orders#

The higher-order terms are polynomials in the position, so that \(e^{-\imath\psi}\) has a Taylor series in closed form:

\[e^{-\imath \sum_j \phi_j(t) P_j(\boldsymbol{u})} = \sum_{\boldsymbol{\alpha}} \frac{(-\imath)^{|\boldsymbol{\alpha}|}} {\boldsymbol{\alpha}!}\, \boldsymbol{\phi}(t)^{\boldsymbol{\alpha}}\, \boldsymbol{P}(\boldsymbol{u})^{\boldsymbol{\alpha}},\]

a factorization whose time factors are products of the phase coefficients, and whose space factors are products of spherical harmonics. Truncated to an order \(n\), its error is at most \(|\psi|^{n+1} / (n + 1)!\), which is small as the expansion in the frame of the image leaves only the phase that is neither constant nor linear. Its rank, the number of products, is then reduced to \(L\) by an SVD of the small matrices relating the two sets of factors, which gives the best rank-\(L\) approximation of the series, without ever forming the \(M \times N\) matrix of the exponential. A factorization of the static off-resonance is included by taking the products of its factors with those of the compressed series, and compressing these products in the same way.

compute_girf_interpolators() chooses the order from the range of \(\psi\), and the rank from the target error tol. For a \(\psi\) of a few tenths of a radian, a rank of 6 to 8 reaches \(10^{-3}\), as the optimal SVD of the full matrix does.

Implementation#

Sampling#

Gradient sample \(n\) is held during \([n\Delta t, (n + 1)\Delta t)\), with \(\Delta t\) = acq.raster_time. Gradients are taken as zero before the first sample and after the last one, and the fields are given at the same samples as the gradients. To predict the fields at the ADC samples, use the ADC dwell time as raster_time and repeat each gradient sample accordingly.

Time window and causality#

A GIRF sampled with a frequency step \(\delta f\) only determines the impulse responses modulo a period of \(1/\delta f\). They are therefore taken as zero outside \([t_\mathrm{start}, t_\mathrm{start} + 1/\delta f)\), with \(t_\mathrm{start}\) = t_start.

The gradient chain is causal, but the measured responses start slightly before \(t = 0\): the band limit of the measurement rings on both sides of \(t = 0\), and the time reference of the measurement may be offset by a few microseconds. By default, \(t_\mathrm{start} = -1\) ms, as in the MATLAB GIRF toolbox [GIRFtb].

  • With \(t_\mathrm{start} = 0\), the ringing before \(t = 0\) is moved to the end of the period.

  • With a centred window, \(t_\mathrm{start} = -1/(2\delta f)\), half of any response slower than the window precedes its cause.

Responses slower than \(1/\delta f\) cannot be represented. In particular, a gain at 0 Hz that departs from that of the neighbouring frequencies, e.g. because of how drifts were removed during the measurement, is spread as a constant over the whole window: it adds a ramp lasting \(1/\delta f\) after each change of the gradients. The low frequencies of a GIRF are worth checking before use.

The impulse responses are sampled exactly from the frequencies of the GIRF, without interpolation when \(1/(\delta f \Delta t)\) is an integer, then zero-padded for the linear convolution. Interpolating the GIRF linearly onto a finer frequency grid instead would attenuate the slow parts of the responses.

delay adds a delay, possibly fractional, to all the responses.

Practical aspects#

Pre-phasers

The responses to the pre-phasers, and to anything played before the ADC, leak into the readout, and the phases accrued during them differ between shots. They should be included in the input, and cropped from the output after integrating the fields: the trajectory and the phases are cropped directly, and compute_girf_interpolators() takes the full fields with the number of samples to skip, skip. mrinufft.io.read_gradients() returns the full waveforms, with the number of samples before the ADC.

Noise

Above the bandwidth of the measurement, the GIRF is only noise, which makes the impulse responses long. fmax in mrinufft.io.read_girf() sets it to zero; it should stay above the bandwidth of the gradient waveforms. The higher-order terms are measured with less sensitivity, and usually need a lower cut, e.g. girf[:, 4:, freqs > 10e3] = 0.

Example#

import numpy as np

from mrinufft.extras import compute_girf_interpolators
from mrinufft.io import read_girf, read_gradients
from mrinufft.trajectories import (
    Acquisition,
    Hardware,
    apply_girf,
    convert_gradients_to_trajectory,
)

freqs, girf = read_girf("girf.mat", fmax=30e3)
gradients, initial_positions, params = read_gradients("trajectory.bin")
acq = Acquisition(
    fov=tuple(params["FOV"]),
    img_size=tuple(params["img_size"]),
    gamma=params["gamma"] * 1e3,  # kHz/T to Hz/T
    hardware=Hardware(grad_raster_time=10e-6),
    affine=affine,  # voxel indices to physical coordinates, in m
)

nominal = convert_gradients_to_trajectory(gradients, initial_positions, acq)
trajectory, fields = apply_girf(
    girf=girf, freqs=freqs, trajectory=nominal, acq=acq, girf_affine=girf_affine
)
# Phase of the zeroth order, accrued since the start of the waveforms.
phase_0 = 2 * np.pi * acq.gamma * acq.raster_time * np.cumsum(fields[..., 0], axis=1)
phase_0 = np.pad(phase_0, ((0, 0), (1, 0)))
# Drop the pre-phasers, before the ADC.
skip = params["start_skip_samples"]
trajectory, phase_0 = trajectory[:, skip:], phase_0[:, skip:]

# Compensate the zeroth order, with kspace_data of shape (n_coils, n_samples)
# sampled at the same times as the trajectory.
kspace_data = kspace_data * np.exp(1j * phase_0.ravel())

# Higher orders, from the full fields, with b0_factors the factorization of
# the static off-resonance at the samples of the ADC (get_orc_factorization).
B, C = compute_girf_interpolators(
    fields, acq, skip=skip, interpolators=b0_factors
)

See GIRF-based correction of the encoding for the higher orders and the static off-resonance.

References#

[Van13]

Vannesjo, S. J., Haeberlin, M., Kasper, L., Pavan, M., Wilm, B. J., Barmet, C., Pruessmann, K. P. “Gradient system characterization by impulse response measurements with a dynamic field camera.” Magnetic Resonance in Medicine 69.2 (2013): 583-593. https://doi.org/10.1002/mrm.24263

[Add12]

Addy, N. O., Wu, H. H., Nishimura, D. G. “Simple method for MR gradient system characterization and k-space trajectory estimation.” Magnetic Resonance in Medicine 68.1 (2012): 120-129. https://doi.org/10.1002/mrm.23217

[Van16]

Vannesjo, S. J., Graedel, N. N., Kasper, L., Gross, S., Busch, J., Haeberlin, M., Barmet, C., Pruessmann, K. P. “Image reconstruction using a gradient impulse response model for trajectory prediction.” Magnetic Resonance in Medicine 76.1 (2016): 45-58. https://doi.org/10.1002/mrm.25841

[Wil11]

Wilm, B. J., Barmet, C., Pavan, M., Pruessmann, K. P. “Higher order reconstruction for MRI in the presence of spatiotemporal field perturbations.” Magnetic Resonance in Medicine 65.6 (2011): 1690-1701. https://doi.org/10.1002/mrm.22767

[GIRFtb]

MATLAB GIRF toolbox, GirfApplier.PredictGrad. MRI-gradient/GIRF