Differences between revisions 47 and 97 (spanning 50 versions)
Revision 47 as of 2009-01-15 18:17:17
Size: 16430
Comment:
Revision 97 as of 2013-11-01 14:32:41
Size: 20867
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
## page was renamed from FsTutorial/AnatomicalROI
Line 3: Line 4:
= Anatomical ROI analysis =

This tutorial gives a brief introduction to anatomical ROI analysis which includes working with label files, extracting ROI measures from the anatomical data, group statistics etc.
Line 5: Line 10:
= Anatomical ROI analysis =

This tutorial gives a brief introduction to anatomical ROI analysis which includes working with label files, extracting ROI measures from the anatomical data, group statistics etc.
Make sure you have set your SUBJECTS_DIR to correct location as
----
{{{
setenv SUBJECTS_DIR <path_to_data>
}}}
----
== Preparations ==
=== If You're at an Organized Course ===
If you are taking one of the formally organized courses, everything has been set up for you on the provided laptop. The only thing you will need to do is run the following commands in ''every'' '''new''' terminal window (aka shell) you open throughout this tutorial. Copy and paste the commands below to get started:

{{{
setenv SUBJECTS_DIR $TUTORIAL_DATA/buckner_data/tutorial_subjs/group_analysis_tutorial
cd $SUBJECTS_DIR
}}}
''To copy: Highlight the command in the box above, right click and select copy (or use keyboard shortcut Ctrl+c), then use the middle button of your mouse to click inside the terminal window (this will paste the command). Press enter to run the command.''

These two commands set the SUBJECTS_DIR variable to the directory where the data is stored and then navigates into this directory. You can now skip ahead to the tutorial (below the gray line).

=== If You're not at an Organized Course ===
If you are '''NOT''' taking one of the formally organized courses, then to follow this exercise exactly be sure you've downloaded the [[FsTutorial/Data|tutorial data set]] before you begin. If you choose not to download the data set you can follow these instructions on your own data, but you will have to substitute your own specific paths and subject names. These are the commands that you need to run before getting started:

{{{
tcsh
source your_freesurfer_dir/SetUpFreeSurfer.csh
setenv SUBJECTS_DIR $TUTORIAL_DATA/buckner_data/tutorial_subjs/group_analysis_tutorial
cd $SUBJECTS_DIR
}}}
Notice the command to open tcsh. If you are already running the tcsh command shell, then the 'tcsh' command is not necessary. If you are not using the tutorial data you should set your {{{SUBJECTS_DIR}}} to the directory in which the recon(s) of the subject(s) you will use for this tutorial are located.

--------
Line 17: Line 36:
In this exercise, you will examin a segmentation, parcellation, and color lookup table to understand how they are related.

Open the subject in tkmedit using the following command
In this exercise, you will examine a segmentation, parcellation, and color lookup table to understand how they are related.

Open the subject in tkmedit using the following command:
Line 29: Line 48:
setenv SUBJECTS_DIR $TUTORIAL_DATA/buckner_data/tutorial_subjs/group_analysis_tutorial
cd $SUBJECTS_DIR
Line 32: Line 53:
Finally, run the following command to display the contents of LUT Finally, run the following command to display the contents of LUT (in ''another'' new terminal window)
Line 38: Line 59:
Click [[FsTutorial/AnatomicalROI/FreeSurferColorLUT|here]] to view the contents of the file.

Things to do:
You can hit the 'Page Up' and 'Page Down' buttons to see the rest of the file. Or click [[FsTutorial/AnatomicalROI/FreeSurferColorLUT|here]] to view the contents of the file. (To exit the less command, hit the 'q' button.)

Things to do -- Navigating between tkmedit and LUT:
Line 42: Line 63:
  1. See the structure name in the tkmedit Tools window.
  1. Look at the Aux value in the tkmedit Tools window.
  1. Find value in the LUT, which you have opened using the command mentioned above.
  1. See the structure name in the tkmedit Tools window (under the Cursor section).
  1. Look at the Aux (aparc+aseg.mgz) value in the tkmedit Tools window. For example, it may say 1024.
  1. Find that value in the LUT, which you have opened using the command mentioned above.
Line 47: Line 68:
Things to do:
  1. Click on a point in tksurfer in the superior temporal gyrus.
  1. Note that the name displayed in the tksurfer Tools window does not have lh or rh in it.
Things to do -- Navigating between tksurfer, tkmedit and LUT:
  1. Click on a point in tksurfer in the superior temporal gyrus. If you don't know it's location, you can hover over the different areas to see their label underneath the Mouse section of the Tools window.
  1. Note that the name displayed in the tksurfer Tools window does not have lh or rh in it. This is because you loaded only one hemisphere.
Line 51: Line 72:
  1. In tkmedit, click on Goto Point button {{attachment:icon_cursor_goto.gif}}.   1. In tkmedit, click on Goto Point button {{attachment:icon_cursor_goto.gif}} , which takes the cursor to the ROI. Zoom in to see the cursor.
Line 53: Line 74:
  1. The Aux value should be 1030.   1. The Aux (aparc+aseg.mgz) value should be 1030.
Line 56: Line 77:
You can close tkmedit and tksurfer once you are done. To get out of the less command, type 'q' for quit.
Line 60: Line 83:
To load an existing label, for example lh.BA45.label, run To map a label, such as the lh.BA45.label, from the fsaverage subject to a target subject, run
{{{
cd $SUBJECTS_DIR
mri_label2label \
  --srcsubject fsaverage \
  --srclabel fsaverage/label/lh.BA45.label \
  --trgsubject 004 \
  --trglabel 004/label/lh.BA45.label \
  --hemi lh \
  --regmethod surface
}}}

Although we used an existing label for the example above, you could draw a new label on fsaverage and map that to all your subjects so that it will appear in the same cortical region. To take a look at the contents of that newly created label file, run:
Line 66: Line 101:
To load a label in tkmedit, first load the subject you want to work on, in tkmedit. To load the label in tkmedit, first load the subject you want to work on, in tkmedit.
Line 72: Line 107:
Then on the tkmedit toolbar, go to '''File-> Label --> Load Label --> lh.BA45.label'''

