Back to list of all tutorials | Back to course page | Previous

Tract statistics

Remember...

For each new terminal that you open, you must do:

export SUBJECTS_DIR=$TUTORIAL_DATA/diffusion_recons
cd $TUTORIAL_DATA/diffusion_tutorial


This section of the tutorial will teach you how to extract statistics on anisotropy and diffusivity measures for the white-matter pathways reconstructed by TRACULA. There are two types of statistics files that are created for each white-matter pathway:

For example, the statistics files for the left inferior longitudinal fasciculus (ILF) of subject elmo.2012, showing measures for the entire left ILF or along the left ILF, can be found below. Optional: use a text editor, such as gedit, or the command open -e on a Mac, to open these files.

$TUTORIAL_DATA/diffusion_tutorial/elmo.2012/dpath/lh.ilf_AS_avg33_mni_bbr/pathstats.overall.txt
$TUTORIAL_DATA/diffusion_tutorial/elmo.2012/dpath/lh.ilf_AS_avg33_mni_bbr/pathstats.byvoxel.txt

Anisotropy and diffusivity averaged over an entire pathway

You can view an example of the overall pathway stats by doing:

gedit $TUTORIAL_DATA/diffusion_tutorial/elmo.2012/dpath/lh.ilf_AS_avg33_mni_bbr/pathstats.overall.txt &

ON MACS, RUN:

 open -e $TUTORIAL_DATA/diffusion_tutorial/elmo.2012/dpath/lh.ilf_AS_avg33_mni_bbr/pathstats.overall.txt &

This file will look like this:

# Title Pathway Statistics
#
# generating_program /usr/local/freesurfer/stable6/bin/dmri_pathstats
# cvs_version
# cmdline /usr/local/freesurfer/stable6/bin/dmri_pathstats --intrc /autofs/space/rama_001/users/eboyd2/FStutorial_edits/diffusion_tutorial/elmo.2012/dpath/lh.ilf_AS_avg33_mni_bbr --dtbase /autofs/space/rama_001/users/eboyd2/FStutorial_edits/diffusion_tutorial/elmo.2012/dmri/dtifit --path lh.ilf --subj elmo.2012 --out /autofs/space/rama_001/users/eboyd2/FStutorial_edits/diffusion_tutorial/elmo.2012/dpath/lh.ilf_AS_avg33_mni_bbr/pathstats.overall.txt --outvox /autofs/space/rama_001/users/eboyd2/FStutorial_edits/diffusion_tutorial/elmo.2012/dpath/lh.ilf_AS_avg33_mni_bbr/pathstats.byvoxel.txt
# sysname Linux
# hostname oribi
# machine x86_64
# user eboyd2
# anatomy_type pathway
#
# subjectname elmo.2012
# pathwayname lh.ilf
#
Count 1500
Volume 629
Len_Min 36
Len_Max 71
Len_Avg 50.01
Len_Center 48
AD_Avg 0.00136398
AD_Avg_Weight 0.00137336
AD_Avg_Center 0.00137163
RD_Avg 0.000570444
RD_Avg_Weight 0.000568755
RD_Avg_Center 0.00056212
MD_Avg 0.000834957
MD_Avg_Weight 0.000836957
MD_Avg_Center 0.000831957
FA_Avg 0.505701
FA_Avg_Weight 0.510267
FA_Avg_Center 0.514496

This text file contains various diffusion measures, averaged over the entire white-matter tract. The measures include:

Converting pathstats.overall.txt files to a table for group analyses

Measures can be extracted from these files to be analyzed further, e.g., for tract-based group analysis. Specifically, the text files can be converted into a table using the command tractstats2table and then used for doing GLM analyses with mri_glmfit or any other statistical software (SPSS, Excel, Statview etc.)

To extract all diffusion measures for the left ILF from subject elmo.2012 into a table, do the following:

tractstats2table --inputs $TUTORIAL_DATA/diffusion_tutorial/elmo.2012/dpath/lh.ilf_AS_avg33_mni_bbr/pathstats.overall.txt --overall --tablefile $TUTORIAL_DATA/diffusion_tutorial/lh.ilf.elmo.2012.All.table

