Anderson Winkler, Jason Stein, Roberto Toro

Last update: 29.Jun.2010.



For FreeSurfer users

FreeSurfer already produces measurements of intracranial volume (eTIV) and of brain volume, so there is no need for additional image processing steps, just extract the results. The numbers we are interested in are in the file aseg.stats, located in the subdirectory stats of each of the subjects' directory. These numbers can be extracted from any aseg.stats file using:


cat aseg.stats | grep IntraCranialVol | awk -F, '{ print $4 }'

cat aseg.stats | grep BrainSegVolNotVent | awk -F, '{ print $4 }'

There are many ways to create a table with all the results. A suggestion is to use a for-loop, looking at one subject per iteration. First, create text file called list_subjects.txt containing one subject ID per line:


subj1

subj2

subj3

...

subjN

Assuming that there is already a working installation of FreeSurfer and that the path for the directory that contain the analysis is in the environment variable ${SUBJECTS_DIR}, then copy and paste these lines at the prompt assuming you are using the bash shell (if you are not using the bash shell you can paste the commands into a script and add #!/bin/bash to the top):


echo "subj_id,IntraCranialVol,BrainSegVolNotVent" > global_size_FS.csv

for subj_id in `cat list_subjects.txt` ; do

echo -n "${subj_id}," >> global_size_FS.csv

echo -n "`cat ${SUBJECTS_DIR}/${subj_id}/stats/aseg.stats | grep IntraCranialVol | awk -F, '{ print $4 }'| sed 's/\ //g'`," >> global_size_FS.csv

echo "`cat ${SUBJECTS_DIR}/${subj_id}/stats/aseg.stats | grep BrainSegVolNotVent | awk -F, '{ print $4 }'| sed 's/\ //g'`" >> global_size_FS.csv

done

The outputs will be saved in the current directory, in a file named global_size_FS.csv. This file can be opened in spreadsheet applications such as OpenOffice Calc or MS Excel.


For people who are not using FreeSurfer, but still would like to report the same IntraCranialVol, the much shorter -autorecon1 part of FreeSurfer's recon-all can be used. In this case, there will not be an aseg.stats file, but instead, we obtain an equivalent number from the file talairach.xfm. The task of producing a table with only IntraCranialVolume can be accomplished using the command xfm2det (available here), then copy and paste these lines at the prompt assuming you are using the bash shell (if you are not using the bash shell you can paste the commands into a script and add #!/bin/bash to the top):


echo "subj_id,IntraCranialVol" > intracranialvol.csv

for subj_id in `cat list_subjects.txt` ; do

echo "${subj_id},`xfm2det ${SUBJECTS_DIR}/${subj_id}/mri/transforms/talairach.xfm | awk '{ print $2 }'`" >> intracranialvol.csv

done


For FSL users

Using FSL to obtain estimates for total intracranial volume and brain volume requires some image processing steps. An estimate for the total intracranial volume can be obtained by linearly aligning each subject brain to the MNI152 space, computing the inverse of the determinant of the affine matrix and multiplying by a constant, which is the size of the template. In our case, we don't need the constant, so just the inverse of the determinant is sufficient. For the brain volume, the sum of the gray matter and white matter partitions produced by FAST is the estimate we are interested in.

To produce these numbers, assuming that there is already a working installation of FSL, which location is defined by the environment variable ${FSLDIR}, define the following variable at the prompt assuming you are using the bash shell (if you are not using the bash shell you can paste the commands into a script and add #!/bin/bash to the top), which specify the template to be used:


T_brain=${FSLDIR}/data/standard/MNI152_T1_1mm_brain

Define a variable to the location where subjects' files are. If the data is stored in /enigma/hippo/data, define this variable by typing at the prompt:


SUBJECTS_DIR=/enigma/hippo/data

To define which subjects are going to be analysed and have results reported, create a text file called list_subjects.txt containing one subject ID per line:


subj1

subj2

subj3

...

subjN

If the images have not yet been skull stripped, it must be done now. Different combinations of BET options may work better depending on the images. The following is left as a suggestion that extracts the brain in two-steps, using FAST for an intemediate bias correction:


for subj_id in `cat list_subjects.txt` ; do

bet ${SUBJECTS_DIR}/${subj_id} ${SUBJECTS_DIR}/${subj_id}_braintmp -f 0.2

fast -b --nopve ${SUBJECTS_DIR}/${subj_id}_braintmp

fslmaths ${SUBJECTS_DIR}/${subj_id} -div ${SUBJECTS_DIR}/${subj_id}_braintmp_bias ${SUBJECTS_DIR}/${subj_id}_biascorrected

bet ${SUBJECTS_DIR}/${subj_id}_biascorrected ${SUBJECTS_DIR}/${subj_id}_brain -f 0.3

done

Once the images have been all skull-stripped, are named such as ${subj_id}_brain.nii.gz, and their quality have thoroughly been checked, then run the following loop to align to a standard brain and segment into gray and white matter:


for subj_id in `cat list_subjects.txt` ; do

flirt -in ${SUBJECTS_DIR}/${subj_id}_brain -ref ${T_brain} -omat ${SUBJECTS_DIR}/${subj_id}_brain_to_T_brain.mat

fast ${SUBJECTS_DIR}/${subj_id}_brain

done

After the commands above have all been sucessfully finished and the quality of the outputs have been checked, then run the next loop to create a table with the results we are interested in. This loop requires the command mat2det (available here). If some of the subjects failed in the previous step, and it is not possible to recover, then it might be time to remove them from the list_subjects.txt file.

Obs: We have observed different levels of performance for the measurements of brain size with different datasets. We are aware that for some datasets, there may be settings that may work better. Different choices for the protocols and rationale their use may be discussed in our mailing list (see below).


echo "subj_id,eTIV_FLIRT,FASTvol_noCSF" > global_size_FSL.csv

for subj_id in `cat list_subjects.txt` ; do

eTIV=`./mat2det ${SUBJECTS_DIR}/${subj_id}_to_T_brain.mat | awk '{ print $2 }'`

volGM=`fslstats ${SUBJECTS_DIR}/${subj_id}_brain_pve_1 -V -M | awk '{ vol = $2 * $3 ; print vol }'`

volWM=`fslstats ${SUBJECTS_DIR}/${subj_id}_brain_pve_2 -V -M | awk '{ vol = $2 * $3 ; print vol }'`

voltissue=`expr ${volGM} + ${volWM}`

echo "${subj_id},${eTIV},${voltissue}" >> global_size_FSL.csv

done

The outputs will be saved in the current directory, in a file named global_size_FSL.csv. This file can be opened in spreadsheet applications such as OpenOffice Calc or MS Excel.


Where to find help

General information about the ENIGMA and this protocol can be found in the consortium website:

https://enigma.ini.usc.edu

Questions about image processing related to this project can be directed to our mailing list. Subscribe to be informed and receive the latest updates by clicking the Join button above:

And send emails to: enigma@lists.ini.usc.edu

General documentation and support for FreeSurfer and FSL can be found in their respective websites and mailing lists:


ENIGMA on social media: