Dipy overview

Dipy also known as "Diffusion Imaging in Python: is used for diffusion magnetic resonance imaging (dMRI) experiments. dMRI measures the structural features of white matter in the brain.

The primary focus of this algorithms.md document will be on fiber tractography.

Tractography overview

dMRI is special in its application of pulsed magnetic gradients to make diffusion sensitive measurements. The specific sensitivity is based on the b value, a set of parameters including duration of gradient, time between gradient pulses, and gradient amplitude. The specific directionality of the magnetif field gradient is shown by unit vectors called b vectors.

For simplicity's sake we will call tractography the computational art of detecting and delineating fibers. In dMRI this is done by generating "streamlines" - imaginary lines that run along the most likely directions of diffusion shown by the b values and vectors.

Pseudocode paragraph description

Step 1: Data extraction

Using an MRI format input (such as nifti), we extract the data to a numpy array. The input is a 4D volume which contains sequential 3D volumes. The first 3D volume is the non-diffusion-weighted data.

Step 2: Background Removal

A median filter is used to smooth the volume and then an Otsu filter is used the separate the brain from the background. Ultimately this separates the volumes into two, one for the foreground and one for the background.

Step 3: Gradient Table

Calculate b value using classical PGSE sequence equation. The dipy gradient table is simply an object that checks input values and returns b values and vectors in a Dipy friendly form.

Step 4: Reconstruction

Diffusion propagator P is used to calculate the probability displacement distribution. A DTI tensor based system is constructed. A tensor is defined as a 3 x 3 positive definite symmetric matrix. This is a centered ellipsoid with 3 principal axes and eigenvalues.

Application of Dipy probabilistic and deterministic algorithms to Clarity brains

Clarity brains are not true diffusion MRI images, and are thus NOT a 4D volume. There is no naturally included magnetic gradient information (because there is none) and most importantly the b values and vectors are thus not applicable quantities. This obviously makes tractography difficult because of the dependence on both probabilistic and deterministic algorithms on the gradient table calculated from the b values and vectors.

Overview of Probabilistic algorithms for Dipy and their relevance to Clarity

The major algorithms that Dipy uses for probabilistic tractography involve Monte Carlo sampling to genereate streamlines using the uncertainty in fiber direction (fODF). A seed point is genereated and is used along a propagation direction that is randomly chosen from fODF, and then is continuously adjusted based on sampleing of the fODF at each new location. This only terminates when the pre-programmed stopping criteria is met.

Dipy's probabilistic algorithm is actually a type of deterministic algorithm fiber tracking, with the fODF at each point being the delta function of a single fiber direction.

Diffusion tensor is modeled as

$\frac{S(g,b)}{S_0} = e^{-bg^{T}Dg}$

and describes the general behavior of diffusion within a specific model. Specifically, $\mathbf{g}$ is a unit vector in 3 space indicating the direction of measurement and b are the parameters of measurement, such as the strength and duration of diffusion-weighting gradient. $S(\mathbf{g}, b)$ is the diffusion-weighted signal measured and $S_0$ is the signal conducted in a measurement with no diffusion weighting.

Source: Dipy

D is a positive-definite quadratic form, which contains six free parameters to be fit. In English terms this is simply a variance covariance matrix along three spatial directions containing 6 parameters for fit.

$\mathbf{D} = \begin{pmatrix} D_{xx} & D_{xy} & D_{xz} \\ D_{yx} & D_{yy} & D_{yz} \\ D_{zx} & D_{zy} & D_{zz} \\ \end{pmatrix}$