{{attachment:label.jpg}}

To load the label in tksurfer, first load the subject.
Then on the menu bar at the top of tkmedit tools window, go to '''File --> Label --> Load Label --> Browse --> lh.BA45.label''' and hit 'OK' in both windows. The label is visible in coronal slice 153.

{{attachment:BAlabel.jpg}}

This label can be edited when the Select Voxels button is chosen. Use the middle mouse button to add to the label. Use the right mouse button to delete from the label. If this was your own subject, you would want to make sure you save your edits by going to '''File --> Label --> Save Label''' but it's not necessary for this tutorial.

To load the label in tksurfer, first load the subject (in another terminal window).
Line 82: Line 119:
On the tksurfer toolbar, go to '''File --> Label --> Load Label --> lh.BA45.label'''

{{attachment:tksurferlabel.jpg}}
On the menu bar at the top of tksurfer tools window, go to '''File --> Label --> Load Label --> Browse --> lh.BA45.label'''

{{attachment:BAlabel_tksurfer.jpg}}

Information on how to create and edit labels in tksurfer can be found on [[https://surfer.nmr.mgh.harvard.edu/fswiki/tksurfer_labeledit|this wiki]]. You don't have to do this for the tutorial, but please feel free to take a look if you are interested.
Line 88: Line 127:
During the normal FreeSurfer processing stream, via the recon-all script, [[http://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial|(a freesurfer tutorial is available.)]] some statistical output files are generated. They are kept in each subjects {{{stats/}}} subdirectory, and are a result of the subcortical segmentation, aseg, and the cortical parcellation, aparc. These tables include information on each labeled region for the individual subject. During the normal FreeSurfer processing stream, via the recon-all script some statistical output files are generated.  They are kept in each subjects' {{{stats/}}} subdirectory and are generated for the subcortical segmentation (aseg) and the cortical parcellation (aparc). These tables include information on each labeled region for the individual subject.
Line 92: Line 131:
The statistical output from the subcortical segmentation, called {{{aseg.stats}}}, is a regular text file and will contain the volumes of specific structures. For example, you can obtain information such as the volume of left hippocampus and it's mean intensity from this file. The statistical output from the subcortical segmentation, called {{{aseg.stats}}}, is a regular text file and will contain the volumes of specific structures. For example, you can obtain information such as the volume of left hippocampus and its mean intensity from this file.
Line 101: Line 140:
At the head of the text file there will be information about the command that was run, the version used, the user who ran it and a time stamp. Following this there is information about the volume of the entire brain. This shows the number of voxels in the brainmask {{{(BrainMaskNVox)}}}, the volume of the brainmask {{{(BrainMaskVol)}}}, the number of voxels in the brainseg {{{(BrainSegNVox)}}}, the volume of the brainseg {{{(BrainSegVol)}}}, and the intracranial volume {{{(ICV)}}}. This part of the file also tells us that the brainmask.mgz volume is being used as !BrainMask {{{(BrainMaskFile mri/brainmask.mgz)}}} and the aseg.mgz segmentation is being used as the !SegVol {{{(SegVolFile mri/aseg.mgz)}}}. The number of voxels and the volumes should be the same for this subject, since this part of the file also tells us that the voxel volume is 1 mm^3^ {{{(VoxelVolume_mm3 1)}}} - and volume is measured in mm^3^. <<BR>> At the head of the text file there will be information about the command that was run, the version used, the user who ran it and a time stamp. Following this there is information about the volume of the entire brain. <<BR>>
Line 104: Line 143:
We can expect to see the ''Segmentation Id'', ''Number of Voxels'', ''Volume'', ''Structure Name'', ''Intensity normMean'', ''Itensity normStdDev'', ''Intensity normMin'', ''Intensity normMax'', and ''Intensity normRange'' for each entry in the table.<<BR>> We can expect to see the ''Segmentation Id'', ''Number of Voxels'', ''Volume'', ''Structure Name'', ''Intensity normMean'', ''Intensity normStdDev'', ''Intensity normMin'', ''Intensity normMax'', and ''Intensity normRange'' for each entry in the table.<<BR>>
Line 109: Line 148:
# Title Segmentation Statistics # Title Segmentation Statistics  #
Line 111: Line 151:
# cvs_version $Id: mri_segstats.c,v 1.33.2.4 2008/12/21 18:04:48 greve Exp $
# cmdline mri_segstats --seg mri/aseg.mgz --sum stats/aseg.stats --pv mri/norm.mgz --excludeid 0 --brain-vol-from-seg --brainmask mri/brainmask.mgz --in mri/norm.mgz --in-intensity-name norm --in-intensity-units MR --etiv --subject
00
4 --surf-wm-vol --ctab /usr/local/freesurfer/stable4/ASegStatsLUT.txt
# cvs_version $Id: mri_segstats.c,v 1.69.2.1 2010/07/26 16:19:29 greve Exp $
# cmdline mri_segstats --seg mri/aseg.mgz --sum stats/aseg.stats --pv mri/norm.mgz --empty --excludeid 0 --excl-ctxgmwm --supratent --subcortgray --in mri/norm.mgz --in-intensity-name norm --in-intensity-units MR --etiv --surf-wm-vol --surf-ctx-vol --totalgray --ctab /autofs/cluster/freesurfer/test/subjects/x86_64/buckner_data/group_study_fs5.0.0/freesurfer-Linux-centos4_x86_64-stable-pub-v5.0.0/ASegStatsLUT.txt --subject 004
Line 115: Line 154:
# hostname node0304 # hostname compute-0-85.local
Line 117: Line 156:
# user FS-user # user nicks
Line 119: Line 158:
# SUBJECTS_DIR /autofs/space/birn_045/users/BWH/buckner_data/tutorial_subjs #
# SUBJECTS_DIR /autofs/cluster/freesurfer/test/subjects/x86_64/buckner_data/group_study_fs5.0.0
Line 121: Line 161:
# BrainMaskFile mri/brainmask.mgz
# BrainMaskFileTimeStamp 2009/01/11 15:41:05
# Measure BrainMask, BrainMaskNVox, Number of Brain Mask Voxels, 1750402, unitless
# Measure BrainMask, BrainMaskVol, Brain Mask Volume, 1750402.000000, mm^3
# Measure BrainSegNotVent, BrainSegVolNotVent, Brain Segmentation Volume Without Ventricles, 1175182.000000, mm^3
# Measure BrainSeg, BrainSegNVox, Number of Brain Segmentation Voxels, 1235011, unitless
# Measure BrainSeg, BrainSegVol, Brain Segmentation Volume, 1235011.000000, mm^3
# Measure IntraCranialVol, ICV, Intracranial Volume, 1796495.343836, mm^3
# SegVolFile mri/aseg.mgz
# SegVolFileTimeStamp 2008/11/22 04:53:19
# ColorTable /usr/local/freesurfer/stable4/ASegStatsLUT.txt
# ColorTableTimeStamp 2009/01/11 07:09:19
# InVolFile mri/norm.mgz
# InVolFileTimeStamp 2008/11/21 19:10:07
# InVolFrame 0
# PVVolFile mri/norm.mgz
# PVVolFileTimeStamp 2008/11/21 19:10:07
# surface-based-volume mm3 lh-cerebral-white-matter 256451.250000
# surface-based-volume mm3 rh-cerebral-white-matter 256024.875000
# surface-based-volume mm3 tot-cerebral-white-matter 512476.125000
# ExcludeSegId 0
# VoxelVolume_mm3 1
-
-
-
# TableCol 1 ColHeader Index
# TableCol 1 FieldName Index
# TableCol 1 Units NA
# TableCol 2 ColHeader SegId
# Measure lhCortex, lhCortexVol, Left hemisphere cortical gray matter volume, 244507.719492, mm^3
# Measure rhCortex, rhCortexVol, Right hemisphere cortical gray matter volume, 249102.710448, mm^3
# Measure Cortex, CortexVol, Total cortical gray matter volume, 493610.429940, mm^3
# Measure lhCorticalWhiteMatter, lhCorticalWhiteMatterVol, Left hemisphere cortical white matter volume, 260412.984375, mm^3
# Measure rhCorticalWhiteMatter, rhCorticalWhiteMatterVol, Right hemisphere cortical white matter volume, 256990.187500, mm^3
# Measure CorticalWhiteMatter, CorticalWhiteMatterVol, Total cortical white matter volume, 517403.171875, mm^3
# Measure SubCortGray, SubCortGrayVol, Subcortical gray matter volume, 183995.000000, mm^3
# Measure TotalGray, TotalGrayVol, Total gray matter volume, 677605.429940, mm^3
# Measure SupraTentorial, SupraTentorialVol, Supratentorial volume, 1189372.762911, mm^3
# Measure IntraCranialVol, ICV, Intracranial Volume, 1792580.562856, mm^3
# SegVolFile mri/aseg.mgz
# SegVolFileTimeStamp 2010/08/12 21:00:31
# ColorTable /autofs/cluster/freesurfer/test/subjects/x86_64/buckner_data/group_study_fs5.0.0/freesurfer-Linux-centos4_x86_64-stable-pub-v5.0.0/ASegStatsLUT.txt
# ColorTableTimeStamp 2010/08/11 23:17:47
# InVolFile mri/norm.mgz
# InVolFileTimeStamp 2010/08/12 16:27:10
# InVolFrame 0
# PVVolFile mri/norm.mgz
# PVVolFileTimeStamp 2010/08/12 16:27:10
# Excluding Cortical Gray and White Matter
# ExcludeSegId 0 2 3 41 42
# VoxelVolume_mm3 1
-
-
-
# TableCol 1 ColHeader Index
# TableCol 1 FieldName Index
# TableCol 1 Units NA
# TableCol 2 ColHeader SegId
Line 152: Line 192:
# TableCol 3 ColHeader NVoxels # TableCol 3 ColHeader NVoxels 
Line 164: Line 204:
#ColHeaders Index SegId NVoxels Volume_mm3 StructName normMean normStdDev normMin normMax normRange
              1 2 219775 219775.0 Left-Cerebral-White-Matter 104.1449 9.6298 23.0000 180.0000 157.0000
              2 3 249186 249186.0 Left-Cerebral-Cortex 68.4475 10.9191 19.0000 154.0000 135.0000
              3 4 31217 31217.0 Left-Lateral-Ventricle 21.2879 9.9687 6.0000 82.0000 76.0000
              4 5 1380 1380.0 Left-Inf-Lat-Vent 37.2319 12.6153 13.0000 85.0000 72.0000
              5 7 13337 13337.0 Left-Cerebellum-White-Matter 86.1768 7.6600 42.0000 124.0000 82.0000
              6 8 49087 49087.0 Left-Cerebellum-Cortex 58.4803 9.5375 19.0000 96.0000 77.0000
# ColHeaders Index SegId NVoxels Volume_mm3 StructName normMean normStdDev normMin normMax normRange
  1 4 31149 31149.0 Left-Lateral-Ventricle 21.2596 10.2600 6.0000 84.0000 78.0000
  2 5 1360 1360.0 Left-Inf-Lat-Vent 37.3251 12.8335 12.0000 83.0000 71.0000
  3 7 12845 12845.0 Left-Cerebellum-White-Matter 87.6037 7.6264 40.0000 124.0000 84.0000
  4 8 48371 48371.0 Left-Cerebellum-Cortex 60.9231 9.6107 19.0000 107.0000 88.0000
  5 10 7197 7197.0 Left-Thalamus-Proper 85.0192 11.4083 21.0000 118.0000 97.0000
  6 11 5829 5829.0 Left-Caudate 71.9549 11.1561 28.0000 109.0000 81.0000
  7 12 8389 8389.0 Left-Putamen 77.1418 9.1256 26.0000 107.0000 81.0000
Line 178: Line 219:
The statistical output from the cortical parcellation, called {{{lh.aparc.stats}}} and {{{rh.aparc.stats}}}, is a regular text file and will contain the thickness of specific structures. For example, you can obtain information such as, how big is left superior temporal gyrus and it's average thickness from this file. The statistical output from the cortical parcellation, called {{{lh.aparc.stats}}} and {{{rh.aparc.stats}}}, is a regular text file and will contain the thickness of specific structures. For example, you can obtain information such as, how big is left superior temporal gyrus and its average thickness from this file.
Line 185: Line 226:
At the head of the text file there will be information about the command that was run, the version used, the user who ran it and a time stamp. Following this there is information about the volume of the entire brain. This shows the total white matter volume {{{(TotalWhiteMatterVolume)}}}, the number of vertices in the cortex {{{(NumVert)}}}, and the surface area of the cortex {{{(SurfArea)}}}. This part of the file also tells us that the lh.aparc.annot is being used as the annotation file {{{(AnnotationFile ../label/lh.aparc.annot)}}}.<<BR>> At the head of the text file there will be information about the command that was run, the version used, the user who ran it and a time stamp. Following this there is information about the volume of the entire brain. This shows the number of vertices in the cortex {{{(NumVert)}}}, and the surface area of the cortex {{{(SurfArea)}}}. This part of the file also tells us that the lh.aparc.annot is being used as the annotation file {{{(AnnotationFile ../label/lh.aparc.annot)}}}.<<BR>>
Line 190: Line 231:
The remainder of the table shows this information for all the structures that are labeled in the aseg.

{{{
# Table of FreeSurfer cortical parcellation anatomical statistics
# CreationTime 2009/01/13-02:24:40-GMT
The remainder of the table shows this information for all the structures that are labeled in the aparc.

{{{
# Table of FreeSurfer cortical parcellation anatomical statistics 
#
#
CreationTime 2010/08/13-05:08:41-GMT
Line 196: Line 238:
# cvs_version $Id: mris_anatomical_stats.c,v 1.54.2.4 2009/01/09 22:23:40 nicks Exp $
# mrisurf.c-cvs_version $Id: mrisurf.c,v 1.557.2.17 2009/01/08 17:16:51 nicks Exp $
# cmdline mris_anatomical_stats -mgz -f ../stats/lh.aparc.stats -b -a ../label/lh.aparc.annot -c ../label/aparc.annot.ctab 004 lh
# cvs_version $Id: mris_anatomical_stats.c,v 1.68 2010/05/28 20:36:45 nicks Exp $
# mrisurf.c-cvs_version $Id: mrisurf.c,v 1.678 2010/05/28 21:22:21 rpwang Exp $
# cmdline mris_anatomical_stats -mgz -cortex ../label/lh.cortex.label -f ../stats/lh.aparc.stats -b -a ../label/lh.aparc.annot -c ../label/aparc.annot.ctab 004 lh white
Line 200: Line 242:
# hostname node0323 # hostname compute-0-85.local
Line 202: Line 244:
# user FS-user
# SUBJECTS_DIR /autofs/space/birn_045/users/BWH/buckner_data/tutorial_subjs
# user nicks
#

# SUBJECTS_DIR /autofs/cluster/freesurfer/test/subjects/x86_64/buckner_data/group_study_fs5.0.0
Line 208: Line 251:
# AnnotationFileTimeStamp 2009/01/12 02:40:55
# Measure Cortex, NumVert, Number of Vertices, 151295, unitless
# Measure Cortex, SurfArea, Surface Area,  100640, mm^2
# AnnotationFileTimeStamp 2010/08/13 01:08:34
# Measure Cortex, NumVert, Number of Vertices, 142825, unitless
# Measure Cortex, SurfArea, Surface Area, 95354.8, mm^2
# Measure Cortex, MeanThickness, Mean Thickness, 2.31
065, mm
Line 226: Line 270:
# TableCol 5 ColHeader ThickAvg # TableCol 5 ColHeader ThickAvg 
Line 232: Line 276:
#ColHeaders StructName NumVert SurfArea GrayVol ThickAvg ThickStd MeanCurv GausCurv FoldInd CurvInd
unknown 13332 8382 11785 1.313 1.553 0.117 0.146 1134 56.2
bankssts 1372 939 2157 2.249 0.512 0.138 0.048 17 2.9
caudalanteriorcingulate 1188 783 2316 2.561 0.829 0.176 0.102 38 4.9
caudalmiddlefrontal 3278 2160 6170 2.555 0.565 0.143 0.056 45 7.8
cuneus 2460 1561 3093 1.800 0.406 0.165 0.071 47 6.9
entorhinal 544 371 1617 3.130 0.717 0.183 0.177 36 4.2
fusiform 5421 3746 10126 2.281 0.708 0.155 0.067 98 14.7
inferiorparietal 7558 5112 13237 2.269 0.589 0.154 0.066 154 19.6
# ColHeaders StructName NumVert SurfArea GrayVol ThickAvg ThickStd MeanCurv GausCurv FoldInd CurvInd
bankssts 1630 1133 2693 2.331 0.489 0.137 0.042 19 2.9
caudalanteriorcingulate 1248 805 2396 2.657 0.674 0.171 0.105 37 4.5
caudalmiddlefrontal 3336 2205 6275 2.528 0.562 0.142 0.059 42 7.6
cuneus 2513 1597 3129 1.806 0.423 0.174 0.119 128 8.5
entorhinal 566 403 1837 3.268 0.679 0.139 0.067 8 1.6
Line 253: Line 294:
setenv SUBJECTS_DIR <path_to_data> setenv SUBJECTS_DIR $TUTORIAL_DATA/buckner_data/tutorial_subjs/group_analysis_tutorial
cd $SUBJECTS_DIR
Line 265: Line 307:
  --t aseg.vol.table
}}}
----
where 11, 17 and 18 correspond to the segmentation label of left caudate, left hippocampus and left amygdala respectively. You can get the segmentation labels and the corresponding subcortical structures using the following command.
----
{{{
less $FREESURFER_HOME/FreeSurferColorLUT.txt
}}}
----
For tutorial purposes, click [[FsTutorial/AnatomicalROI/FreeSurferColorLUT|here]] to view the contents of the file.

After running the ''asegstats2table'' command, to load the resulting table into a spreadsheet, run
----
{{{
oocalc aseg.vol.table
}}}
----
and then select '''Space''' in the '''Separated by''' menu.

{{attachment:spreadsheet.jpg}}

Please note that the ''oocalc'' command is meant to be run on a Linux machine.
  --tablefile aseg.vol.table
}}}
----
where 11, 17 and 18 correspond to the segmentation label of left caudate, left hippocampus and left amygdala respectively. (You can create a table with all of the labels, not just these three, by omitting the --segno part.)

Click [[FsTutorial/AnatomicalROI/FreeSurferColorLUT|here]] if you would like to view the list of labels and their corresponding ID numbers again.

The file {{{aseg.vol.table}}} is your output - a text file consisting of the subjects mentioned in the command above and the values for the structures requested. The information in this text file is formatted so it can be easily imported into a spreadsheet program (often used as input for many statistical analysis programs). If you do the {{{ls}}} command, you should see that the text file {{{aseg.vol.table}}} has been created. To see what the file looks like, do:
----
{{{
less aseg.vol.table
}}}
----


To to load the resulting table into a spreadsheet, run:
----
{{{
gnumeric aseg.vol.table
}}}
----

'''Note:''' the ''gnumeric'' command is meant to be run on a Linux machine. Mac users could install !OpenOffice 3.0 to open the table in a spreadsheet and run the command
----
{{{
/Applications/OpenOffice.org.app/Contents/MacOS/scalc aseg.vol.table
}}}
----
Line 289: Line 338:
About the subject IDs, you'll notice that in the examples we've considered here, each subject is a 3 digit number. Therefore ''oocalc'' thinks it is a number and removes leading 0s. This is an oocalc issue but probably it would not happen if subject names has characters in them instead of integers. About the subject IDs, you'll notice that in the examples we've considered here, each subject is a 3 digit number. Therefore ''gnumeric'' thinks it is a number and removes leading 0s. This is a gnumeric issue but probably it would not happen if subject names had characters in them instead of integers.
Line 293: Line 342:
Purpose of this section is to demonstrate how you can change the measure from volume to mean intensity using ''asegstats2table'' command. Purpose of this section is to demonstrate how you can change what measure you collect for your spreadsheet from volume to mean intensity using the ''asegstats2table'' command.
Line 300: Line 349:
  --t aseg.mean-intensity.table
}}}
----
You can load the table into a spread sheet as explained in the previous section. Please refer to the file ''FreeSurferColorLUT.txt'' for the segmentation labels and the corresponding subcortical structures.
  --tablefile aseg.mean-intensity.table
}}}
----

