Note
Go to the end to download the full example code.
3D Variable Flip Angle (non-linear)#
This example illustrates motion correction of a 3D time series with variable flip angles (VFA). The motion correction is performed with 3D coregistration and a non-linear signal model fit.
Import packages and load data#
Signal model#
The signal data are acquired using a spoiled gradient-echo sequence in the steady-state, with different flip angles:
\(S(\phi)=S_0\sin{\phi} \frac{1-e^{-T_R/T_1}}{1-\cos{\phi}\,e^{-T_R/T_1}}\)
Here \(S(\phi)\) is the signal at flip angle \(\phi\), \(S_0\) a scaling factor, \(T_R\) the repetition time and \(T_1\) the longitudinal relaxation time.
Defining the following constant in the range [0,1]:
\(E=e^{-T_R/T_1}\)
The signal model can be written as:
\(S(\phi) = S_0\sin{\phi} \frac{1-E}{1-\cos{\phi}\,E}\)
Perform motion correction#
The signal model above is included in mdreg
as the function
mdreg.spgr_vfa_nonlin
, which requires the flip angle (FA) in degrees as
input:
For this example we will use a coarse deformation field with grid spacing 50mm:
coreg_params = {
'spacing': spacing,
'FinalGridSpacingInPhysicalUnits': 50.0,
}
We can now perform the motion correction:
Visualize the results#
We visualise the original data and results of the computation using the
builtin mdreg.animation
function. Since we want to call this 3 times,
we define the settings up front:
plot_settings = {
'interval' : 500, # Time between animation frames in ms
'vmin' : 0, # Minimum value of the colorbar
'vmax' : np.percentile(array,99), # Maximum value of the colorbar
'show' : True, # Display the animation on screen
}
Now we can plot the data, coregistered images and model fits separately:
anim = mdreg.animation(array, title='Original data', **plot_settings)
anim = mdreg.animation(coreg, title='Motion corrected', **plot_settings)
anim = mdreg.animation(fit, title='Model fit', **plot_settings)
It’s also instructive to show the deformation field and check whether deformations are consistent with the effect of breathing motion. Since the deformation field is a vector we show here its norm:
# Get the norm of the deformation field and adjust the plot settings
defo = mdreg.defo_norm(defo)
plot_settings['vmax'] = np.percentile(defo, 99)
# Display the norm of the deformation field
anim = mdreg.animation(defo, title='Deformation field', **plot_settings)
#
#
Total running time of the script: (70 minutes 7.519 seconds)