Processing a HCP Dataset

Here we have run an HCP dataset through DSI Studio using the recommended parameters from the documentation. This includes

  • Gradient unwarping
  • Motion/Eddy correction
  • TopUp

The images (dwi mask, dwi data and graddev files) were downloaded directly from connectomedb.org. The resulting fib file is in 101915/data/input.

Loading DSI Studio files

Here a MITTENS object is created using default parameters.


In [1]:
from mittens import MITTENS
mitn = MITTENS(fibgz_file="101915/data/input/101915.src.gz.odf8.f5rec.fy.gqi.1.25.fib.gz")


INFO:mittens._mittens:
Using
------
  Step Size:		0.8660 Voxels 
  ODF Resolution:	odf8
  Max Angle:		35.00 Degrees
  Angle Weights:	flat
  Angle weight power:	1.0
INFO:mittens._mittens:Loading DSI Studio fib file
INFO:mittens._mittens:Loading 101915/data/input/101915.src.gz.odf8.f5rec.fy.gqi.1.25.fib.gz
INFO:mittens._mittens:Loaded 101915/data/input/101915.src.gz.odf8.f5rec.fy.gqi.1.25.fib.gz
INFO:mittens._mittens:Loading ODF data
INFO:mittens._mittens:Loaded ODF data: (750138, 321)

Calculating transition probabilities

We see in the output above that the default parameters of $\theta_{max}=35$ degrees and $s=\sqrt{3}/2$ voxels will be used for calculating transition probabilities. Now we actually calculate the probabilities and save them in NIfTI format.


In [2]:
import os
#os.makedirs("101915/data/mittens_output")
mitn.calculate_transition_probabilities(output_prefix="HCP")