Things to do:

  1.
You can load the table into a spreadsheet as explained in the previous section.
  1. R
efer to the file ''FreeSurferColorLUT.txt'' for the segmentation labels and the corresponding subcortical structures.
Line 313: Line 366:
The purpose of this section is to show how you can change the segmentation atlas The purpose of this section is to show how you can change which segmentation atlas you get stats from (and thus which structures):
Line 320: Line 373:
  --t wmparc.vol.table
}}}
----
Please refer to the file ''FreeSurferColorLUT.txt'' for the segmentation labels and the corresponding subcortical structures. 
  --tablefile wmparc.vol.table
}}}
----
Things to do:

  1. You can load the table into a spreadsheet.
  1. R
efer to the file ''FreeSurferColorLUT.txt'' for the segmentation labels and the corresponding subcortical structures.
Line 329: Line 385:
For tutorial purposes, click [[FsTutorial/AnatomicalROI/FreeSurferColorLUT|here]] to view the contents of the file. For tutorial purposes, click [[FsTutorial/AnatomicalROI/FreeSurferColorLUT|here]] to view the contents of the file
Line 333: Line 389:
This section explains how to create a table of the surface area of each cortical parcellation in the Desikan atlas. This section explains how to create a table of the surface area of each cortical parcellation in the Desikan atlas (surface area is the default measure).
Line 338: Line 394:
  --t lh.aparc.area.stats
}}}
----
  --tablefile lh.aparc.area.table
}}}
----
You can now load the resulting table into a spreadsheet.
Line 350: Line 407:
  --parc aparc.a2005s \
  --t lh.aparc.a2005.thickness.stats
}}}
----
  --parc aparc.a2009s \
  --tablefile lh.aparc.a2009.thickness.table
}}}
----
You can now load the resulting table into a spreadsheet.

