qsirecon.utils.brainsuite_shore module

class qsirecon.utils.brainsuite_shore.BrainSuiteShoreFit(model, shore_coef, regularization=0, alpha=0.0, r2=0.0, cnr=0.0)[source]

Bases: object

__init__(model, shore_coef, regularization=0, alpha=0.0, r2=0.0, cnr=0.0)[source]

Calculates diffusion properties for a single voxel

Parameters:
  • model (object,) – AnalyticalModel

  • shore_coef (1d ndarray,) – shore coefficients

property alpha

The alpha used for the L1 fit.

property cnr

Contrast to Noise ratio.

fitted_signal()[source]

The fitted signal.

msd()[source]

Calculates the analytical mean squared displacement (MSD) [1]_

..math::
nowrap:
begin{equation}

MSD:{DSI}=int_{-infty}^{infty}int_{-infty}^{infty} int_{-infty}^{infty} P(hat{mathbf{r}}) cdot hat{mathbf{r}}^{2} dr_x dr_y dr_z

end{equation}

where $hat{mathbf{r}}$ is a point in the 3D propagator space (see Wu et al. [1]_).

References

  1. 617-629, 2007.

odf(sphere)[source]

Calculates the ODF for a given discrete sphere.

odf_sh()[source]

Calculates the real analytical ODF in terms of Spherical Harmonics.

pdf(r_points)[source]

Diffusion propagator on a given set of real points. if the array r_points is non writeable, then intermediate results are cached for faster recalculation

pdf_grid(gridsize, radius_max)[source]

Applies the analytical FFT on $S$ to generate the diffusion propagator. This is calculated on a discrete 3D grid in order to obtain an EAP similar to that which is obtained with DSI.

Parameters:
  • gridsize (unsigned int) – dimension of the propagator grid

  • radius_max (float) – maximal radius in which to compute the propagator

Returns:

eap – the ensemble average propagator in the 3D grid

Return type:

ndarray

predict(gtab, S0=100.0)[source]

Recovers the reconstructed signal for any qvalue array or gradient table.

property r2

Model r^2.

property regularization

Regularization used for fitting coefficients.

rtop_pdf()[source]

Calculates the analytical return to origin probability (RTOP) from the pdf [1]_.

References

diffusion imaging method for mapping tissue microstructure”, NeuroImage, 2013.

rtop_signal()[source]

Calculates the analytical return to origin probability (RTOP) from the signal [1]_.

References

diffusion imaging method for mapping tissue microstructure”, NeuroImage, 2013.

property shore_coeff

The SHORE coefficients.

class qsirecon.utils.brainsuite_shore.BrainSuiteShoreModel(gtab, regularization='L1', radial_order=6, zeta=700, tau=0.025330295910584444, lambdaN=1e-08, lambdaL=1e-08, regularization_weighting='CV', l1_positive_constraint=False, l1_cv=3, l1_maxiter=1000, l1_verbose=False, l1_alpha=1.0, pos_grid=11, pos_radius=0.02)[source]

Bases: Cache

Simple Harmonic Oscillator based Reconstruction and Estimation (SHORE) [1]_ of the diffusion signal.

The main idea is to model the diffusion signal as a linear combination of continuous functions $phi_i$,

..math::
nowrap:
begin{equation}

S(mathbf{q})= sum_{i=0}^I c_{i} phi_{i}(mathbf{q}).

end{equation}

where $mathbf{q}$ is the wave vector which corresponds to different gradient directions. Numerous continuous functions $phi_i$ can be used to model $S$. This specifically comes from [1].

References

Notes