INFO:mittens._mittens:ODF 0/750138
INFO:mittens._mittens:ODF 10000/750138
INFO:mittens._mittens:ODF 20000/750138
INFO:mittens._mittens:ODF 30000/750138
INFO:mittens._mittens:ODF 40000/750138
INFO:mittens._mittens:ODF 50000/750138
INFO:mittens._mittens:ODF 60000/750138
INFO:mittens._mittens:ODF 70000/750138
INFO:mittens._mittens:ODF 80000/750138
INFO:mittens._mittens:ODF 90000/750138
INFO:mittens._mittens:ODF 100000/750138
INFO:mittens._mittens:ODF 110000/750138
INFO:mittens._mittens:ODF 120000/750138
INFO:mittens._mittens:ODF 130000/750138
INFO:mittens._mittens:ODF 140000/750138
INFO:mittens._mittens:ODF 150000/750138
INFO:mittens._mittens:ODF 160000/750138
INFO:mittens._mittens:ODF 170000/750138
INFO:mittens._mittens:ODF 180000/750138
INFO:mittens._mittens:ODF 190000/750138
INFO:mittens._mittens:ODF 200000/750138
INFO:mittens._mittens:ODF 210000/750138
INFO:mittens._mittens:ODF 220000/750138
INFO:mittens._mittens:ODF 230000/750138
INFO:mittens._mittens:ODF 240000/750138
INFO:mittens._mittens:ODF 250000/750138
INFO:mittens._mittens:ODF 260000/750138
INFO:mittens._mittens:ODF 270000/750138
INFO:mittens._mittens:ODF 280000/750138
INFO:mittens._mittens:ODF 290000/750138
INFO:mittens._mittens:ODF 300000/750138
INFO:mittens._mittens:ODF 310000/750138
INFO:mittens._mittens:ODF 320000/750138
INFO:mittens._mittens:ODF 330000/750138
INFO:mittens._mittens:ODF 340000/750138
INFO:mittens._mittens:ODF 350000/750138
INFO:mittens._mittens:ODF 360000/750138
INFO:mittens._mittens:ODF 370000/750138
INFO:mittens._mittens:ODF 380000/750138
INFO:mittens._mittens:ODF 390000/750138
INFO:mittens._mittens:ODF 400000/750138
INFO:mittens._mittens:ODF 410000/750138
INFO:mittens._mittens:ODF 420000/750138
INFO:mittens._mittens:ODF 430000/750138
INFO:mittens._mittens:ODF 440000/750138
INFO:mittens._mittens:ODF 450000/750138
INFO:mittens._mittens:ODF 460000/750138
INFO:mittens._mittens:ODF 470000/750138
INFO:mittens._mittens:ODF 480000/750138
INFO:mittens._mittens:ODF 490000/750138
INFO:mittens._mittens:ODF 500000/750138
INFO:mittens._mittens:ODF 510000/750138
INFO:mittens._mittens:ODF 520000/750138
INFO:mittens._mittens:ODF 530000/750138
INFO:mittens._mittens:ODF 540000/750138
INFO:mittens._mittens:ODF 550000/750138
INFO:mittens._mittens:ODF 560000/750138
INFO:mittens._mittens:ODF 570000/750138
INFO:mittens._mittens:ODF 580000/750138
INFO:mittens._mittens:ODF 590000/750138
INFO:mittens._mittens:ODF 600000/750138
INFO:mittens._mittens:ODF 610000/750138
INFO:mittens._mittens:ODF 620000/750138
INFO:mittens._mittens:ODF 630000/750138
INFO:mittens._mittens:ODF 640000/750138
INFO:mittens._mittens:ODF 650000/750138
INFO:mittens._mittens:ODF 660000/750138
INFO:mittens._mittens:ODF 670000/750138
INFO:mittens._mittens:ODF 680000/750138
INFO:mittens._mittens:ODF 690000/750138
INFO:mittens._mittens:ODF 700000/750138
INFO:mittens._mittens:ODF 710000/750138
INFO:mittens._mittens:ODF 720000/750138
INFO:mittens._mittens:ODF 730000/750138
INFO:mittens._mittens:ODF 740000/750138
INFO:mittens._mittens:ODF 750000/750138
INFO:mittens._mittens:Calculating None-Ahead CoDI
INFO:mittens._mittens:Calculating Order1 KL Distance
INFO:mittens._mittens:Writing singleODF results
INFO:mittens._mittens:Writing HCP_singleODF_a_prob.nii.gz
INFO:mittens._mittens:Writing HCP_singleODF_ai_prob.nii.gz
INFO:mittens._mittens:Writing HCP_singleODF_as_prob.nii.gz
INFO:mittens._mittens:Writing HCP_singleODF_i_prob.nii.gz
INFO:mittens._mittens:Writing HCP_singleODF_l_prob.nii.gz
INFO:mittens._mittens:Writing HCP_singleODF_la_prob.nii.gz
INFO:mittens._mittens:Writing HCP_singleODF_lai_prob.nii.gz
INFO:mittens._mittens:Writing HCP_singleODF_las_prob.nii.gz
INFO:mittens._mittens:Writing HCP_singleODF_li_prob.nii.gz
INFO:mittens._mittens:Writing HCP_singleODF_lp_prob.nii.gz
INFO:mittens._mittens:Writing HCP_singleODF_lpi_prob.nii.gz
INFO:mittens._mittens:Writing HCP_singleODF_lps_prob.nii.gz
INFO:mittens._mittens:Writing HCP_singleODF_ls_prob.nii.gz
INFO:mittens._mittens:Writing HCP_singleODF_p_prob.nii.gz
INFO:mittens._mittens:Writing HCP_singleODF_pi_prob.nii.gz
INFO:mittens._mittens:Writing HCP_singleODF_ps_prob.nii.gz
INFO:mittens._mittens:Writing HCP_singleODF_r_prob.nii.gz
INFO:mittens._mittens:Writing HCP_singleODF_ra_prob.nii.gz
INFO:mittens._mittens:Writing HCP_singleODF_rai_prob.nii.gz
INFO:mittens._mittens:Writing HCP_singleODF_ras_prob.nii.gz
INFO:mittens._mittens:Writing HCP_singleODF_ri_prob.nii.gz
INFO:mittens._mittens:Writing HCP_singleODF_rp_prob.nii.gz
INFO:mittens._mittens:Writing HCP_singleODF_rpi_prob.nii.gz
INFO:mittens._mittens:Writing HCP_singleODF_rps_prob.nii.gz
INFO:mittens._mittens:Writing HCP_singleODF_rs_prob.nii.gz
INFO:mittens._mittens:Writing HCP_singleODF_s_prob.nii.gz
INFO:mittens._mittens:Pre-computing neighbor angle weights
INFO:mittens._mittens:ODF 0/750138
INFO:mittens._mittens:ODF 10000/750138
INFO:mittens._mittens:ODF 20000/750138
INFO:mittens._mittens:ODF 30000/750138
INFO:mittens._mittens:ODF 40000/750138
INFO:mittens._mittens:ODF 50000/750138
INFO:mittens._mittens:ODF 60000/750138
INFO:mittens._mittens:ODF 70000/750138
INFO:mittens._mittens:ODF 80000/750138
INFO:mittens._mittens:ODF 90000/750138
INFO:mittens._mittens:ODF 100000/750138
INFO:mittens._mittens:ODF 110000/750138
INFO:mittens._mittens:ODF 120000/750138
INFO:mittens._mittens:ODF 130000/750138
INFO:mittens._mittens:ODF 140000/750138
INFO:mittens._mittens:ODF 150000/750138
INFO:mittens._mittens:ODF 160000/750138
INFO:mittens._mittens:ODF 170000/750138
INFO:mittens._mittens:ODF 180000/750138
INFO:mittens._mittens:ODF 190000/750138
INFO:mittens._mittens:ODF 200000/750138
INFO:mittens._mittens:ODF 210000/750138
INFO:mittens._mittens:ODF 220000/750138
INFO:mittens._mittens:ODF 230000/750138
INFO:mittens._mittens:ODF 240000/750138
INFO:mittens._mittens:ODF 250000/750138
INFO:mittens._mittens:ODF 260000/750138
INFO:mittens._mittens:ODF 270000/750138
INFO:mittens._mittens:ODF 280000/750138
INFO:mittens._mittens:ODF 290000/750138
INFO:mittens._mittens:ODF 300000/750138
INFO:mittens._mittens:ODF 310000/750138
INFO:mittens._mittens:ODF 320000/750138
INFO:mittens._mittens:ODF 330000/750138
INFO:mittens._mittens:ODF 340000/750138
INFO:mittens._mittens:ODF 350000/750138
INFO:mittens._mittens:ODF 360000/750138
INFO:mittens._mittens:ODF 370000/750138
INFO:mittens._mittens:ODF 380000/750138
INFO:mittens._mittens:ODF 390000/750138
INFO:mittens._mittens:ODF 400000/750138
INFO:mittens._mittens:ODF 410000/750138
INFO:mittens._mittens:ODF 420000/750138
INFO:mittens._mittens:ODF 430000/750138
INFO:mittens._mittens:ODF 440000/750138
INFO:mittens._mittens:ODF 450000/750138
INFO:mittens._mittens:ODF 460000/750138
INFO:mittens._mittens:ODF 470000/750138
INFO:mittens._mittens:ODF 480000/750138
INFO:mittens._mittens:ODF 490000/750138
INFO:mittens._mittens:ODF 500000/750138
INFO:mittens._mittens:ODF 510000/750138
INFO:mittens._mittens:ODF 520000/750138
INFO:mittens._mittens:ODF 530000/750138
INFO:mittens._mittens:ODF 540000/750138
INFO:mittens._mittens:ODF 550000/750138
INFO:mittens._mittens:ODF 560000/750138
INFO:mittens._mittens:ODF 570000/750138
INFO:mittens._mittens:ODF 580000/750138
INFO:mittens._mittens:ODF 590000/750138
INFO:mittens._mittens:ODF 600000/750138
INFO:mittens._mittens:ODF 610000/750138
INFO:mittens._mittens:ODF 620000/750138
INFO:mittens._mittens:ODF 630000/750138
INFO:mittens._mittens:ODF 640000/750138
INFO:mittens._mittens:ODF 650000/750138
INFO:mittens._mittens:ODF 660000/750138
INFO:mittens._mittens:ODF 670000/750138
INFO:mittens._mittens:ODF 680000/750138
INFO:mittens._mittens:ODF 690000/750138
INFO:mittens._mittens:ODF 700000/750138
INFO:mittens._mittens:ODF 710000/750138
INFO:mittens._mittens:ODF 720000/750138
INFO:mittens._mittens:ODF 730000/750138
INFO:mittens._mittens:ODF 740000/750138
INFO:mittens._mittens:ODF 750000/750138
/home/matt/projects/MITTENS/mittens/_mittens.py:434: RuntimeWarning: invalid value encountered in true_divide
  self.doubleODF_results = outputs / np.nansum(outputs, 1)[:,np.newaxis]