top | previous

Anatomical ROI analysis

This tutorial gives a brief introduction to anatomical ROI analysis which includes working with label files, extracting ROI measures from the anatomical data, group statistics etc.

Preparations

If You're at an Organized Course

If you are taking one of the formally organized courses, everything has been set up for you on the provided laptop. The only thing you will need to do is run the following commands in every new terminal window (aka shell) you open throughout this tutorial. Copy and paste the commands below to get started:

setenv SUBJECTS_DIR $TUTORIAL_DATA/buckner_data/tutorial_subjs/group_analysis_tutorial
cd $SUBJECTS_DIR

To copy: Highlight the command in the box above, right click and select copy (or use keyboard shortcut Ctrl+c), then use the middle button of your mouse to click inside the terminal window (this will paste the command). Press enter to run the command.

These two commands set the SUBJECTS_DIR variable to the directory where the data is stored and then navigates into this directory. You can now skip ahead to the tutorial (below the gray line).

If You're not at an Organized Course

If you are NOT taking one of the formally organized courses, then to follow this exercise exactly be sure you've downloaded the tutorial data set before you begin. If you choose not to download the data set you can follow these instructions on your own data, but you will have to substitute your own specific paths and subject names. These are the commands that you need to run before getting started:

tcsh
source your_freesurfer_dir/SetUpFreeSurfer.csh
setenv SUBJECTS_DIR $TUTORIAL_DATA/buckner_data/tutorial_subjs/group_analysis_tutorial
cd $SUBJECTS_DIR

