Differences between revisions 9 and 67 (spanning 58 versions)
Revision 9 as of 2011-03-30 15:27:17
Size: 6889
Comment:
Revision 67 as of 2013-12-06 08:34:19
Size: 16080
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
== Tract Statistics ==

This section of the tutorial will teach you to extract Statistical measures along the major White Matter tracts reconstructed by Tracula. There are two types of statistics files that are output for each White Matter Tract
 * path.overall.txt - This file gives Diffusion measures along the whole WM tract
 * path.byvoxel.txt - This files gives Diffusion measures for each voxel along the WM tract.

To view the statistics files from Tracula for for the subject Diff001 (Left Cortico-Spinal Tract), type the following in the terminal
----
{{{
cd $TUTORIAL_DATA/diffusion_tutorial/Diff001/dpath/5cpts/priorcvs/seg14/initmni/regbbr/lh.cst_AS_avg23_cvs_bbr/
less path.overall.txt
less path.byvoxel.txt
}}}
----

== path.overall.txt ==

This text file gives various diffusion measures about the specific white matter tract along its complete path. Some of the measures include:
 * Count of the # of Fibers in the WM tract
 * Tract Volume
 * Maximum, Minimum and Average length of fibers
 * Length of the center fiber
 * Axial Diffusivity (both average and along the center)
 * Radial Diffusivity (both average and along the center)
 * Mean Diffusivity (both average and along the center)
 * Fractional Anisotropy (both average and along the center)

----
## page was renamed from FsTutorial/TractStatistics
[[FsTutorial|Top]] | [[FsTutorial/TraculaOutputs|Previous]]

= Tract statistics =
=== Remember... ===
For '''each new''' terminal that you open, you must do:

{{{
setenv 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:

 * pathstats.overall.txt - This file contains measures averaged over the whole pathway
 * pathstats.byvoxel.txt - This file contains measures as a function of position along the trajectory of the 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, are, respectively:

{{{
$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 &
}}}

This file will look like this:
Line 32: Line 38:
# generating_program $FREESURFER_HOME/bin/dmri_pathstats # generating_program /usr/local/freesurfer/dev/bin/dmri_pathstats
Line 34: Line 40:
# cmdline $FREESURFER_HOME/bin/dmri_pathstats --intrc $TUTORIAL_DATA/diffusion_tutorial/Diff001/dpath/5cpts/priorcvs/seg14/initmni/regbbr/lh.cst_AS_avg23_cvs_bbr --dtbase $TUTORIAL_DATA/diffusion_tutorial/Diff001/dmri/dtifit --path lh.cst --subj Diff001 --out $TUTORIAL_DATA/diffusion_tutorial/Diff001/dpath/5cpts/priorcvs/seg14/initmni/regbbr/lh.cst_AS_avg23_cvs_bbr/pathstats.overall.txt --outvox $TUTORIAL_DATA/diffusion_tutorial/Diff001/dpath/5cpts/priorcvs/seg14/initmni/regbbr/lh.cst_AS_avg23_cvs_bbr/pathstats.byvoxel.txt # cmdline /usr/local/freesurfer/dev/bin/dmri_pathstats --intrc /space/freesurfer/subjects/diffusion_tutorial/elmo.2012/dpath/lh.ilf_AS_avg33_mni_bbr --dtbase /space/freesurfer/subjects/diffusion_tutorial/elmo.2012/dmri/dtifit --path lh.ilf --subj elmo.2012 --out /space/freesurfer/subjects/diffusion_tutorial/elmo.2012/dpath/lh.ilf_AS_avg33_mni_bbr/pathstats.overall.txt --outvox /space/freesurfer/subjects/diffusion_tutorial/elmo.2012/dpath/lh.ilf_AS_avg33_mni_bbr/pathstats.byvoxel.txt
Line 36: Line 42:
# hostname compute-0-1.local # hostname compute-0-29
Line 38: Line 44:
# user rspriti # user ayendiki
Line 41: Line 47:
# subjectname Diff001
# pathwayname lh.cst
#
Count 100
Volume 235
Len_Min 45
Len_Max 69
Len_Avg 55.3
Len_Center 53
AD_Avg 0.00108402
AD_Avg_Weight 0.00107521
AD_Avg_Center 0.00107062
RD_Avg 0.00046958
RD_Avg_Weight 0.000476065
RD_Avg_Center 0.000507009
MD_Avg 0.000674393
MD_Avg_Weight 0.000675781
MD_Avg_Center 0.000694881
FA_Avg 0.50122
FA_Avg_Weight 0.48976
FA_Avg_Center 0.456292
}}}
----
== path.byvoxel.txt ==