Take a look at the resulting table file:

gedit $TUTORIAL_DATA/diffusion_tutorial/lh.ilf.elmo.2012.All.table &

ON MACS, RUN:

 open -e $TUTORIAL_DATA/diffusion_tutorial/lh.ilf.elmo.2012.All.table &

For a group analysis, tractstats2table can be used to combine the diffusion measures in pathstats.overall.txt from multiple subjects into a single table, which can then be used for analysis with mri_glmfit or any other statistical software.

To do this, you will have to create a text file that lists the full path to every subject's pathstats.overall.txt file. An example of such a list for all 3 tutorial subjects is shown below.

$TUTORIAL_DATA/diffusion_tutorial/elmo.2005/dpath/lh.ilf_AS_avg33_mni_bbr/pathstats.overall.txt
$TUTORIAL_DATA/diffusion_tutorial/elmo.2008/dpath/lh.ilf_AS_avg33_mni_bbr/pathstats.overall.txt
$TUTORIAL_DATA/diffusion_tutorial/elmo.2012/dpath/lh.ilf_AS_avg33_mni_bbr/pathstats.overall.txt

Create a text file using the command below. Copy and paste this list into it, and save the file.

gedit $TUTORIAL_DATA/diffusion_tutorial/lh.ilf.list &

ON MACS, RUN:

 open -e $TUTORIAL_DATA/diffusion_tutorial/lh.ilf.list &

The following command will use this list to create a table with the diffusion measures from all the files listed above:

tractstats2table --load-pathstats-from-file $TUTORIAL_DATA/diffusion_tutorial/lh.ilf.list --overall --tablefile $TUTORIAL_DATA/diffusion_tutorial/lh.ilf.All.table

Take a look at the resulting table file:

gedit $TUTORIAL_DATA/diffusion_tutorial/lh.ilf.All.table &

ON MACS, RUN:

 open -e $TUTORIAL_DATA/diffusion_tutorial/lh.ilf.All.table &

Instead of extracting all measures included in the tract statistics files, we may be interested only in a few specific measures. For example, to extract only the average FA for each subject, do the following:

tractstats2table --load-pathstats-from-file $TUTORIAL_DATA/diffusion_tutorial/lh.ilf.list --overall --only-measures FA_Avg --tablefile $TUTORIAL_DATA/diffusion_tutorial/lh.ilf.FA_Avg.table

OPTIONAL: You can look at these tables in OpenOffice (or any other spreadsheet program). For example, to open the file lh.ilf.All.table in OpenOffice, do the following :

localc $TUTORIAL_DATA/diffusion_tutorial/lh.ilf.All.table

From here, you could use these stats tables to run a group analysis on the tracts.

Anisotropy and diffusivity along the trajectory of a pathway

Now take a look at the stats as a function of position along the trajectory of the same tract:

gedit $TUTORIAL_DATA/diffusion_tutorial/elmo.2012/dpath/lh.ilf_AS_avg33_mni_bbr/pathstats.byvoxel.txt &

ON MACS, RUN:

 open -e $TUTORIAL_DATA/diffusion_tutorial/elmo.2012/dpath/lh.ilf_AS_avg33_mni_bbr/pathstats.byvoxel.txt &

It will look like this:

# Title Pathway Statistics
#
# generating_program /usr/local/freesurfer/stable6/bin/dmri_pathstats
# cvs_version
# cmdline /usr/local/freesurfer/stable6/bin/dmri_pathstats --intrc /autofs/space/rama_001/users/eboyd2/FStutorial_edits/diffusion_tutorial/elmo.2012/dpath/lh.ilf_AS_avg33_mni_bbr --dtbase /autofs/space/rama_001/users/eboyd2/FStutorial_edits/diffusion_tutorial/elmo.2012/dmri/dtifit --path lh.ilf --subj elmo.2012 --out /autofs/space/rama_001/users/eboyd2/FStutorial_edits/diffusion_tutorial/elmo.2012/dpath/lh.ilf_AS_avg33_mni_bbr/pathstats.overall.txt --outvox /autofs/space/rama_001/users/eboyd2/FStutorial_edits/diffusion_tutorial/elmo.2012/dpath/lh.ilf_AS_avg33_mni_bbr/pathstats.byvoxel.txt
# sysname Linux
# hostname oribi
# machine x86_64
# user eboyd2
# anatomy_type pathway
#
# subjectname elmo.2012
# pathwayname lh.ilf
#
# pathway start
x y z AD RD MD FA AD_Avg RD_Avg MD_Avg FA_Avg
83 74 10 0.0010087 0.000830648 0.000889999 0.159232 0.00116397 0.000637616 0.000813066 0.374542
83 73 10 0.00107542 0.00076142 0.000866087 0.248381 0.00116 0.000631537 0.000807689 0.378022
83 73 11 0.00110213 0.000712833 0.000842598 0.275052 0.00116456 0.000632124 0.000809599 0.378441
83 72 11 0.00115836 0.000627003 0.000804122 0.379383 0.00118313 0.000638984 0.000820367 0.378685
83 71 11 0.00130141 0.00050243 0.000768757 0.540997 0.00120207 0.000613241 0.000809521 0.409762
83 71 12 0.00135934 0.000596314 0.000850654 0.479475 0.00122036 0.00060423 0.00080961 0.425146
83 70 12 0.00154584 0.000596379 0.000912867 0.540192 0.0012735 0.000598274 0.000823352 0.449849
83 69 12 0.0015961 0.000637489 0.000957027 0.523057 0.0013166 0.000627619 0.000857281 0.443408
83 68 13 0.00144106 0.000659587 0.000920077 0.456897 0.00131143 0.000646806 0.000868347 0.428068
84 67 13 0.00133104 0.000563732 0.000819502 0.501266 0.00126369 0.00063388 0.000843816 0.423312
84 66 14 0.00129191 0.000639349 0.000856869 0.429424 0.00120567 0.000636186 0.000826019 0.401576
84 65 14 0.00111743 0.000576156 0.000756579 0.401439 0.00120671 0.000675135 0.000852329 0.370139
84 64 15 0.000995878 0.000653256 0.000767463 0.27065 0.00115213 0.000677309 0.000835582 0.347765
84 63 15 0.00103649 0.000619989 0.000758823 0.333934 0.00120864 0.000672818 0.00085142 0.372466
84 62 16 0.00121678 0.000586189 0.000796385 0.432171 0.00128202 0.000629584 0.000847063 0.436846
84 61 16 0.00128539 0.000496937 0.000759754 0.553296 0.00133043 0.000553918 0.000812759 0.516887
84 60 16 0.00128823 0.00053104 0.000783438 0.53335 0.00134452 0.000506174 0.000785624 0.563432
84 60 17 0.00126802 0.000460207 0.000729479 0.58859 0.00133849 0.000496096 0.000776899 0.570689
84 59 17 0.00108238 0.000373869 0.000610039 0.629474 0.00133839 0.000466135 0.00075689 0.597466
84 58 17 0.00130795 0.000494729 0.000765803 0.58186 0.00140401 0.000490494 0.000795002 0.591723
84 57 18 0.00107557 0.000464563 0.000668231 0.525115 0.00141309 0.000503638 0.000806786 0.580816
84 56 18 0.00112712 0.000392396 0.000637304 0.612159 0.00142693 0.000501972 0.000810288 0.593075
84 55 19 0.00110705 0.000536791 0.000726878 0.47699 0.0014481 0.000521233 0.000830186 0.580617
84 54 19 0.00131515 0.000501804 0.000772919 0.560854 0.00149121 0.000514767 0.000840246 0.591875
84 53 19 0.00141376 0.000488109 0.000796661 0.592974 0.00151916 0.00050704 0.000844416 0.603714
84 53 20 0.00119967 0.000528667 0.000752334 0.515978 0.00151852 0.000501309 0.000840379 0.609157
84 52 20 0.00120838 0.000496335 0.000733684 0.545742 0.00151907 0.000506619 0.0008441 0.607991
84 51 21 0.0011066 0.000545991 0.000732861 0.48208 0.00145287 0.000537145 0.000842389 0.566021
83 50 21 0.00148025 0.000517207 0.000838221 0.591659 0.00143009 0.000558962 0.00084934 0.541725
83 49 21 0.00144729 0.000608569 0.000888142 0.504581 0.00143929 0.000580943 0.000867057 0.523038
83 48 21 0.00140066 0.000648933 0.000899507 0.45017 0.00146562 0.000588808 0.000881079 0.52329
82 47 22 0.00179437 0.000560765 0.000971966 0.632207 0.00152193 0.000564541 0.00088367 0.560292
82 46 22 0.00140457 0.000546434 0.00083248 0.540164 0.00148664 0.000549511 0.000861887 0.56362
81 45 22 0.00165706 0.000706209 0.00102316 0.494609 0.00148319 0.000559383 0.000867323 0.558307
80 44 23 0.00174696 0.000418429 0.000861272 0.723202 0.0014574 0.00058681 0.000877008 0.532129
80 43 23 0.00146997 0.000619092 0.000902717 0.497525 0.00140823 0.000612242 0.000877576 0.493454
79 42 23 0.00152992 0.000444628 0.000806391 0.661404 0.00139555 0.000603363 0.000867423 0.492408
78 41 23 0.00157958 0.000555758 0.000897033 0.592812 0.00138554 0.0005864 0.000852775 0.498505
78 40 24 0.00169536 0.000341967 0.000793098 0.769893 0.00136858 0.00057877 0.000842035 0.494142
77 39 24 0.00176535 0.000454217 0.000891263 0.699291 0.00136671 0.000564577 0.000831952 0.504254
76 39 24 0.00181275 0.000391344 0.000865146 0.750689 0.00138579 0.00055527 0.000832107 0.517531
76 38 25 0.00177161 0.000446334 0.000888092 0.705912 0.00138728 0.000545684 0.000826213 0.523804
75 37 25 0.00186546 0.000517308 0.000966693 0.673821 0.0013714 0.000562255 0.000831969 0.506898
74 36 25 0.00161531 0.000582424 0.000926721 0.575432 0.00135436 0.000571873 0.000832701 0.492641
74 35 25 0.00158317 0.000631253 0.000948557 0.529855 0.00134491 0.000573929 0.000830925 0.489379
73 34 25 0.00146608 0.000741013 0.000982702 0.410368 0.00134846 0.000580893 0.000836751 0.486019
72 34 25 0.00118521 0.000661327 0.000835955 0.367785 0.00134222 0.000586273 0.000838257 0.478949
72 33 25 0.00120423 0.000714338 0.000877636 0.354421 0.00133965 0.000594724 0.000843032 0.47204
# pathway end