Notice the command to open tcsh. If you are already running the tcsh command shell, then the 'tcsh' command is not necessary. If you are not using the tutorial data you should set your SUBJECTS_DIR to the directory in which the recon(s) of the subject(s) you will use for this tutorial are located.


Relationship between segmentation, parcellation and LookUp Table (LUT)

In this exercise, you will examine a segmentation, parcellation, and color lookup table to understand how they are related.

Open the subject in tkmedit using the following command:


tkmedit 004 orig.mgz -aux aparc+aseg.mgz \
  -seg aparc+aseg.mgz $FREESURFER_HOME/FreeSurferColorLUT.txt


Open another terminal to load the subject in tksurfer, using the following command.


setenv SUBJECTS_DIR $TUTORIAL_DATA/buckner_data/tutorial_subjs/group_analysis_tutorial
cd $SUBJECTS_DIR
tksurfer 004 lh inflated -annot aparc.annot


Finally, run the following command to display the contents of LUT (in another new terminal window)


less $FREESURFER_HOME/FreeSurferColorLUT.txt


You can hit the 'Page Up' and 'Page Down' buttons to see the rest of the file. Or click here to view the contents of the file. (To exit the less command, hit the 'q' button.)

Things to do -- Navigating between tkmedit and LUT:

  1. Click on a point on the image loaded in tkmedit.
  2. See the structure name in the tkmedit Tools window (under the Cursor section).
  3. Look at the Aux (aparc+aseg.mgz) value in the tkmedit Tools window. For example, it may say 1024.
  4. Find that value in the LUT, which you have opened using the command mentioned above.
  5. Verify that it is the same structure as listed in tkmedit.

