Skip to content

Commit

Permalink
Merge pull request #1726 from ShreyasFadnavis/ivim_mix
Browse files Browse the repository at this point in the history
IVIM MIX Model (MicroLearn)
  • Loading branch information
skoudoro committed Mar 8, 2019
2 parents aaeed62 + 1420d12 commit 7977f2b
Show file tree
Hide file tree
Showing 6 changed files with 546 additions and 93 deletions.
67 changes: 35 additions & 32 deletions dipy/reconst/dti.py
Expand Up @@ -52,7 +52,7 @@ def _roll_evals(evals, axis=-1):


def fractional_anisotropy(evals, axis=-1):
"""
r"""
Fractional anisotropy (FA) of a diffusion tensor.
Parameters
Expand Down Expand Up @@ -91,7 +91,7 @@ def fractional_anisotropy(evals, axis=-1):


def geodesic_anisotropy(evals, axis=-1):
"""
r"""
Geodesic anisotropy (GA) of a diffusion tensor.
Parameters
Expand Down Expand Up @@ -172,7 +172,7 @@ def geodesic_anisotropy(evals, axis=-1):


def mean_diffusivity(evals, axis=-1):
"""
r"""
Mean Diffusivity (MD) of a diffusion tensor.
Parameters
Expand Down Expand Up @@ -201,7 +201,7 @@ def mean_diffusivity(evals, axis=-1):


def axial_diffusivity(evals, axis=-1):
"""
r"""
Axial Diffusivity (AD) of a diffusion tensor.
Also called parallel diffusivity.
Expand Down Expand Up @@ -233,7 +233,7 @@ def axial_diffusivity(evals, axis=-1):


def radial_diffusivity(evals, axis=-1):
"""
r"""
Radial Diffusivity (RD) of a diffusion tensor.
Also called perpendicular diffusivity.
Expand Down Expand Up @@ -264,7 +264,7 @@ def radial_diffusivity(evals, axis=-1):


def trace(evals, axis=-1):
"""
r"""
Trace of a diffusion tensor.
Parameters
Expand Down Expand Up @@ -390,7 +390,7 @@ def isotropic(q_form):


def deviatoric(q_form):
"""
r"""
Calculate the deviatoric (anisotropic) part of the tensor [1]_.
Parameters
Expand Down Expand Up @@ -426,7 +426,7 @@ def deviatoric(q_form):


def norm(q_form):
"""
r"""
Calculate the Frobenius norm of a tensor quadratic form
Parameters
Expand Down Expand Up @@ -456,7 +456,7 @@ def norm(q_form):


def mode(q_form):
"""
r"""
Mode (MO) of a diffusion tensor [1]_.
Parameters
Expand Down Expand Up @@ -500,7 +500,7 @@ def mode(q_form):


def linearity(evals, axis=-1):
"""
r"""
The linearity of the tensor [1]_
Parameters
Expand Down Expand Up @@ -535,7 +535,7 @@ def linearity(evals, axis=-1):


def planarity(evals, axis=-1):
"""
r"""
The planarity of the tensor [1]_
Parameters
Expand Down Expand Up @@ -571,7 +571,7 @@ def planarity(evals, axis=-1):


def sphericity(evals, axis=-1):
"""
r"""
The sphericity of the tensor [1]_
Parameters
Expand Down Expand Up @@ -913,7 +913,7 @@ def mode(self):

@auto_attr
def md(self):
"""
r"""
Mean diffusivity (MD) calculated from cached eigenvalues.
Returns
Expand All @@ -934,7 +934,7 @@ def md(self):

@auto_attr
def rd(self):
"""
r"""
Radial diffusivity (RD) calculated from cached eigenvalues.
Returns
Expand All @@ -956,7 +956,7 @@ def rd(self):

@auto_attr
def ad(self):
"""
r"""
Axial diffusivity (AD) calculated from cached eigenvalues.
Returns
Expand All @@ -978,7 +978,7 @@ def ad(self):

@auto_attr
def trace(self):
"""
r"""
Trace of the tensor calculated from cached eigenvalues.
Returns
Expand All @@ -998,7 +998,7 @@ def trace(self):