INFO:mittens._mittens:Calculating Double ODF CoDI
INFO:mittens._mittens:Calculating CoAsy

This writes out NIfTI images for the transition probabilities to each neighbor using both the singleODF and doubleODF methods. Additionally, you will find volumes written out for CoDI and CoAsy. Writing to NIfTI is useful to quickly assess the quality of the output. the CoDI volumes should look a lot like GFA or FA images.

One can load theses images directly to create a MITTENS object. This bypasses the need to re-calculate transition probabilities and is the recommended way to access transition probabilities before building and saving Voxel Graphs.

Loading from NIfTI outputs

Here we demonstrate loading transition probabilites from NIfTI files. We verify that their contents are identical to those generated by calculating transition probabilities from a fib.gz file.


In [4]:
nifti_mitn = MITTENS(nifti_prefix="HCP")

import numpy as np
print("singleODF outputs are identical:", 
          np.allclose(mitn.singleODF_results,nifti_mitn.singleODF_results))
print("doubleODF outputs are identical:", 
          np.allclose(mitn.doubleODF_results,nifti_mitn.doubleODF_results,equal_nan=True))


INFO:mittens._mittens:
Using
------
  Step Size:		0.8660 Voxels 
  ODF Resolution:	odf8
  Max Angle:		35.00 Degrees
  Angle Weights:	flat
  Angle weight power:	1.0