Things to do -- Navigating between tksurfer, tkmedit and LUT:

  1. Click on a point in tksurfer in the superior temporal gyrus. If you don't know it's location, you can hover over the different areas to see their label underneath the Mouse section of the Tools window.
  2. Note that the name displayed in the tksurfer Tools window does not have lh or rh in it. This is because you loaded only one hemisphere.
  3. In tksurfer, click on the Save Point button icon_cursor_save.gif

  4. In tkmedit, click on Goto Point button icon_cursor_goto.gif , which takes the cursor to the ROI. Zoom in to see the cursor.

  5. Verify the structure name in the tkmedit Tools window. Note that it DOES have an lh or rh in it.
  6. The Aux (aparc+aseg.mgz) value should be 1030.
  7. In FreeSurferColorLUT.txt, verify that 1030 is ctx-lh-superiortemporal

You can close tkmedit and tksurfer once you are done. To get out of the less command, type 'q' for quit.

Label files

This section gives the details of commands to load an existing label file in text editor, tkmedit, and tksurfer.

To map a label, such as the lh.BA45.label, from the fsaverage subject to a target subject, run

cd $SUBJECTS_DIR
mri_label2label \
  --srcsubject fsaverage \
  --srclabel fsaverage/label/lh.BA45.label \
  --trgsubject 004 \
  --trglabel 004/label/lh.BA45.label \
  --hemi lh \
  --regmethod surface

Although we used an existing label for the example above, you could draw a new label on fsaverage and map that to all your subjects so that it will appear in the same cortical region. To take a look at the contents of that newly created label file, run:


less 004/label/lh.BA45.label


To load the label in tkmedit, first load the subject you want to work on, in tkmedit.


tkmedit 004 orig.mgz 


Then on the menu bar at the top of tkmedit tools window, go to File --> Label --> Load Label --> Browse --> lh.BA45.label and hit 'OK' in both windows. The label is visible in coronal slice 153.

BAlabel.jpg

This label can be edited when the Select Voxels button is chosen. Use the middle mouse button to add to the label. Use the right mouse button to delete from the label. If this was your own subject, you would want to make sure you save your edits by going to File --> Label --> Save Label but it's not necessary for this tutorial.

To load the label in tksurfer, first load the subject (in another terminal window).


tksurfer 004 lh inflated


On the menu bar at the top of tksurfer tools window, go to File --> Label --> Load Label --> Browse --> lh.BA45.label

BAlabel_tksurfer.jpg

Information on how to create and edit labels in tksurfer can be found on this wiki. You don't have to do this for the tutorial, but please feel free to take a look if you are interested.

Individual Stats files

During the normal FreeSurfer processing stream, via the recon-all script some statistical output files are generated. They are kept in each subjects' stats/ subdirectory and are generated for the subcortical segmentation (aseg) and the cortical parcellation (aparc). These tables include information on each labeled region for the individual subject.

aseg.stats

The statistical output from the subcortical segmentation, called aseg.stats, is a regular text file and will contain the volumes of specific structures. For example, you can obtain information such as the volume of left hippocampus and its mean intensity from this file.


cd $SUBJECTS_DIR/004/stats
less aseg.stats


At the head of the text file there will be information about the command that was run, the version used, the user who ran it and a time stamp. Following this there is information about the volume of the entire brain.

The next section of this file defines the column headers, field name, and units for the rest of the table. We can expect to see the Segmentation Id, Number of Voxels, Volume, Structure Name, Intensity normMean, Intensity normStdDev, Intensity normMin, Intensity normMax, and Intensity normRange for each entry in the table.

The remainder of the table shows this information for all the structures that are labeled in the aseg.

