Classes and functions for fitting tensors
Fits a diffusion tensor given diffusion-weighted signals and gradient info
Tensor object that when initialized calculates single self diffusion tensor [R6] in each voxel using selected fitting algorithm (DEFAULT: weighted least squares [R7]) Requires a given gradient table, b value for each diffusion-weighted gradient vector, and image data given all as arrays.
Parameters : | data : array ([X, Y, Z, ...], g)
bval : array (g,)
gtab : array (g, 3)
mask : array, optional
thresh : float, default = None
fit_method : funciton or string, default = ‘WLS’
*args, **kargs : :
common fit methods: :
|
---|
See also
dipy.io.bvectxt.read_bvec_file, dipy.core.qball.ODF
Notes
Due to the fact that diffusion MRI entails large volumes (e.g. [256,256, 50,64]), memory can be an issue. Therefore, only the following parameters of the self diffusion tensor are cached for each voxel:
From these cached parameters, one can presumably construct any desired parameter.
References
[R6] | (1, 2) Basser, P.J., Mattiello, J., LeBihan, D., 1994. Estimation of the effective self-diffusion tensor from the NMR spin echo. J Magn Reson B 103, 247-254. |
[R7] | (1, 2) Basser, P., Pierpaoli, C., 1996. Microstructural and physiological features of tissues elucidated by quantitative diffusion-tensor MRI. Journal of Magnetic Resonance 111, 209-219. |
Examples
For a complete example have a look at the main dipy/examples folder
Attributes
D | |
mask | |
evals | |
evecs |
Methods
fa | |
md |
Self diffusion tensor
Returns the eigenvalues of the tensor as an array
Returns the eigenvectors of teh tensor as an array
Fractional anisotropy (FA) calculated from cached eigenvalues.
Returns : | fa : array (V, 1)
|
---|
Notes
FA is calculated with the following equation:
FA = \sqrt{\frac{1}{2}\frac{(\lambda_1-\lambda_2)^2+(\lambda_1- \lambda_3)^2+(\lambda_2-lambda_3)^2}{\lambda_1^2+ \lambda_2^2+\lambda_3^2} }
Quantizes eigenvectors with maximum eigenvalues on an evenly distributed sphere so that the can be used for tractography.
Returns : | IN : array, shape(x,y,z) integer indices for the points of the evenly distributed sphere representing tensor eigenvectors of : maximum eigenvalue : |
---|
Mean diffusitivity (MD) calculated from cached eigenvalues.
Returns : | md : array (V, 1)
|
---|
Notes
MD is calculated with the following equation:
ADC = \frac{\lambda_1+\lambda_2+\lambda_3}{3}
Returns eigenvalues and eigenvectors given a diffusion tensor
Computes tensor eigen decomposition to calculate eigenvalues and eigenvectors of self-diffusion tensor. (Basser et al., 1994a)
Parameters : | D : array (3,3)
|
---|---|
Returns : | eigvals : array (3,)
eigvecs : array (3,3)
|
See also
numpy.linalg.eig
Constructs design matrix for DTI weighted least squares or least squares fitting. (Basser et al., 1994a)
Parameters : | gtab : array with shape (3,g)
bval : array with shape (g,)
dtype : string
|
---|---|
Returns : | design_matrix : array (g,7)
|
Computes ordinary least squares (OLS) fit to calculate self-diffusion tensor using a linear regression model [1].
Parameters : | design_matrix : array (g, 7)
data : array ([X, Y, Z, ...], g)
min_signal : default = 1
|
---|---|
Returns : | eigvals : array (..., 3)
eigvecs : array (..., 3, 3)
|
See also
WLS_fit_tensor, decompose_tensor, design_matrix
Notes
This function is offered mainly as a quick comparison to WLS.
y = \mathrm{data} \\ X = \mathrm{design matrix} \\ \hat{\beta}_\mathrm{OLS} = (X^T X)^{-1} X^T y
References
[1] | (1, 2) Chung, SW., Lu, Y., Henry, R.G., 2006. Comparison of bootstrap approaches for estimation of uncertainties of DTI parameters. NeuroImage 33, 531-541. |
Find the closest orientation of an evenly distributed sphere
Parameters : | evecs : ndarray odf_vertices : None or ndarray
|
---|---|
Returns : | IN : ndarray |
Computes weighted least squares (WLS) fit to calculate self-diffusion tensor using a linear regression model [1].
Parameters : | design_matrix : array (g, 7)
data : array ([X, Y, Z, ...], g)
min_signal : default = 1
|
---|---|
Returns : | eigvals : array (..., 3)
eigvecs : array (..., 3, 3)
|
See also
Notes
In Chung, et al. 2006, the regression of the WLS fit needed an unbiased preliminary estimate of the weights and therefore the ordinary least squares (OLS) estimates were used. A “two pass” method was implemented:
- calculate OLS estimates of the data
- apply the OLS estimates as weights to the WLS fit of the data
This ensured heteroscadasticity could be properly modeled for various types of bootstrap resampling (namely residual bootstrap).
y = \mathrm{data} \\ X = \mathrm{design matrix} \\ \hat{\beta}_\mathrm{WLS} = \mathrm{desired regression coefficients (e.g. tensor)}\\ \\ \hat{\beta}_\mathrm{WLS} = (X^T W X)^{-1} X^T W y \\ \\ W = \mathrm{diag}((X \hat{\beta}_\mathrm{OLS})^2), \mathrm{where} \hat{\beta}_\mathrm{OLS} = (X^T X)^{-1} X^T y
References