@auto_attr
def planarity(self):
"""
r"""
Returns
-------
sphericity : array
Expand All @@ -1024,7 +1024,7 @@ def planarity(self):

@auto_attr
def linearity(self):
"""
r"""
Returns
-------
linearity : array
Expand All @@ -1050,7 +1050,7 @@ def linearity(self):

@auto_attr
def sphericity(self):
"""
r"""
Returns
-------
sphericity : array
Expand All @@ -1074,7 +1074,7 @@ def sphericity(self):
return sphericity(self.evals)

def odf(self, sphere):
"""
r"""
The diffusion orientation distribution function (dODF). This is an
estimate of the diffusion distance in each direction
Expand Down Expand Up @@ -1105,7 +1105,9 @@ def odf(self, sphere):
.. [Descoteaux2008] Descoteaux, M. (2008). PhD Thesis: High Angular
Resolution Diffusion MRI: from Local Estimation to Segmentation and
Tractography. ftp://ftp-sop.inria.fr/athena/Publications/PhDs/descoteaux_thesis.pdf
Tractography.
ftp://ftp-sop.inria.fr/athena/Publications/PhDs/descoteaux_thesis.pdf
"""
odf = np.zeros((self.evals.shape[:-1] + (sphere.vertices.shape[0],)))
if len(self.evals.shape) > 1:
Expand Down Expand Up @@ -1313,7 +1315,7 @@ def wrapped_fit_tensor(design_matrix, data, return_S0_hat=False,

@iter_fit_tensor()
def wls_fit_tensor(design_matrix, data, return_S0_hat=False):
"""
r"""
Computes weighted least squares (WLS) fit to calculate self-diffusion
tensor using a linear regression model [1]_.
Expand Down Expand Up @@ -1371,6 +1373,7 @@ def wls_fit_tensor(design_matrix, data, return_S0_hat=False):
.. [1] Chung, SW., Lu, Y., Henry, R.G., 2006. Comparison of bootstrap
approaches for estimation of uncertainties of DTI parameters.
NeuroImage 33, 531-541.
"""
tol = 1e-6
data = np.asarray(data)
Expand All @@ -1391,7 +1394,7 @@ def wls_fit_tensor(design_matrix, data, return_S0_hat=False):

@iter_fit_tensor()
def ols_fit_tensor(design_matrix, data, return_S0_hat=False):
"""
r"""
Computes ordinary least squares (OLS) fit to calculate self-diffusion
tensor using a linear regression model [1]_.
Expand Down Expand Up @@ -1470,7 +1473,7 @@ def _ols_fit_matrix(design_matrix):

def _nlls_err_func(tensor, design_matrix, data, weighting=None,
sigma=None):
"""
r"""
Error function for the non-linear least-squares fit of the tensor.
Parameters
Expand Down Expand Up @@ -1498,14 +1501,14 @@ def _nlls_err_func(tensor, design_matrix, data, weighting=None,
Notes
-----
The Geman-McClure M-estimator is described as follows [1]_ (page 1089): "The
scale factor C affects the shape of the GMM [Geman-McClure M-estimator]
weighting function and represents the expected spread of the residuals
(i.e., the SD of the residuals) due to Gaussian distributed noise. The
scale factor C can be estimated by many robust scale estimators. We used
the median absolute deviation (MAD) estimator because it is very robust to
outliers having a 50% breakdown point (6,7). The explicit formula for C
using the MAD estimator is:
The Geman-McClure M-estimator is described as follows [1]_ (page 1089):
"The scale factor C affects the shape of the GMM
[Geman-McClure M-estimator] weighting function and represents the expected
spread of the residuals (i.e., the SD of the residuals) due to Gaussian
distributed noise. The scale factor C can be estimated by many robust scale
estimators. We used the median absolute deviation (MAD) estimator because
it is very robust to outliers having a 50% breakdown point (6,7).
The explicit formula for C using the MAD estimator is:
.. math ::
Expand Down

0 comments on commit 7977f2b

Please sign in to comment.