This text file gives us various diffusion measures in each voxel along the WM tract
----
{{{
# subjectname elmo.2012
# pathwayname lh.ilf
#
Count 1500
Volume 167
Len_Min 29
Len_Max 64
Len_Avg 45.008
Len_Center 37
AD_Avg 0.00131194
AD_Avg_Weight 0.00139891
AD_Avg_Center 0.001268
RD_Avg 0.000686486
RD_Avg_Weight 0.000770628
RD_Avg_Center 0.000635293
MD_Avg 0.00089497
MD_Avg_Weight 0.000980054
MD_Avg_Center 0.000846196
FA_Avg 0.414059
FA_Avg_Weight 0.392266
FA_Avg_Center 0.408256
}}}

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

 * Number of sample paths in the WM tract
 * Tract volume (in voxels)
 * Maximum, minimum and average length of sample paths
 * Length of the highest-probability (a.k.a. maximum a posteriori) path
 * Axial diffusivity (average over the entire support of the path distribution, weighted average over the entire support of the path distribution, and average over highest-probability path only)
 * Radial diffusivity (as above)
 * Mean diffusivity (as above)
 * Fractional anisotropy (as above)

=== 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
}}}
 * The argument to the {{{--inputs}}} option specifies the input stats file.
 * The {{{--overall}}} option tells tractstats2table to expect the overall path stats file (stats averaged over the entire left ILF), as opposed to the stats along the trajectory of the tract (which would be specified with the {{{--byvoxel}}} option instead).
 * The argument to the {{{--tablefile}}} option specifies the output file.

Take a look at the resulting table file:

{{{
gedit $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 that contains the list above and name it as follows:

{{{
gedit $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
}}}
 * The argument to the {{{--load-pathstats-from-file}}} option specifies the text file that contains the list of all the statistics files that will be loaded.

Take a look at the resulting table file:

{{{
gedit $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
}}}
 * The argument to the {{{--only-measures}}} option specifies which measure we want to extract from the statistics files. Instead of FA_Avg, this could be the name of any of the measures included in {{{pathstats.overall.txt.}}}

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:

{{{
oocalc $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 &
}}}
It will look like this:

{{{
Line 72: Line 155:
# generating_program $FREESURFER_HOME/dmri_pathstats # generating_program /usr/local/freesurfer/dev/bin/dmri_pathstats
Line 74: Line 157:
# cmdline $FREESURFER_HOME/dmri_pathstats --intrc $TUTORIAL_DATA/diffusion_tutorial/Diff001/dpath/5cpts/priorcvs/seg14/initmni/regbbr/lh.cst_AS_avg23_cvs_bbr --dtbase $TUTORIAL_DATA/diffusion_tutorial/Diff001/dmri/dtifit --path lh.cst --subj Diff001 --out $TUTORIAL_DATA/diffusion_tutorial/Diff001/dpath/5cpts/priorcvs/seg14/initmni/regbbr/lh.cst_AS_avg23_cvs_bbr/pathstats.overall.txt --outvox $TUTORIAL_DATA/diffusion_tutorial/Diff001/dpath/5cpts/priorcvs/seg14/initmni/regbbr/lh.cst_AS_avg23_cvs_bbr/pathstats.byvoxel.txt # cmdline /usr/local/freesurfer/dev/bin/dmri_pathstats --intrc /space/freesurfer/subjects/diffusion_tutorial/elmo.2012/dpath/lh.ilf_AS_avg33_mni_bbr --dtbase /space/freesurfer/subjects/diffusion_tutorial/elmo.2012/dmri/dtifit --path lh.ilf --subj elmo.2012 --out /space/freesurfer/subjects/diffusion_tutorial/elmo.2012/dpath/lh.ilf_AS_avg33_mni_bbr/pathstats.overall.txt --outvox /space/freesurfer/subjects/diffusion_tutorial/elmo.2012/dpath/lh.ilf_AS_avg33_mni_bbr/pathstats.byvoxel.txt
Line 76: Line 159:
# hostname compute-0-1.local # hostname compute-0-29
Line 78: Line 161:
# user rspriti # user ayendiki
Line 81: Line 164:
# subjectname Diff001
# pathwayname lh.cst
# subjectname elmo.2012
# pathwayname lh.ilf
Line 85: Line 168:
x y z AD RD MD FA
62 63 10 0.000637887 0.000476948 0.000530594 0.178865
62 63 11 0.0006074 0.000433505 0.00049147 0.22773
63 63 12 0.000846852 0.000610935 0.000689574 0.251636
63 64 13 0.00123916 0.00105259 0.00111478 0.107897
63 64 14 0.000936783 0.000621757 0.000726766 0.264886
64 64 15 0.000869413 0.000500918 0.00062375 0.348479
64 64 16 0.000742746 0.000432898 0.000536181 0.357518
65 64 16 0.000729103 0.000361411 0.000483975 0.42985
66 65 17 0.000645165 0.000105291 0.000285249 0.86012
67 65 18 0.00115478 0.000351219 0.000619072 0.647404
68 66 19 0.00142292 0.000690686 0.000934763 0.432432
69 66 20 0.00166259 0.000912869 0.00116278 0.363279
69 66 21 0.00145087 0.000448438 0.000782583 0.639517
70 66 22 0.00124617 0.000204701 0.000551856 0.816332
70 66 23 0.00138642 0.000415134 0.000738896 0.650657
71 66 23 0.00136252 0.000330065 0.000674217 0.721118
71 66 24 0.00134187 0.000385197 0.000704089 0.678151
71 66 25 0.00108983 0.000289931 0.000556565 0.729769
72 66 26 0.00106165 0.000357968 0.000592529 0.650427
72 66 27 0.00117242 0.000398032 0.00065616 0.619191
73 65 28 0.00130606 0.000441963 0.000729994 0.61662
73 65 29 0.00132239 0.00034928 0.000673651 0.701421
74 65 30 0.00133145 0.000391918 0.000705096 0.652609
74 65 31 0.00130265 0.000371743 0.000682045 0.665608
74 65 32 0.00126357 0.000429947 0.000707822 0.596254
75 65 33 0.00126146 0.000533254 0.000775991 0.499365
75 64 34 0.00117235 0.000465188 0.00070091 0.536046
75 64 35 0.00111144 0.000424831 0.000653701 0.560041
76 64 36 0.00128036 0.000299521 0.000626469 0.731721
76 64 37 0.00119495 0.000322181 0.000613105 0.688909
76 64 38 0.00105691 0.000334124 0.000575053 0.64994
76 63 39 0.00106784 0.000449252 0.000655449 0.514129
76 63 40 0.00113234 0.000537139 0.000735539 0.463226
76 63 41 0.000990485 0.000493054 0.000658864 0.446701
76 63 42 0.000798778 0.000477672 0.000584708 0.336071
76 62 43 0.000870652 0.000483175 0.000612334 0.362795
75 62 44 0.000878542 0.000493417 0.000621792 0.376378
75 62 45 0.000897465 0.000514559 0.000642194 0.348244
75 61 46 0.000882752 0.000537658 0.000652689 0.310019
74 61 47 0.00100985 0.00048457 0.000659663 0.436199
74 61 48 0.00104135 0.000461786 0.000654973 0.482846
74 60 49 0.000957188 0.000488566 0.000644774 0.472547
73 60 50 0.00100422 0.00055232 0.000702954 0.378698
73 60 51 0.000938077 0.000492242 0.000640854 0.429111
72 59 52 0.00104503 0.000475882 0.000665599 0.474443
72 59 53 0.00091483 0.00047261 0.000620017 0.409087
72 59 54 0.000792557 0.000632776 0.000686036 0.174565
71 59 55 0.000961412 0.000680667 0.000774249 0.243739
71 58 56 0.001061 0.000895478 0.000950651 0.133396
70 58 57 0.000862592 0.000663684 0.000729986 0.162365
70 58 58 0.00119199 0.00103056 0.00108437 0.086213
69 57 59 0.00120589 0.000980809 0.00105584 0.127098
69 57 60 0.00102806 0.000829161 0.000895461 0.141788
x y z AD RD MD FA AD_Avg RD_Avg MD_Avg FA_Avg
86 71 16 0.00124639 0.000810355 0.000955702 0.296343 0.00124166 0.000683586 0.000869599 0.375502
86 72 15 0.000758499 0.000690337 0.000713058 0.0665528 0.00120352 0.000674202 0.00085063 0.365702
85 72 14 0.000819579 0.000601256 0.00067403 0.196614 0.00111348 0.000618912 0.00078378 0.353662
84 72 13 0.000970979 0.00067094 0.000770953 0.227346 0.00115739 0.000679319 0.000838683 0.329086
84 71 13 0.0010519 0.000845654 0.000914402 0.174291 0.00117946 0.000675255 0.000843332 0.342993
84 70 13 0.00122524 0.00075747 0.000913395 0.295734 0.00127004 0.000700568 0.00089039 0.368428
84 69 13 0.0013762 0.000607907 0.000864005 0.475513 0.00130121 0.000666051 0.000877759 0.405086
83 68 14 0.00117165 0.000572571 0.000772264 0.433612 0.00127088 0.000631783 0.000844803 0.427719
83 67 14 0.00122987 0.000573616 0.000792367 0.452554 0.00123866 0.000625767 0.000830053 0.422219
83 66 14 0.00120132 0.000599483 0.000800095 0.411401 0.00118774 0.00062832 0.000814796 0.408966
83 65 14 0.00130532 0.000741545 0.000929471 0.341101 0.00117765 0.000649599 0.000825623 0.38951
83 64 15 0.00113069 0.000744614 0.000873306 0.303024 0.00124994 0.000716112 0.000894054 0.35574
83 63 15 0.00145392 0.000843014 0.00104665 0.338389 0.00160184 0.000956015 0.00117128 0.342898
83 62 15 0.00150758 0.000704525 0.000972208 0.454268 0.00184354 0.00110231 0.0013494 0.361096
82 61 15 0.00168556 0.000719335 0.00104141 0.500387 0.00187725 0.00105482 0.00132898 0.413339
82 60 16 0.00149165 0.000655993 0.000934546 0.482961 0.00174103 0.000915708 0.00119082 0.459582
82 59 16 0.00178469 0.000676534 0.00104592 0.547817 0.00181009 0.000942766 0.00123188 0.47797
82 58 16 0.00187731 0.000555021 0.000995783 0.650825 0.00176598 0.000879462 0.00117498 0.482668
82 57 17 0.00136583 0.000342585 0.000683666 0.706805 0.00183719 0.00101521 0.00128919 0.444575
82 56 17 0.00149454 0.000361014 0.000738857 0.718399 0.00172875 0.000879471 0.00116258 0.466697
82 55 17 0.00164246 0.000404404 0.000817091 0.714028 0.00143606 0.000654734 0.000915172 0.485324
81 54 17 0.00110069 0.000505138 0.000703656 0.462108 0.00123971 0.000546461 0.000777551 0.491684
81 53 18 0.00149581 0.000503958 0.000834577 0.601599 0.00138836 0.000547033 0.000827479 0.539068
81 52 18 0.00130913 0.000454745 0.00073954 0.597531 0.00133457 0.000539894 0.000804789 0.533393
81 51 18 0.00131507 0.000631822 0.000859572 0.448947 0.00131177 0.000606845 0.000841826 0.469117
81 50 18 0.00135444 0.000747886 0.000950069 0.362522 0.00129975 0.000659834 0.000873148 0.416883
81 49 18 0.00120955 0.000643043 0.000831879 0.404422 0.00126551 0.00064144 0.000849466 0.418424
80 48 19 0.00140649 0.000619495 0.000881827 0.476057 0.00134196 0.000607405 0.000852266 0.47251
80 47 19 0.00124703 0.00054436 0.000778584 0.493392 0.00129913 0.000595745 0.000830194 0.470203
80 46 19 0.00123713 0.000562425 0.000787325 0.473597 0.00131166 0.000608192 0.000842689 0.465411
80 45 19 0.00131702 0.000638351 0.000864576 0.436198 0.00131184 0.000638683 0.000863079 0.443722
79 44 20 0.000961184 0.000655564 0.000757438 0.251941 0.00120554 0.000691043 0.000862543 0.349984
79 43 20 0.00104516 0.000760429 0.000855339 0.211843 0.00118236 0.000713172 0.000869568 0.323664
79 42 20 0.0010671 0.000695726 0.000819518 0.290868 0.00118518 0.000688767 0.000854257 0.347132
79 41 20 0.000951325 0.000643122 0.000745857 0.290616 0.00115072 0.000662836 0.000825473 0.352023
80 40 20 0.00111846 0.000771887 0.00088741 0.232294 0.00118544 0.000701789 0.000863008 0.328079
81 40 20 0.000989299 0.000649715 0.00076291 0.283576 0.00114976 0.000669422 0.000829546 0.343642
Line 141: Line 208:
----

These two files can be used to extract measures that can be further used group analysis.

This can also be converted into a table using tractstats2table for doing GLM analyses using mri_glmfit or any other statistical software (SPSS, Excel, Statview etc)

To convert the path.overall.txt for the above tract into a table that can be used by mri_glmfit, do the following

----
{{{
cd $TUTORIAL_DATA/diffusion_tutorial/Diff001/dpath/5cpts/priorcvs/seg14/initmni/regbbr/lh.cst_AS_avg23_cvs_bbr/
 
# To extract all diffusion measures into a table do the following

tractstats2table

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.

=== 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 &
}}}

The contents of this file will look like this:

{{{
elmo.2005 elmo.2008 elmo.2012
NaN 0.335817 NaN
0.373068 0.35773 0.263802
0.37555 0.372835 0.280039
0.389334 0.373771 0.304207
0.403752 0.36399 0.340167
0.418984 0.363519 0.333422
0.433291 0.378936 0.356918
0.441835 0.397896 0.355258
0.432407 0.398355 0.356802
0.428443 0.399408 0.381642
0.428464 0.406425 0.410158
0.417515 0.415535 0.428911
...
}}}

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 &
}}}


=== 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
}}}