This text file contains various diffusion measures, one row for each position along the trajectory of the path. The first three entries in each row are the x, y, z coordinates in native diffusion space. The next four entries are the axial diffusivity, radial diffusivity, mean diffusivity, and fractional anisotropy at that position on the maximum a posteriori path. The last four entries are the axial diffusivity, radial diffusivity, mean diffusivity, and fractional anisotropy at the same position, averaged over all sampled paths.

Points are always ordered in the following way:

Converting pathstats.byvoxel.txt files to a table for group analyses

The pathstats.byvoxel.txt files will generally not contain the same number of positions (rows) for each subject because the tracts are reconstructed in each subject's native diffusion space and not in a template space. Thus they are not ready for performing group analyses yet. To combine these files from multiple subjects, interpolating the anisotropy and diffusivity values at corresponding positions along the tract for all subjects, run the following:

trac-all -stat -c $TUTORIAL_DATA/diffusion_tutorial/dmrirc.tutorial

This will create a directory named stats under the main TRACULA output directory and save one table per tract per diffusion measure. In these tables, each row is a different position along the trajectory of the tract and each column is a different subject.

To examine the table of average FA along the left ILF, do the following:

gedit $TUTORIAL_DATA/diffusion_tutorial/stats/lh.ilf_AS.avg33_mni_bbr.FA_Avg.txt &

