DTI#
Diffusion tensor imaging (DTI) describes the diffusion in each voxel with a 3x3 tensor D, fitted to the log signal, log(S) = log(S0) - b g^T D g (Basser et al. 1994). Its eigenvalues give the fractional anisotropy (FA) and the mean, axial and radial diffusivities (MD, AD, RD), and its first eigenvector the principal direction of diffusion. Citing lists the papers, and Conventions the units and the tensor’s element order.
The data on this page
The examples on this page run on a small synthetic image, written to the current folder by the code below:
dwi.nii.gz with its gradient files dwi.bval and dwi.bvec, and a mask, mask.nii.gz. It has 12 x 12 x 2
voxels of 2 mm, two b=0 images and 30 directions at each of b=1000 and 2000 s/mm^2. Two bundles cross in its
middle, one along x and one along y; the other voxels hold isotropic diffusion. To use your own data, use your
files instead.
import numpy as np
from larmor.io import save_volume, write_bvals_bvecs
from larmor.sd import AnisotropicRF
from larmor.types import GradientTable, Volume
rng = np.random.default_rng(0)
directions = rng.normal(size=(60, 3))
directions /= np.linalg.norm(directions, axis=1, keepdims=True)
bvals = np.r_[0, 0, [1000] * 30, [2000] * 30]
bvecs = np.r_[np.zeros((2, 3)), directions]
gtab = GradientTable(bvals, bvecs)
fibre = AnisotropicRF([1.7e-3, 0.3e-3, 0.3e-3], mean_kurtosis=0.5)
along_x, along_y = fibre.signal(bvals, gtab.bvecs, np.eye(3)[:2]).T
isotropic = np.exp(-bvals * 0.8e-3)
signal = np.broadcast_to(isotropic, (12, 12, 2, len(bvals))).copy()
signal[:, 4:8] = along_x
signal[4:8, :] = along_y
signal[4:8, 4:8] = (along_x + along_y) / 2
data = 1000 * signal + rng.normal(0, 10, signal.shape)
affine = np.diag([2.0, 2.0, 2.0, 1.0])
save_volume(Volume(data.astype(np.float32), affine), "dwi.nii.gz")
write_bvals_bvecs(gtab, "dwi.bval", "dwi.bvec", ref_path="dwi.nii.gz")
save_volume(Volume(np.ones((12, 12, 2), np.uint8), affine), "mask.nii.gz")
Fitting the tensor#
from larmor.dwi import DTIModel
from larmor.io import load_dwi, load_volume, save_volume
dwi, gtab = load_dwi("dwi.nii.gz", "dwi.bval", "dwi.bvec")
mask = load_volume("mask.nii.gz")
fit = DTIModel().fit(dwi, gtab, mask=mask)
save_volume(dwi.with_data(fit.fa), "fa.nii.gz")
save_volume(dwi.with_data(fit.md), "md.nii.gz")
print(f"FA in the bundles: {fit.fa[0, 5, 0]:.2f}, elsewhere: {fit.fa[0, 0, 0]:.2f}")
The result, a DTIFit, holds the maps as arrays on the image’s grid, zero outside the mask:
fa, md, ad, rd, the principal eigenvector pe, the eigenvalues eigen_vals and the tensor dt (its six
elements xx, xy, xz, yy, yz, zz). Diffusivities are in mm^2/s for b-values in s/mm^2.
lar dti dwi.nii.gz dti --bvals dwi.bval --bvecs dwi.bvec -m mask.nii.gz
The second argument is a prefix: the command writes dti_fa.nii.gz, dti_md.nii.gz, dti_ad.nii.gz,
dti_rd.nii.gz and dti_pe.nii.gz, the principal eigenvector. Diffusivities are in mm^2/s for b-values in
s/mm^2.
Options#
Fit method. Ordinary least squares by default; weighted least squares, with weights from the predicted signal, with
DTIModel(fit_method="wls")or--fit wls(Veraart et al. 2013).Mask. Voxels outside the mask are not fitted. Without one, a brain mask is computed from the mean b=0 image, as
create_brain_mask()andlar maskcompute it.Shells. The fit needs at least two distinct b-values. To fit one shell of a multi-shell acquisition, keep its volumes first, as in Gradient tables and shells.
Threads. The voxels are fitted in parallel on every core;
n_jobsin Python and--nton the command line set the number of threads. The result does not depend on it.
Viewing the maps#
lar bv -v dti_fa.nii.gz -v dti_pe.nii.gz
The viewer can draw the principal eigenvector as direction colours, modulated by FA; see DTI colours in the viewer.
See also#
Gallery: Fitting DTI to a synthetic tensor, DTI of a simulated brain.
Command:
lar dti.
References#
Basser PJ, Mattiello J, LeBihan D. Estimation of the effective self-diffusion tensor from the NMR spin echo. J Magn Reson B 103 (1994) 247-254.
Veraart J, Sijbers J, Sunaert S, Leemans A, Jeurissen B. Weighted linear least squares estimation of diffusion MRI parameters: strengths, limitations, and pitfalls. NeuroImage 81 (2013) 335-346.