INFO:mittens._mittens:Loading output from pre-existing NIfTIs
INFO:mittens.spatial:Loading NIfTI Image HCP_mask.nii.gz
INFO:mittens._mittens:Used  to mask from 3658350 to 750138 voxels
INFO:mittens._mittens:Loading singleODF results
INFO:mittens._mittens:Loading NIfTI Image HCP_singleODF_a_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_singleODF_a_prob.nii.gz
INFO:mittens._mittens:Loading NIfTI Image HCP_singleODF_ai_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_singleODF_ai_prob.nii.gz
INFO:mittens._mittens:Loading NIfTI Image HCP_singleODF_as_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_singleODF_as_prob.nii.gz
INFO:mittens._mittens:Loading NIfTI Image HCP_singleODF_i_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_singleODF_i_prob.nii.gz
INFO:mittens._mittens:Loading NIfTI Image HCP_singleODF_l_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_singleODF_l_prob.nii.gz
INFO:mittens._mittens:Loading NIfTI Image HCP_singleODF_la_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_singleODF_la_prob.nii.gz
INFO:mittens._mittens:Loading NIfTI Image HCP_singleODF_lai_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_singleODF_lai_prob.nii.gz
INFO:mittens._mittens:Loading NIfTI Image HCP_singleODF_las_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_singleODF_las_prob.nii.gz
INFO:mittens._mittens:Loading NIfTI Image HCP_singleODF_li_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_singleODF_li_prob.nii.gz
INFO:mittens._mittens:Loading NIfTI Image HCP_singleODF_lp_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_singleODF_lp_prob.nii.gz
INFO:mittens._mittens:Loading NIfTI Image HCP_singleODF_lpi_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_singleODF_lpi_prob.nii.gz
INFO:mittens._mittens:Loading NIfTI Image HCP_singleODF_lps_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_singleODF_lps_prob.nii.gz
INFO:mittens._mittens:Loading NIfTI Image HCP_singleODF_ls_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_singleODF_ls_prob.nii.gz
INFO:mittens._mittens:Loading NIfTI Image HCP_singleODF_p_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_singleODF_p_prob.nii.gz
INFO:mittens._mittens:Loading NIfTI Image HCP_singleODF_pi_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_singleODF_pi_prob.nii.gz
INFO:mittens._mittens:Loading NIfTI Image HCP_singleODF_ps_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_singleODF_ps_prob.nii.gz
INFO:mittens._mittens:Loading NIfTI Image HCP_singleODF_r_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_singleODF_r_prob.nii.gz
INFO:mittens._mittens:Loading NIfTI Image HCP_singleODF_ra_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_singleODF_ra_prob.nii.gz
INFO:mittens._mittens:Loading NIfTI Image HCP_singleODF_rai_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_singleODF_rai_prob.nii.gz
INFO:mittens._mittens:Loading NIfTI Image HCP_singleODF_ras_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_singleODF_ras_prob.nii.gz
INFO:mittens._mittens:Loading NIfTI Image HCP_singleODF_ri_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_singleODF_ri_prob.nii.gz
INFO:mittens._mittens:Loading NIfTI Image HCP_singleODF_rp_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_singleODF_rp_prob.nii.gz
INFO:mittens._mittens:Loading NIfTI Image HCP_singleODF_rpi_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_singleODF_rpi_prob.nii.gz
INFO:mittens._mittens:Loading NIfTI Image HCP_singleODF_rps_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_singleODF_rps_prob.nii.gz
INFO:mittens._mittens:Loading NIfTI Image HCP_singleODF_rs_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_singleODF_rs_prob.nii.gz
INFO:mittens._mittens:Loading NIfTI Image HCP_singleODF_s_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_singleODF_s_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_singleODF_CoDI.nii.gz
INFO:mittens._mittens:Reading doubleODF results
INFO:mittens._mittens:Loading HCP_doubleODF_a_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_doubleODF_a_prob.nii.gz
INFO:mittens._mittens:Loading HCP_doubleODF_ai_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_doubleODF_ai_prob.nii.gz
INFO:mittens._mittens:Loading HCP_doubleODF_as_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_doubleODF_as_prob.nii.gz
INFO:mittens._mittens:Loading HCP_doubleODF_i_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_doubleODF_i_prob.nii.gz
INFO:mittens._mittens:Loading HCP_doubleODF_l_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_doubleODF_l_prob.nii.gz
INFO:mittens._mittens:Loading HCP_doubleODF_la_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_doubleODF_la_prob.nii.gz
INFO:mittens._mittens:Loading HCP_doubleODF_lai_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_doubleODF_lai_prob.nii.gz
INFO:mittens._mittens:Loading HCP_doubleODF_las_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_doubleODF_las_prob.nii.gz
INFO:mittens._mittens:Loading HCP_doubleODF_li_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_doubleODF_li_prob.nii.gz
INFO:mittens._mittens:Loading HCP_doubleODF_lp_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_doubleODF_lp_prob.nii.gz
INFO:mittens._mittens:Loading HCP_doubleODF_lpi_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_doubleODF_lpi_prob.nii.gz
INFO:mittens._mittens:Loading HCP_doubleODF_lps_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_doubleODF_lps_prob.nii.gz
INFO:mittens._mittens:Loading HCP_doubleODF_ls_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_doubleODF_ls_prob.nii.gz
INFO:mittens._mittens:Loading HCP_doubleODF_p_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_doubleODF_p_prob.nii.gz
INFO:mittens._mittens:Loading HCP_doubleODF_pi_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_doubleODF_pi_prob.nii.gz
INFO:mittens._mittens:Loading HCP_doubleODF_ps_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_doubleODF_ps_prob.nii.gz
INFO:mittens._mittens:Loading HCP_doubleODF_r_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_doubleODF_r_prob.nii.gz
INFO:mittens._mittens:Loading HCP_doubleODF_ra_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_doubleODF_ra_prob.nii.gz
INFO:mittens._mittens:Loading HCP_doubleODF_rai_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_doubleODF_rai_prob.nii.gz
INFO:mittens._mittens:Loading HCP_doubleODF_ras_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_doubleODF_ras_prob.nii.gz
INFO:mittens._mittens:Loading HCP_doubleODF_ri_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_doubleODF_ri_prob.nii.gz
INFO:mittens._mittens:Loading HCP_doubleODF_rp_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_doubleODF_rp_prob.nii.gz
INFO:mittens._mittens:Loading HCP_doubleODF_rpi_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_doubleODF_rpi_prob.nii.gz
INFO:mittens._mittens:Loading HCP_doubleODF_rps_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_doubleODF_rps_prob.nii.gz
INFO:mittens._mittens:Loading HCP_doubleODF_rs_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_doubleODF_rs_prob.nii.gz
INFO:mittens._mittens:Loading HCP_doubleODF_s_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_doubleODF_s_prob.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_doubleODF_CoDI.nii.gz
INFO:mittens.spatial:Loading NIfTI Image HCP_doubleODF_CoAsy.nii.gz
singleODF outputs are identical: True
doubleODF outputs are identical: True