# Title Segmentation Statistics 
# 
# generating_program mri_segstats
# cvs_version $Id: mri_segstats.c,v 1.69.2.1 2010/07/26 16:19:29 greve Exp $
# cmdline mri_segstats --seg mri/aseg.mgz --sum stats/aseg.stats --pv mri/norm.mgz --empty --excludeid 0 --excl-ctxgmwm --supratent --subcortgray --in mri/norm.mgz --in-intensity-name norm --in-intensity-units MR --etiv --surf-wm-vol --surf-ctx-vol --totalgray --ctab /autofs/cluster/freesurfer/test/subjects/x86_64/buckner_data/group_study_fs5.0.0/freesurfer-Linux-centos4_x86_64-stable-pub-v5.0.0/ASegStatsLUT.txt --subject 004 
# sysname  Linux
# hostname compute-0-85.local
# machine  x86_64
# user     nicks
# anatomy_type volume
# 
# SUBJECTS_DIR /autofs/cluster/freesurfer/test/subjects/x86_64/buckner_data/group_study_fs5.0.0
# subjectname 004
# Measure lhCortex, lhCortexVol, Left hemisphere cortical gray matter volume, 244507.719492, mm^3
# Measure rhCortex, rhCortexVol, Right hemisphere cortical gray matter volume, 249102.710448, mm^3
# Measure Cortex, CortexVol, Total cortical gray matter volume, 493610.429940, mm^3
# Measure lhCorticalWhiteMatter, lhCorticalWhiteMatterVol, Left hemisphere cortical white matter volume, 260412.984375, mm^3
# Measure rhCorticalWhiteMatter, rhCorticalWhiteMatterVol, Right hemisphere cortical white matter volume, 256990.187500, mm^3
# Measure CorticalWhiteMatter, CorticalWhiteMatterVol, Total cortical white matter volume, 517403.171875, mm^3
# Measure SubCortGray, SubCortGrayVol, Subcortical gray matter volume, 183995.000000, mm^3
# Measure TotalGray, TotalGrayVol, Total gray matter volume, 677605.429940, mm^3
# Measure SupraTentorial, SupraTentorialVol, Supratentorial volume, 1189372.762911, mm^3
# Measure IntraCranialVol, ICV, Intracranial Volume, 1792580.562856, mm^3
# SegVolFile mri/aseg.mgz 
# SegVolFileTimeStamp  2010/08/12 21:00:31 
# ColorTable /autofs/cluster/freesurfer/test/subjects/x86_64/buckner_data/group_study_fs5.0.0/freesurfer-Linux-centos4_x86_64-stable-pub-v5.0.0/ASegStatsLUT.txt 
# ColorTableTimeStamp 2010/08/11 23:17:47 
# InVolFile  mri/norm.mgz 
# InVolFileTimeStamp  2010/08/12 16:27:10 
# InVolFrame 0 
# PVVolFile  mri/norm.mgz 
# PVVolFileTimeStamp  2010/08/12 16:27:10 
# Excluding Cortical Gray and White Matter
# ExcludeSegId 0 2 3 41 42 
# VoxelVolume_mm3 1 
-
-
-
# TableCol  1 ColHeader Index 
# TableCol  1 FieldName Index 
# TableCol  1 Units     NA 
# TableCol  2 ColHeader SegId 
# TableCol  2 FieldName Segmentation Id
# TableCol  2 Units     NA
# TableCol  3 ColHeader NVoxels 
# TableCol  3 FieldName Number of Voxels
# TableCol  3 Units     unitless
# TableCol  4 ColHeader Volume_mm3
# TableCol  4 FieldName Volume
# TableCol  4 Units     mm^3
# TableCol  5 ColHeader StructName
# TableCol  5 FieldName Structure Name
# TableCol  5 Units     NA
-
-
-
# ColHeaders  Index SegId NVoxels Volume_mm3 StructName normMean normStdDev normMin normMax normRange  
  1   4     31149    31149.0  Left-Lateral-Ventricle            21.2596    10.2600     6.0000    84.0000    78.0000 
  2   5      1360     1360.0  Left-Inf-Lat-Vent                 37.3251    12.8335    12.0000    83.0000    71.0000 
  3   7     12845    12845.0  Left-Cerebellum-White-Matter      87.6037     7.6264    40.0000   124.0000    84.0000 
  4   8     48371    48371.0  Left-Cerebellum-Cortex            60.9231     9.6107    19.0000   107.0000    88.0000 
  5  10      7197     7197.0  Left-Thalamus-Proper              85.0192    11.4083    21.0000   118.0000    97.0000 
  6  11      5829     5829.0  Left-Caudate                      71.9549    11.1561    28.0000   109.0000    81.0000 
  7  12      8389     8389.0  Left-Putamen                      77.1418     9.1256    26.0000   107.0000    81.0000 
-
-
-

aparc.stats

The statistical output from the cortical parcellation, called lh.aparc.stats and rh.aparc.stats, is a regular text file and will contain the thickness of specific structures. For example, you can obtain information such as, how big is left superior temporal gyrus and its average thickness from this file.


cd $SUBJECTS_DIR/004/stats
less lh.aparc.stats


At the head of the text file there will be information about the command that was run, the version used, the user who ran it and a time stamp. Following this there is information about the volume of the entire brain. This shows the number of vertices in the cortex (NumVert), and the surface area of the cortex (SurfArea). This part of the file also tells us that the lh.aparc.annot is being used as the annotation file (AnnotationFile ../label/lh.aparc.annot).

The next section of this file defines the column headers, field name, and units for the rest of the table. We can expect to see the Structure Name, Number of Vertices, Surface Area, Gray Matter Volume, Average Thickness, Thickness StDev, Integrated Rectified Mean Curvature, Integrated Rectified Gaussian Curvature, Folding Index and Intrinsic Curvature Index for each entry in the table.

The remainder of the table shows this information for all the structures that are labeled in the aparc.

