Autorecon2: Difference between revisions
Line 74: | Line 74: | ||
== The Mysterious Case of the Missing Chunks == | == The Mysterious Case of the Missing Chunks == | ||
After running autorecon2, you may notice that skill strip is cutting out grey/white matter as well. This really only can be seen when checking quality via tkmedit, so be sure to do that. It also usually happens around the temporal lobes. The cause is unknown, but we suspect it is related to the larger head coil used with the Semantic Imagery experiment. We have been experimenting with different methods to enhance the T1 MPRAGE image so that autorecon2 is better able to detect the white matter tracts and the gray matter boundaries and avoid missing large chunks of the anterior temporal lobes. The following technique seems to work, and it makes use of the segmentation files that SPM generates, and the intensity thresholding provided by MRICron. As of Jan 29, 2018, only | After running autorecon2, you may notice that skill strip is cutting out grey/white matter as well. This really only can be seen when checking quality via tkmedit, so be sure to do that. It also usually happens around the temporal lobes. The cause is unknown, but we suspect it is related to the larger head coil used with the Semantic Imagery experiment. We have been experimenting with different methods to enhance the T1 MPRAGE image so that autorecon2 is better able to detect the white matter tracts and the gray matter boundaries and avoid missing large chunks of the anterior temporal lobes. The following technique seems to work, and it makes use of the segmentation files that SPM generates, and the intensity thresholding provided by MRICron. As of Jan 29, 2018, only ''Brocasarea'' and ''Accumbens'' have SPM12 configured correctly, so you will need to copy the subject/mri folder to one of those two computers and work there. I made a folder called ~/FIX and have been working there, e.g.,: | ||
*~ (home directory) | *~ (home directory) | ||
**/FIX | **/FIX | ||
Line 91: | Line 91: | ||
# Save and run batch_example. This creates a set of MPRAGE files I will discuss below. | # Save and run batch_example. This creates a set of MPRAGE files I will discuss below. | ||
batch_example | batch_example creates a series of segmented MPRAGE files that contain specific parts of the image. | ||
* c1MPRAGE.nii contains the grey matter. | * c1MPRAGE.nii contains the grey matter. | ||
* c2MPRAGE.nii contains white matter. | * c2MPRAGE.nii contains white matter. |
Revision as of 16:53, 29 January 2018
The -autorecon2 directive tells Freesurfer to convert the cubic voxel-based T1 (high-resolution anatomical) image into a triangular mesh surface model. It generates a separate surface mesh for each hemisphere, and from this point on in the process, each hemisphere will have its own independent set of files.
If you checked your data carefully after autorecon1 has finished you should find that the second step goes fairly smoothly.
There is a script, autorecon2.sh
that is a wrapper for the recon-all command with the -autorecon2 directive. It simply requires you to specify a valid subjectid within your $SUBJECTS_DIR
. Note that a valid subjectid will be the name of the directory generated by Freesurfer when executing the -autorecon1 directive. For example, if my source data prior to running Freesurfer came from:
- /home
- /mydirectory
- /fmri
- /sub_001
- /MPRAGE
- /sub_001
- /fmri
- /mydirectory
My $SUBJECTS_DIR
might be set to be /home/mydirectory/fmri
. After running autorecon1.sh, depending on the value given for the -subjid
flag, a new directory might now exist containing all the resulting outputs, e.g.:
- /home
- /mydirectory
- /fmri
- /FS_001
- /fmri
- /mydirectory
For all subsequent processing steps, the subject id is FS_001 for this data set, and not 001.
If you have an autorecon2.sh script in your ~/bin/ directory, inspect it first before running it, and ensure that you understand what it's doing. For reference, here's what a script of mine looks like:
#!/bin/bash # Usage: autorecon2.sh <subjectid> PROJECTROOT=~/ubfs/cpmcnorg/openfmri/booth/ #Change this: where are your data located? OLD_SUBJECTS_DIR=${SUBJECTS_DIR} #Your subjects directory might be initially set to something else SUBJECTS_DIR=${PROJECTROOT} #now tell freesurfer where the subject in question resides export SUBJECTS_DIR echo SUBJECTS_DIR: ${SUBJECTS_DIR} subjectID=$1 recon-all -autorecon2 \ -subjid ${subjectID} SUBJECTS_DIR=${OLD_SUBJECTS_DIR} #reset subjects_dir to whatever it was before export SUBJECTS_DIR
When I ran my autorecon1.sh script, it created a new folder called FS_T?_* for the individual (I was working on longitudinal data, where there was a T1 and T2 time point for each participant). When I ran it for the T1 data for subject 501, it created a folder in $SUBJECTS_DIR called FS_T1_501. After editing the brainmask.mgz file for this participant, I ran autorecon2.sh like this:
autorecon2.sh FS_T1_501
The -autorecon2 directive takes several hours to complete. Initial estimates were as long as 11 hours, though it recently took only about 5 or 6 hours to run on a different participant. Either way, you should plan to do some other work while you're waiting for this step to be completed.
N.B.: This script may report that it exited with errors, with the error log file indicating that a script was unable to find ribbon.mgz. As far as we can tell, this error is inconsequential and can be ignored.
Quality Control
Note: There is a systematic blip that occurs on the medial left hemisphere near the corpus callosum and ventricle areas. Don't worry about this, since it's not grey matter anyway.
After this step has completed, you can overlay the surface mesh vector on to the source T1 anatomical image in tkmedit:
tkmedit <subject_id> brainmask.mgz -aux T1.mgz -surfs
You will want to confirm that the pial boundaries, which define where the grey matter is located, correspond to the source image data. The following wiki page has an example of where it includes dura or skull: Pial Editing Another potential problem that we have seen is where the grey matter signal is too faint, causing this stage to omit these voxels in the mesh. In one example, the top of the head appeared "flattened" because of signal drop-off. I'll hopefully be able to find a solution to this problem with the Freesurfer people.
Next, load up the generated mesh in a program called tksurfer:
tksurfer <subject_id> <hemi> <surf>
Where subject_id is the name that you passed to autorecon2.sh (e.g., FS_T1_501), hemi is the hemisphere you want to load (one of either lh or rh), and the surf flag indicates which surface you want to view (typically I look at the 'inflated' surface.
tksurfer FS_1001 lh inflated
You can rotate the surface around along all 3D axes and confirm that it looks like what you would expect a normal brain to look like. Errors in the surface construction would be evident by strangely-shaped features, like spikes or pits along the surface.
Another useful application of our surface mesh is that it lets us fix potentially catastrophic misalignments manually (to get the functional images in the right ballpark) as described in the FreeSurfer wiki
We will probably find ourselves getting more experience with the issues described on this Freesurfer tutorial as time goes on: [1]
Regenerating the Surface
When you are finished editing the voxels, you will need to regenerate the surfaces. Since the white matter hasn't been changed, as we do not currently edit the white matter (can be done with control points, here: https://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/ControlPoints_tktools), you don't need to resegment the entire volume (e.g. you don't need to completely re-run autorecon2.sh). You can simply regenerate the pial surface with:
recon-all -autorecon-pial -subjid <subject_id>
Or use the autorecon2_fix.sh script.
autorecon2_fix.sh FS_T1_501
The Mysterious Case of the Missing Chunks
After running autorecon2, you may notice that skill strip is cutting out grey/white matter as well. This really only can be seen when checking quality via tkmedit, so be sure to do that. It also usually happens around the temporal lobes. The cause is unknown, but we suspect it is related to the larger head coil used with the Semantic Imagery experiment. We have been experimenting with different methods to enhance the T1 MPRAGE image so that autorecon2 is better able to detect the white matter tracts and the gray matter boundaries and avoid missing large chunks of the anterior temporal lobes. The following technique seems to work, and it makes use of the segmentation files that SPM generates, and the intensity thresholding provided by MRICron. As of Jan 29, 2018, only Brocasarea and Accumbens have SPM12 configured correctly, so you will need to copy the subject/mri folder to one of those two computers and work there. I made a folder called ~/FIX and have been working there, e.g.,:
- ~ (home directory)
- /FIX
- /SUBJECT_ID
- /mri
- MPRAGE.nii
- /mri
- /SUBJECT_ID
- /FIX
Note that if the .nii files is gzipped (i.e., as MPRAGE.nii.gz) you will need to use gunzip to unzip it, because SPM does not work on gzipped files.
- Open matlab. Make sure you have spm12 and batch_example in your path.
- To do so, click "add path" and add
/opt/northwestern/batch
and/opt/spm12
.
- To do so, click "add path" and add
- Open batch_example to edit. Note: there is an old batch_example and a new one. We need the new one.
- Change root dir and work dir to the folder containing the data to be fixed (e.g. ~/FIX). These are on lines 160 and 167, I believe.
- Change all_subjects (line 59) to the subject you want to work on.
- Uncomment the
b_name
line that defines it as {'slice_b', 'region', ...} and has aTEST
comment at the end. Comment out all otherb_name
files. - Save and run batch_example. This creates a set of MPRAGE files I will discuss below.
batch_example creates a series of segmented MPRAGE files that contain specific parts of the image.
- c1MPRAGE.nii contains the grey matter.
- c2MPRAGE.nii contains white matter.
- c3MPRAGE.nii contains CSF.
- c4MPRAGE.nii contains dura.
- c5MPRAGE.nii contains skull.
- mMPRAGE.nii contains a contrast-adjusted version of MPRAGE.nii.
WORK IN PROGRESS
We want to make an MPRAGE file that just contains white and grey matter, and CSF. To do so, we will use 3dcalc to essentially "subtract" the parts skull and dura from the contrast-adjusted MPRAGE.
- Open
3dcalc
in terminal. - cd to the subject's mri folder.
- Type
3dcalc -a c4MPRAGE.nii -b c5MPRAGE.nii -expr '(a+b)' -prefix strip_mask.nii
. This creates a mask of the skull and dura. - Type
3dcalc -a mMPRAGE.nii -b strip_mask.nii -expr 'max(1, a-(789*))' -prefix strippedMPRAGE.nii
. This subtracts the dura and skull MPRAGE file from the contrast-adjusted MPRAGE file. - To check to make sure strippedMPRAGE.nii is right, open mricron by searching in the Ubuntu search bar. Click open and then open the strippedMPRAGE.nii file. It should only be a brain with no dura or skull. A slight outline of the head might still be visible, but anything close to the brain should be stripped off. This should make it extra clear to recon-all that the non-black regions are brain tissue, not skull.
You will then use this to do autorecon1. See the autorecon1 page to see how to run autorecon1 with multiple MPRAGES/a T2 image to help eliminate the missing chunks problem further.