The implementation of SHORE depends on CVXPY (http://www.cvxpy.org/).

__init__(gtab, regularization='L1', radial_order=6, zeta=700, tau=0.025330295910584444, lambdaN=1e-08, lambdaL=1e-08, regularization_weighting='CV', l1_positive_constraint=False, l1_cv=3, l1_maxiter=1000, l1_verbose=False, l1_alpha=1.0, pos_grid=11, pos_radius=0.02)[source]

Analytical and continuous modeling of the diffusion signal with respect to the SHORE basis [1,2]_. This implementation is a modification of SHORE presented in [1]_. The modification was made to obtain the same ordering of the basis presented in [2,3]_.

The main idea is to model the diffusion signal as a linear combination of continuous functions $phi_i$,

..math::
nowrap:
begin{equation}

S(mathbf{q})= sum_{i=0}^I c_{i} phi_{i}(mathbf{q}).

end{equation}

where $mathbf{q}$ is the wave vector which corresponds to different gradient directions.

From the $c_i$ coefficients, there exists an analytical formula to estimate the ODF.

Parameters:
  • gtab (GradientTable,) – gradient directions and bvalues container class

  • radial_order (unsigned int,) – an even integer that represent the order of the basis

  • zeta (unsigned int,) – scale factor

  • lambdaN (float,) – radial regularisation constant

  • lambdaL (float,) – angular regularisation constant

  • tau (float,) – diffusion time. By default the value that makes q equal to the square root of the b-value.

  • pos_grid (int,) – Grid that define the points of the EAP in which we want to enforce positivity.

  • pos_radius (float,) – Radius of the grid of the EAP in which enforce positivity in millimeters. By default 20e-03 mm.

References

ODF estimation via Compressive Sensing in diffusion MRI”, Medical Image Analysis, 2013.

Examples

In this example, where the data, gradient table and sphere tessellation used for reconstruction are provided, we model the diffusion signal with respect to the SHORE basis and compute the real and analytical ODF.

from dipy.data import get_data,get_sphere sphere = get_sphere(‘symmetric724’) fimg, fbvals, fbvecs = get_data(‘ISBI_testing_2shells_table’) bvals, bvecs = read_bvals_bvecs(fbvals, fbvecs) gtab = gradient_table(bvals, bvecs) from dipy.sims.voxel import SticksAndBall data, golden_directions = SticksAndBall(

gtab, d=0.0015, S0=1., angles=[(0, 0), (90, 0)], fractions=[50, 50], snr=None)

from dipy.reconst.canal import ShoreModel radial_order = 4 zeta = 700 asm = ShoreModel(gtab, radial_order=radial_order, zeta=zeta,

lambdaN=1e-8, lambdaL=1e-8)

asmfit = asm.fit(data) odf= asmfit.odf(sphere)

fit(data, *, mask=None, **kwargs)[source]

Fit method for every voxel in data

qsirecon.utils.brainsuite_shore.brainsuite_shore_basis(radial_order, zeta, gtab, tau=0.025330295910584444)[source]

Calculate the brainsuite shore basis functions.

qsirecon.utils.brainsuite_shore.brainsuite_shore_matrix_pdf(radial_order, zeta, rtab)[source]

Compute the SHORE propagator matrix [1]_

Parameters:
  • radial_order (unsigned int,) – an even integer that represent the order of the basis

  • zeta (unsigned int,) – scale factor

  • rtab (array, shape (N,3)) – real space points in which calculates the pdf

References

ODF estimation via Compressive Sensing in diffusion MRI”, Medical Image Analysis, 2013.

qsirecon.utils.brainsuite_shore.create_rspace(gridsize, radius_max)[source]

Create the real space table, that contains the points in which to compute the pdf.

Parameters:
  • gridsize (unsigned int) – dimension of the propagator grid

  • radius_max (float) – maximal radius in which compute the propagator

Returns:

  • vecs (array, shape (N,3)) – positions of the pdf points in a 3D matrix

  • tab (array, shape (N,3)) – real space points in which calculates the pdf

qsirecon.utils.brainsuite_shore.shore_index_matrix(radial_order)[source]
qsirecon.utils.brainsuite_shore.shore_matrix_odf(radial_order, zeta, sphere_vertices)[source]

Compute the SHORE ODF matrix [1]_

Parameters:
  • radial_order (unsigned int,) – an even integer that represent the order of the basis

  • zeta (unsigned int,) – scale factor

  • sphere_vertices (array, shape (N,3)) – vertices of the odf sphere

References

ODF estimation via Compressive Sensing in diffusion MRI”, Medical Image Analysis, 2013.

qsirecon.utils.brainsuite_shore.shore_matrix_pdf(radial_order, zeta, rtab)[source]