# ConTrack Score

### From VISTA LAB WIKI

## Contents |

## [edit] ConTrack Score

ConTrack is an algorithm that used diffusion imaging data to find and score pathways between brain regions. It consists of two components, "gen", which generates pathways from the diffusion data, and "score", which scores them by evaluating their likelihood given the diffusion dataset. Both algorithms were originally implemented in C++, but were relatively inaccessible due to the code's complexity.

This wiki page describes a Matlab implementation of ConTrack "score", which is designed to integrate with the standard vistasoft processing pipeline.

#### [edit] Paper

#### [edit] Code Repository

## [edit] Using ConTrack Score

Sample code: testctrscore.m

### [edit] 1. Required Data

The following data must be obtained through the standard vistasoft processing pipeline. Some example names are specified based on a sample dataset.

#### [edit] Files

- A white matter mask (Eg. wmProb.nii.gz)
- A PDF file (Eg. pdf.nii.gz)
- An ROI mask file (Eg. ltLGN_ltCalcFreesurfer_9_20110827T152126.nii.gz)
- A pdb fiber file (Eg. ltLGN_ltCalcFreesurfer_9_20110827T152126_top5000.pdb)
- A tensor file (Eg. tensors.nii.gz)

#### [edit] Sample Dataset

TODO : Ask Michael for hard-link

### [edit] 2. Pre-processing : Load tensor data

The code uses standard vistasoft functions to load in the data.

file_tensor = '<base_path>/contrack.git/data/sub100311rd/dti06trilin/bin/tensors.nii.gz'; <br /> dwiData = load_nifti(file_tensor); % Just to get the xform <br /> fib2voxXform = inv(dwiData.vox2ras); % Fibers are typically in RAS coordinates <br /> [dt6, xformToAcpc, mmPerVoxel, fileName, desc, intentName] = dtiLoadTensorsFromNifti(file_tensor);

### [edit] 3. Pre-processing : Integrate the Bingham and Watson distributions

The most significant computational cost in ConTrack score is to compute the Bingham and Watson distributions. These are used as probability distributions on the surface of a sphere that are similar at two ends of a diameter line (antipodally symmetric). The distributions themselves, however, may integrate to an arbitrary constant on the surface of a sphere. As such, we compute the integral and divide each value by it to obtain a probability distribution, which must integrate to unity over the domain.

This is a one-time cost per dataset since both Bingham and Watson distributions are functions of the diffusion tensor eigenvalues at each voxel. (Alternatively, one may approximate the constant for a set of discretized eigenvalues---to be done).

[dt6bham dt6wat] = ctrGetBinghamIntegConstt(dt6,0.1); % 0.1 (rad) is the default integration step size. Increase it to speed things up

The matlab documentation describes each argument:

% CTRGENBINGHAMPATVOXELS Integrates the Bingham distribution over a sphere % for each voxel and computes the normalizing constant at each point. % % [ Bconstt Wconstt] = ctrGenBinghamIntegConstt( tensors ) % % Inputs: % dt6 : mrVista's diffusion data structure containing the tensors. % sampling_res : The integration step resolution. Default = 0.001. % vox_range : (Optional) Allows computing this for a subset of total vox % % Outuputs: % Bconstt : The Bingham constant obtained by numerically integrating the % Bingham function over a sphere for each voxel. % Wconstt : The Watson constant obtained by numerically integrating the % Watson function over a sphere for each voxel.

### [edit] 4. Run ConTrack Score

The returned scores vector contains a score for each fiber in the pathway. The default code also tests whether the execution was numerically stable or not.

[scores unstable] = contrack_score(fg, dt6, fib2voxXform, tmpStructural, tmpStructural.*0 + 1, dt6bham, dt6wat);

There is another (faster) implementation with no numerical instability tests.

[scores unstable] = contrack_score_ndbg(fg, dt6, fib2voxXform, tmpStructural, tmpStructural.*0 + 1, dt6bham, dt6wat);

The matlab documentation describes each argument:

% [ scores, algo_unstable ] = contrack_score( fg, dt6, dwiSeg, dwiROI ) % % Inputs: % fg : A fiber group, which essentially summarizes a pdb file. % The pdb file is imported as `fgGet(fg,'fibers')` (struct with % 3xn-paths). % NOTE : This is typically loaded from a pdb file % >> fg = dtiLoadFiberGroup('fname.pdb') % % dt6 : The diffusion weighted data % % dwiSeg : A co-registered segmented volume. Could be higher res than the % diffusion data. Contains the ROI. % % dwiROI : An ROI to avoid (passing this will give the fiber a zero % score). A matrix of size dwiSeg, where 0 indicates region to % avoid and 1 indicates acceptable region. % % dt6bham : The Bingham integration constant for each voxel (matched to % the dt6 data) % % dt6wat : The Watson integration constant for each voxel (matched to % the dt6 data) % % Outuputs: % score : A vector of n * 1, with scores for each fiber, ordered using % the same numerical index as the `fgGet(fg,'fibers')` input. % % algo_unstable : Whether this iteration of the algorithm was numerically % unstable (log and normal scores diverge).

## [edit] Spherical Probability Distributions

Integrating the Bingham and Watson spherical distributions takes quite a while. So we pre-compute common diffusion tensor values based on the following figures (courtesy Ariel Rokem).

B Value = 1000: File:Tensor1k.jpg

B Value = 2000: File:Tensor2k.jpg

B Value = 4000: File:Tensor4k.jpg