[[FsTutorial/Diffusion|Top]] | [[FsTutorial/TraculaOutputs|Previous]]

Top | Previous

Tract statistics

Remember...

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

setenv 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:

  • pathstats.overall.txt - This file contains measures averaged over the whole pathway
  • pathstats.byvoxel.txt - This file contains measures as a function of position along the trajectory of the 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, are, respectively:

$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 &

This file will look like this:

# Title Pathway Statistics
#
# generating_program /usr/local/freesurfer/dev/bin/dmri_pathstats
# cvs_version 
# cmdline /usr/local/freesurfer/dev/bin/dmri_pathstats --intrc /space/freesurfer/subjects/diffusion_tutorial/elmo.2012/dpath/lh.ilf_AS_avg33_mni_bbr --dtbase /space/freesurfer/subjects/diffusion_tutorial/elmo.2012/dmri/dtifit --path lh.ilf --subj elmo.2012 --out /space/freesurfer/subjects/diffusion_tutorial/elmo.2012/dpath/lh.ilf_AS_avg33_mni_bbr/pathstats.overall.txt --outvox /space/freesurfer/subjects/diffusion_tutorial/elmo.2012/dpath/lh.ilf_AS_avg33_mni_bbr/pathstats.byvoxel.txt 
# sysname Linux
# hostname compute-0-29
# machine x86_64
# user ayendiki
# anatomy_type pathway
#
# subjectname elmo.2012
# pathwayname lh.ilf
#
Count 1500
Volume 167
Len_Min 29
Len_Max 64
Len_Avg 45.008
Len_Center 37
AD_Avg 0.00131194
AD_Avg_Weight 0.00139891
AD_Avg_Center 0.001268
RD_Avg 0.000686486
RD_Avg_Weight 0.000770628
RD_Avg_Center 0.000635293
MD_Avg 0.00089497
MD_Avg_Weight 0.000980054
MD_Avg_Center 0.000846196
FA_Avg 0.414059
FA_Avg_Weight 0.392266
FA_Avg_Center 0.408256

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

  • Number of sample paths in the WM tract
  • Tract volume (in voxels)
  • Maximum, minimum and average length of sample paths
  • Length of the highest-probability (a.k.a. maximum a posteriori) path
  • Axial diffusivity (average over the entire support of the path distribution, weighted average over the entire support of the path distribution, and average over highest-probability path only)
  • Radial diffusivity (as above)
  • Mean diffusivity (as above)
  • Fractional anisotropy (as above)

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
  • The argument to the --inputs option specifies the input stats file.

  • The --overall option tells tractstats2table to expect the overall path stats file (stats averaged over the entire left ILF), as opposed to the stats along the trajectory of the tract (which would be specified with the --byvoxel option instead).

  • The argument to the --tablefile option specifies the output file.

