Differences between revisions 20 and 22 (spanning 2 versions)
Revision 20 as of 2011-06-29 11:05:42
Size: 4543
Editor: KhoaNguyen
Comment:
Revision 22 as of 2016-09-23 10:15:37
Size: 5499
Comment: updated commands to run if not at an organized course- added bash commands as well. added link to Download page w/ info about how to source FS
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
[[FsTutorial|top]] | [[FsTutorial/FslFeatFreeSurfer|previous]] [[https://surfer.nmr.mgh.harvard.edu/fswiki/Tutorials|Back to list of all tutorials]]<<BR>>[[https://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial|Back to course page]]<<BR>>[[https://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/FslFeatFreeSurfer|FslFeat Tutorial Homepage]]

----
Line 18: Line 20:
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: If you are '''NOT''' taking one of the formally organized courses, then to follow this exercise exactly be sure you've downloaded the [[https://surfer.nmr.mgh.harvard.edu/fswiki/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:
Line 21: Line 23:
tcsh ## bash
<source_freesurfer>
export TUTORIAL_DATA=<path_to_your_tutorial_data>
export SUBJECTS_DIR=$TUTORIAL_DATA/buckner_data/tutorial_subjs
cd $SUBJECTS_DIR/fbert-feat
ln -s $FREESURFER_HOME/subjects/fsaverage
ln -s $FREESURFER_HOME/subjects/bert

## csh
Line 23: Line 33:
setenv TUTORIAL_DATA <path_to_your_tutorial_data>
Line 28: Line 39:
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. ''Information on how to source [[https://surfer.nmr.mgh.harvard.edu/fswiki/FreeSurfer|FreeSurfer]] is located [[https://surfer.nmr.mgh.harvard.edu/fswiki/DownloadAndInstall#Setup+&+Configuration|here]]''.
Line 30: Line 41:
The subjects 'fsaverage' and 'bert' may already exist in the subjects directory, so ignore any warnings that might be issued that say 'File exists'. 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.

The subjects 'f
saverage' and 'bert' may already exist in the subjects   directory, so ignore any warnings that might be issued that say 'File   exists'.
Line 33: Line 47:
The cortical and subcortical segmentations automatically generated by freesurfer can be mapped into the functional space, which can be useful for doing region of interest (ROI) analysis. This can be done with aseg2feat:
Line 34: Line 49:
The cortical and subcortical segmentations automatically generated by freesurfer can be mapped into the functional space, which can be useful for doing region of interest (ROI) analysis. This can be done with aseg2feat:
Line 43: Line 57:
The segmentation for a particular structure can be extracted to create a binary mask (i.e., a volume where the voxel value is 1 if it is in the structure and 0 otherwise). To make a binary mask of the left putamen, which has been assigned label 12 (see ${FREESURFER_HOME}/FreeSurferColorLUT.txt), use the following command:
Line 44: Line 59:
The segmentation for a particular structure can be extracted to create a binary mask (i.e., a volume where the voxel value is 1 if it is in the structure and 0 otherwise). To make a binary mask of the left putamen, which has been assigned label 12 (see ${FREESURFER_HOME}/FreeSurferColorLUT.txt), use the following command:
Line 53: Line 67:
Line 58: Line 73:
    -fthresh 0.5 -segmentation aparc+aseg.mgz      -fthresh 0.5 -segmentation aparc+aseg.mgz
Line 61: Line 76:
You should see the image below:<<BR>>
{{attachment:tkm-lh.putamen-cor-128-small.jpg}}
You should see the image below:<<BR>> {{attachment:tkm-lh.putamen-cor-128-small.jpg}}
Line 66: Line 80:
Line 73: Line 88:
This will create fbert1.segstats.dat which will be a text file with a table of data. Each row will be a segmentation. The columns will contain various measures, including the number of functional voxels and the mean, stddev, min, max, and range of the cope over each ROI. [[FsTutorial/FslFeatSegStats| Here is an example]]. This will create fbert1.segstats.dat which will be a text file with a table of data. Each row will be a segmentation. The columns will contain various measures, including the number of functional voxels and the mean, stddev, min, max, and range of the cope over each ROI. [[FsTutorial/FslFeatSegStats|Here is an example]].

----
[[https://surfer.nmr.mgh.harvard.edu/fswiki/Tutorials|Back to list of all tutorials]]<<BR>>[[https://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial|Back to course page]]<<BR>>[[https://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/FslFeatFreeSurfer|FslFeat Tutorial Homepage]]

Back to list of all tutorials
Back to course page
FslFeat Tutorial Homepage


Mapping automatic segmentations to the functional space

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
cd $SUBJECTS_DIR/fbert-feat
ln -s $FREESURFER_HOME/subjects/fsaverage
ln -s $FREESURFER_HOME/subjects/bert

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:

## bash
<source_freesurfer>
export TUTORIAL_DATA=<path_to_your_tutorial_data>
export SUBJECTS_DIR=$TUTORIAL_DATA/buckner_data/tutorial_subjs
cd $SUBJECTS_DIR/fbert-feat
ln -s $FREESURFER_HOME/subjects/fsaverage
ln -s $FREESURFER_HOME/subjects/bert

## csh
source your_freesurfer_dir/SetUpFreeSurfer.csh
setenv TUTORIAL_DATA <path_to_your_tutorial_data>
setenv SUBJECTS_DIR $TUTORIAL_DATA/buckner_data/tutorial_subjs
cd $SUBJECTS_DIR/fbert-feat
ln -s $FREESURFER_HOME/subjects/fsaverage
ln -s $FREESURFER_HOME/subjects/bert

Information on how to source FreeSurfer is located here.

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.

The subjects 'fsaverage' and 'bert' may already exist in the subjects directory, so ignore any warnings that might be issued that say 'File exists'.


1.0 Mapping the segmentations

The cortical and subcortical segmentations automatically generated by freesurfer can be mapped into the functional space, which can be useful for doing region of interest (ROI) analysis. This can be done with aseg2feat:


aseg2feat --feat fbert1.feat --aseg aparc+aseg


This command will create fbert1.feat/reg/freesurfer/aparc+aseg.nii.gz. These are segmentations, meaning that each voxel has an integer value that corresponds to a particular structure. The mapping from structure number to name is given in ${FREESURFER_HOME}/FreeSurferColorLUT.txt.

2.0 Creating binary masks

The segmentation for a particular structure can be extracted to create a binary mask (i.e., a volume where the voxel value is 1 if it is in the structure and 0 otherwise). To make a binary mask of the left putamen, which has been assigned label 12 (see ${FREESURFER_HOME}/FreeSurferColorLUT.txt), use the following command:


fslmaths ./fbert1.feat/reg/freesurfer/aparc+aseg.nii.gz \
    -thr 12 -uthr 12 \
    ./fbert1.feat/reg/freesurfer/lh.putamen.nii.gz


To view this binary mask on the anatomical:


tkmedit bert orig.mgz -aux brain.mgz \
    -overlay ./fbert1.feat/reg/freesurfer/lh.putamen.nii.gz \
    -overlay-reg ./fbert1.feat/reg/freesurfer/anat2exf.register.dat \
    -fthresh 0.5 -segmentation aparc+aseg.mgz


You should see the image below:
tkm-lh.putamen-cor-128-small.jpg

3.0 Creating ROI summaries

Once you have the segmentation mapped to the subject's native functional space, you can create summaries of the functional activation. Eg,:


mri_segstats --seg fbert1.feat/reg/freesurfer/aparc+aseg.nii.gz  \
  --nonempty --ctab-default \
  --in fbert1.feat/stats/cope1.nii.gz --sum fbert1.segstats.dat


This will create fbert1.segstats.dat which will be a text file with a table of data. Each row will be a segmentation. The columns will contain various measures, including the number of functional voxels and the mean, stddev, min, max, and range of the cope over each ROI. Here is an example.


Back to list of all tutorials
Back to course page
FslFeat Tutorial Homepage

FsTutorial/MapSegmentationsToFunctionalSpace (last edited 2021-09-22 11:39:22 by DevaniCordero)