You'll notice loading from NIfTI is much faster!

Building and saving a voxel graph

Transition probabilities need to be converted to edge weights somehow. The MITTENS object accomplishes this through the build_graph function, which offers a number of options. Here is the relevant portion of the build_graph documentation

Schemes for shortest paths:
---------------------------

``"negative_log_p"``:
  Transition probabilities are log transformed and made negative.  This is similar to the Zalesky 2009 strategy.

``"minus_iso_negative_log"``:
  Isotropic probabilities are subtracted from transition probabilities. Edges are not added when transition probabilities are less than the isotropic probability.

``"minus_iso_scaled_negative_log"``:
  Same as ``"minus_iso_negative_log"`` except probabilities are re-scaled to sum to 1 *before* the log transform is applied. 


You also have to pick whether to use singleODF or doubleODF probabilities. You can easily create graphs using either.


In [ ]:
doubleODF_nlp = mitn.build_graph(doubleODF=True, weighting_scheme="negative_log_p")
doubleODF_nlp.save("fcup_doubleODF_nlp.mat")

Notes

Masking

If no spatial mask is specified when the MITTENS object is constructed, the generous brain mask estimated by DSI Studio will be used. This means the file sizes will be somewhat larger and the calculations will take longer. However, we recommend using the larger mask, as you can easily apply masks to the voxel graphs. It's better to have a voxel and not need it than to re-run transition probability calculation.