# Table of FreeSurfer cortical parcellation anatomical statistics 
# 
# CreationTime 2010/08/13-05:08:41-GMT
# generating_program mris_anatomical_stats
# cvs_version $Id: mris_anatomical_stats.c,v 1.68 2010/05/28 20:36:45 nicks Exp $
# mrisurf.c-cvs_version $Id: mrisurf.c,v 1.678 2010/05/28 21:22:21 rpwang Exp $
# cmdline mris_anatomical_stats -mgz -cortex ../label/lh.cortex.label -f ../stats/lh.aparc.stats -b -a ../label/lh.aparc.annot -c ../label/aparc.annot.ctab 004 lh white 
# sysname  Linux
# hostname compute-0-85.local
# machine  x86_64
# user     nicks
# 
# SUBJECTS_DIR /autofs/cluster/freesurfer/test/subjects/x86_64/buckner_data/group_study_fs5.0.0
# anatomy_type surface
# subjectname 004
# hemi lh
# AnnotationFile ../label/lh.aparc.annot
# AnnotationFileTimeStamp 2010/08/13 01:08:34
# Measure Cortex, NumVert, Number of Vertices, 142825, unitless
# Measure Cortex, SurfArea, Surface Area, 95354.8, mm^2
# Measure Cortex, MeanThickness, Mean Thickness, 2.31065, mm
-
-
-
# TableCol  1 ColHeader StructName
# TableCol  1 FieldName Structure Name
# TableCol  1 Units     NA
# TableCol  2 ColHeader NumVert
# TableCol  2 FieldName Number of Vertices
# TableCol  2 Units     unitless
# TableCol  3 ColHeader SurfArea
# TableCol  3 FieldName Surface Area
# TableCol  3 Units     mm^2
# TableCol  4 ColHeader GrayVol
# TableCol  4 FieldName Gray Matter Volume
# TableCol  4 Units     mm^3
# TableCol  5 ColHeader ThickAvg 
# TableCol  5 FieldName Average Thickness
# TableCol  5 Units     mm
-
-
-
# ColHeaders StructName NumVert SurfArea GrayVol ThickAvg ThickStd MeanCurv GausCurv FoldInd CurvInd
bankssts                                 1630   1133   2693  2.331 0.489     0.137     0.042       19     2.9
caudalanteriorcingulate                  1248    805   2396  2.657 0.674     0.171     0.105       37     4.5
caudalmiddlefrontal                      3336   2205   6275  2.528 0.562     0.142     0.059       42     7.6
cuneus                                   2513   1597   3129  1.806 0.423     0.174     0.119      128     8.5
entorhinal                                566    403   1837  3.268 0.679     0.139     0.067        8     1.6
-
-
-

Group stats files

This section will run you through using the stats directory in the subjects to perform group stats of certain structures that may be of interest to your study. The following commands will help you combine the data of the subjects you are analyzing into one table that will be easily read into a spreadsheet program. We have considered 6 subjects as examples (004, 021, 040, 067, 080, 092) in the following sections.

Set your SUBJECTS_DIR to the path where you have your subjects to be analyzed.


setenv SUBJECTS_DIR $TUTORIAL_DATA/buckner_data/tutorial_subjs/group_analysis_tutorial
cd $SUBJECTS_DIR


Table of segmentation volumes

This section explains how to create a table of segmentation volumes using the 6 subjects mentioned above.


asegstats2table --subjects 004 021 040 067 080 092 \
  --segno 11 17 18 \
  --tablefile aseg.vol.table


where 11, 17 and 18 correspond to the segmentation label of left caudate, left hippocampus and left amygdala respectively. (You can create a table with all of the labels, not just these three, by omitting the --segno part.)

Click here if you would like to view the list of labels and their corresponding ID numbers again.

The file aseg.vol.table is your output - a text file consisting of the subjects mentioned in the command above and the values for the structures requested. The information in this text file is formatted so it can be easily imported into a spreadsheet program (often used as input for many statistical analysis programs). If you do the ls command, you should see that the text file aseg.vol.table has been created. To see what the file looks like, do:


less aseg.vol.table


To to load the resulting table into a spreadsheet, run:


gnumeric aseg.vol.table


Note: the gnumeric command is meant to be run on a Linux machine. Mac users could install OpenOffice 3.0 to open the table in a spreadsheet and run the command


/Applications/OpenOffice.org.app/Contents/MacOS/scalc aseg.vol.table


In the table, the first cell is volume indicating that the measure is a volume in mm3. In addition to segmentations, you can also get IntraCranialVol (ICV) and BrainSegVol into the table.

About the subject IDs, you'll notice that in the examples we've considered here, each subject is a 3 digit number. Therefore gnumeric thinks it is a number and removes leading 0s. This is a gnumeric issue but probably it would not happen if subject names had characters in them instead of integers.

Table of segmentation mean intensities

Purpose of this section is to demonstrate how you can change what measure you collect for your spreadsheet from volume to mean intensity using the asegstats2table command.


asegstats2table \
  --subjects 004 021 040 067 080 092 \
  --segno 11 17 18 \
  --meas mean \
  --tablefile aseg.mean-intensity.table


Things to do:

  1. You can load the table into a spreadsheet as explained in the previous section.
  2. Refer to the file FreeSurferColorLUT.txt for the segmentation labels and the corresponding subcortical structures.


less $FREESURFER_HOME/FreeSurferColorLUT.txt


For tutorial purposes, click here to view the contents of the file.

Table of white matter parcellation volumes

The purpose of this section is to show how you can change which segmentation atlas you get stats from (and thus which structures):


asegstats2table \
  --subjects 004 021 040 067 080 092 \
  --segno 3007 3021 3022 4022 \
  --stats wmparc.stats \
  --tablefile wmparc.vol.table


Things to do:

  1. You can load the table into a spreadsheet.
  2. Refer to the file FreeSurferColorLUT.txt for the segmentation labels and the corresponding subcortical structures.


less $FREESURFER_HOME/FreeSurferColorLUT.txt


For tutorial purposes, click here to view the contents of the file

Table of the surface area of each cortical parcellation in the Desikan atlas

This section explains how to create a table of the surface area of each cortical parcellation in the Desikan atlas (surface area is the default measure).


aparcstats2table --hemi lh \
  --subjects 004 021 040 067 080 092 \
  --tablefile lh.aparc.area.table


You can now load the resulting table into a spreadsheet.

Table of the average thickness of each cortical parcellation in the Destrieux atlas

The purpose of this section is to show how to change the summary measure and the parcellation atlas.


aparcstats2table --hemi lh \
  --subjects 004 021 040 067 080 092 \
  --meas thickness \
  --parc aparc.a2009s \
  --tablefile lh.aparc.a2009.thickness.table


You can now load the resulting table into a spreadsheet.

FsTutorial/AnatomicalROI_tktools (last edited 2013-11-01 14:32:41 by MaritzaEbling)