ON MACS, RUN:

open -e $TUTORIAL_DATA/diffusion_tutorial/stats/lh.ilf_AS.avg33_mni_bbr.FA_Avg.txt &

The contents of this file will look like this:

elmo.2005 elmo.2008 elmo.2012
NaN NaN 0.378069
NaN NaN 0.378492
0.41336 NaN 0.388788
0.429444 0.377014 0.4164
0.444207 0.392511 0.438363
0.452544 0.394491 0.445661
0.449954 0.388662 0.435143
0.447727 0.407221 0.426532
0.432298 0.428718 0.421008
0.419581 0.425808 0.403944
0.473702 0.40381 0.371384
0.494473 0.387531 0.353198
0.4767 0.414657 0.366791
0.506063 0.453886 0.412596
0.583493 0.519466 0.483278
0.624087 0.57846 0.549247
0.647596 0.600432 0.569196
...

The first row tells you the subject name for the corresponding column of FA values. Note that for some data sets, there will be some NaN ("not a number") values in the beginning or end of the tract, because the tract has a slightly different length for each data set and the endings will not always correspond. For the purposes of a statistical analysis, you can ignore the endings, use only the data points that are not NaN, or pool together the data points from the first few or last few positions.

From here, you could use these stats tables to run a group analysis on the tracts.

Note: In addition to the above tables, the stats directory will also contain a log file for each pathway. You can examine the log file, which contains the full output of the trac-all -stat command, to see if any pathways were flagged as outliers. If this happens, there will be a line in the log file with "Found outlier path:" and the name of the subject. These are paths that were found to differ excessively from those of the other subjects. You can check this information to find out if the reconstruction of this tract failed for any subjects.

For example, you can examine the log file for the left ILF by doing:

gedit $TUTORIAL_DATA/diffusion_tutorial/stats/lh.ilf_AS.avg33_mni_bbr.log &

ON MACS, RUN:

open -e  $TUTORIAL_DATA/diffusion_tutorial/stats/lh.ilf_AS.avg33_mni_bbr.log &

Visualizing results from statistical analyses along each pathway

The trac-all -stat command will also produce average paths in template space (MNI or CVS, depending on what was specified for the inter-subject registration method). These paths can be used to visualize the outputs of statistical analyses along each of the 18 tracts. Note that these average paths are only produced for visualization purposes and their existence does not imply that a voxel-based analysis was performed in template space in these coordinates. (Remember that TRACULA performs both the tractography and the extraction of anisotropy and diffusivity measures in the native diffusion space of each subject.)

To view all 18 mean paths in the space of the MNI template, run the following:

freeview -v $FSLDIR/data/standard/MNI152_T1_1mm_brain.nii.gz \
         -w $TUTORIAL_DATA/diffusion_tutorial/stats/*.path.mean.txt

You should see something like this in the 3D view:

path.waypts.jpg

The following information is based on hypothetical statistical data. The text file of p-values is not available so do not expect your end result to look identical to this image.

Let's say that you have performed a statistical analysis on your subjects in your statistical software of choice. If you save the p-values corresponding to each position along a tract to a simple text file, you can now display these p-values as a heat map on the corresponding mean path. (It is assumed that the number of p-values in your text file is equal to the number of points on the mean path, which is the same as the number of rows of values in the group tables produced by trac-all -stat. If not, display may be problematic.)

To display the p-values from your hypothetical analysis on one of the mean paths, do the following:

You can do this for as many of the tracts as you have performed statistical analyses on. The end result will look something like this in the 3D view:

path.waypts.p.jpg


Summary

By the end of this page, you should know how to:


Quiz

You can test your knowledge of this tutorial by clicking here for a quiz!


Back to list of all tutorials | Back to course page | Previous

FsTutorial/TraculaStatistics (last edited 2019-03-26 10:35:48 by MorganFogarty)