Affines

MITTENS mimics DSI Studio. Internally everything is done in LPS+ orientation and results are written out in RAS+ orientation. The affine used in the transition probability NIfTI images is the same as the images written by DSI Studio. This is a bizarre area of scanner coordinates and more closely matches the coordinates used by streamlines.

Verifying that the Voxel Graph is preserved

Here we load a Voxel Graph directly from a matfile and check that it exactly matches the graph produced above.


In [ ]:
from mittens import VoxelGraph
mat_vox_graph = VoxelGraph("101915/data/mittens_output/HCP_doubleODF_nlp.mat")


from networkit.algebraic import adjacencyMatrix
matfile_adj = adjacencyMatrix(mat_vox_graph.graph,matrixType="sparse")
mitn_adj = adjacencyMatrix(doubleODF_nlp.graph,matrixType="sparse")


mat_indices = np.nonzero(matfile_adj)
indices = np.nonzero(mitn_adj)

print("row indices match:", np.all(mat_indices[0] == indices[0]))
print("column indices match:",np.all(mat_indices[1] == indices[1]))

print("Weights all match:", np.allclose(matfile_adj[indices],mitn_adj[indices]))

Conclusions

Here we've shown that transition probabilities and edge weights are preserved over the three ways they can be represented in MITTENS. Next we show useful operations that can be performed using a VoxelGraph.