Take a look at the resulting table file:

gedit $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 that contains the list above and name it as follows:

gedit $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
  • The argument to the --load-pathstats-from-file option specifies the text file that contains the list of all the statistics files that will be loaded.

Take a look at the resulting table file:

gedit $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
  • The argument to the --only-measures option specifies which measure we want to extract from the statistics files. Instead of FA_Avg, this could be the name of any of the measures included in pathstats.overall.txt.

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:

oocalc $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 &

It will look like this:

# Title Pathway Statistics
#
# generating_program /usr/local/freesurfer/dev/bin/dmri_pathstats
# cvs_version 
# cmdline /usr/local/freesurfer/dev/bin/dmri_pathstats --intrc /space/freesurfer/subjects/diffusion_tutorial/elmo.2012/dpath/lh.ilf_AS_avg33_mni_bbr --dtbase /space/freesurfer/subjects/diffusion_tutorial/elmo.2012/dmri/dtifit --path lh.ilf --subj elmo.2012 --out /space/freesurfer/subjects/diffusion_tutorial/elmo.2012/dpath/lh.ilf_AS_avg33_mni_bbr/pathstats.overall.txt --outvox /space/freesurfer/subjects/diffusion_tutorial/elmo.2012/dpath/lh.ilf_AS_avg33_mni_bbr/pathstats.byvoxel.txt 
# sysname Linux
# hostname compute-0-29
# machine x86_64
# user ayendiki
# 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
86 71 16 0.00124639 0.000810355 0.000955702 0.296343 0.00124166 0.000683586 0.000869599 0.375502
86 72 15 0.000758499 0.000690337 0.000713058 0.0665528 0.00120352 0.000674202 0.00085063 0.365702
85 72 14 0.000819579 0.000601256 0.00067403 0.196614 0.00111348 0.000618912 0.00078378 0.353662
84 72 13 0.000970979 0.00067094 0.000770953 0.227346 0.00115739 0.000679319 0.000838683 0.329086
84 71 13 0.0010519 0.000845654 0.000914402 0.174291 0.00117946 0.000675255 0.000843332 0.342993
84 70 13 0.00122524 0.00075747 0.000913395 0.295734 0.00127004 0.000700568 0.00089039 0.368428
84 69 13 0.0013762 0.000607907 0.000864005 0.475513 0.00130121 0.000666051 0.000877759 0.405086
83 68 14 0.00117165 0.000572571 0.000772264 0.433612 0.00127088 0.000631783 0.000844803 0.427719
83 67 14 0.00122987 0.000573616 0.000792367 0.452554 0.00123866 0.000625767 0.000830053 0.422219
83 66 14 0.00120132 0.000599483 0.000800095 0.411401 0.00118774 0.00062832 0.000814796 0.408966
83 65 14 0.00130532 0.000741545 0.000929471 0.341101 0.00117765 0.000649599 0.000825623 0.38951
83 64 15 0.00113069 0.000744614 0.000873306 0.303024 0.00124994 0.000716112 0.000894054 0.35574
83 63 15 0.00145392 0.000843014 0.00104665 0.338389 0.00160184 0.000956015 0.00117128 0.342898
83 62 15 0.00150758 0.000704525 0.000972208 0.454268 0.00184354 0.00110231 0.0013494 0.361096
82 61 15 0.00168556 0.000719335 0.00104141 0.500387 0.00187725 0.00105482 0.00132898 0.413339
82 60 16 0.00149165 0.000655993 0.000934546 0.482961 0.00174103 0.000915708 0.00119082 0.459582
82 59 16 0.00178469 0.000676534 0.00104592 0.547817 0.00181009 0.000942766 0.00123188 0.47797
82 58 16 0.00187731 0.000555021 0.000995783 0.650825 0.00176598 0.000879462 0.00117498 0.482668
82 57 17 0.00136583 0.000342585 0.000683666 0.706805 0.00183719 0.00101521 0.00128919 0.444575
82 56 17 0.00149454 0.000361014 0.000738857 0.718399 0.00172875 0.000879471 0.00116258 0.466697
82 55 17 0.00164246 0.000404404 0.000817091 0.714028 0.00143606 0.000654734 0.000915172 0.485324
81 54 17 0.00110069 0.000505138 0.000703656 0.462108 0.00123971 0.000546461 0.000777551 0.491684
81 53 18 0.00149581 0.000503958 0.000834577 0.601599 0.00138836 0.000547033 0.000827479 0.539068
81 52 18 0.00130913 0.000454745 0.00073954 0.597531 0.00133457 0.000539894 0.000804789 0.533393
81 51 18 0.00131507 0.000631822 0.000859572 0.448947 0.00131177 0.000606845 0.000841826 0.469117
81 50 18 0.00135444 0.000747886 0.000950069 0.362522 0.00129975 0.000659834 0.000873148 0.416883
81 49 18 0.00120955 0.000643043 0.000831879 0.404422 0.00126551 0.00064144 0.000849466 0.418424
80 48 19 0.00140649 0.000619495 0.000881827 0.476057 0.00134196 0.000607405 0.000852266 0.47251
80 47 19 0.00124703 0.00054436 0.000778584 0.493392 0.00129913 0.000595745 0.000830194 0.470203
80 46 19 0.00123713 0.000562425 0.000787325 0.473597 0.00131166 0.000608192 0.000842689 0.465411
80 45 19 0.00131702 0.000638351 0.000864576 0.436198 0.00131184 0.000638683 0.000863079 0.443722
79 44 20 0.000961184 0.000655564 0.000757438 0.251941 0.00120554 0.000691043 0.000862543 0.349984
79 43 20 0.00104516 0.000760429 0.000855339 0.211843 0.00118236 0.000713172 0.000869568 0.323664
79 42 20 0.0010671 0.000695726 0.000819518 0.290868 0.00118518 0.000688767 0.000854257 0.347132
79 41 20 0.000951325 0.000643122 0.000745857 0.290616 0.00115072 0.000662836 0.000825473 0.352023
80 40 20 0.00111846 0.000771887 0.00088741 0.232294 0.00118544 0.000701789 0.000863008 0.328079
81 40 20 0.000989299 0.000649715 0.00076291 0.283576 0.00114976 0.000669422 0.000829546 0.343642
# 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.

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 &

The contents of this file will look like this:

elmo.2005 elmo.2008 elmo.2012 
NaN 0.335817 NaN 
0.373068 0.35773 0.263802 
0.37555 0.372835 0.280039 
0.389334 0.373771 0.304207 
0.403752 0.36399 0.340167 
0.418984 0.363519 0.333422 
0.433291 0.378936 0.356918 
0.441835 0.397896 0.355258 
0.432407 0.398355 0.356802 
0.428443 0.399408 0.381642 
0.428464 0.406425 0.410158 
0.417515 0.415535 0.428911 
...

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 &

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

Top | Previous

FsTutorial/TraculaStatistics (last edited 2023-07-17 02:37:25 by AnastasiaYendiki)