-
Notifications
You must be signed in to change notification settings - Fork 77
Skullstripping
Adjusting watershed parameters for ideal brainmask volume
It's super simple and fast!
-
Set up the directory pathway. You'll have to SSH into the computer you'll be working from (usually you'll want openmind), by entering into the terminal:
$ ssh -X <username>@openmind.mit.edu
It will prompt you for the password; once you enter it you'll be logged in remotely to openmind. Then you'll want to move to the main directory of your study where the subject folders are held, by running
$ cd /path/to/subjects/directory
. For example the START brains are located in/mindhive/xnat/surfaces/START
so you'd enter:$ cd /mindhive/xnat/surfaces/START
Then the subjects directory variable for FreeSurfer needs to be set to this directory, which is done with the following command:
$ export SUBJECTS_DIR=`pwd`
Alternatively, the previous two steps could be combined into one by simply entering:
$ export SUBJECTS_DIR=/path/to/subjects/directory
-
Adjust the watershed parameter. Before you do anything, make sure to backup the old brainmask. To do this, go into the
mri
directory of the brain you're working on:$ cd /path/to/subjects/directory/subjectfoldername/mri
And then copy the
brainmask.mgz
file to a backup file calledbrainmask_orig.mgz
:$ cp brainmask.mgz brainmask_orig.mgz
From now on, we only make edits to
brainmask.mgz
. Now open FreeView:$ freeview &
Open the Volume files
brainmask.mgz
andorig.mgz
from themri
folder, and make sure you putbrainmask
aboveorig
. Change the colormap ofbrainmask
to heat and lower the opacity a little bit so you can see it overlaid onorig
. Now, skullstripping is based on the watershed parameter, which helps FreeSurfer make the brainmask. The default value is 25. If the red area of the brainmask volume includes some of the skull, you'll want to lower the watershed parameter. If the brainmask is too small and doesn't include some of the brain matter, you'll want to increase the watershed parameter. To change it, runrecon-all
as follows:$ recon-all -skullstrip -wsthresh <watershed parameter> -clean-bm -no-wsgcaatlas -gcut -subjid <subject folder name>
This command usually takes less than 2 minutes to run. Then you can reopen the brain volumes in FreeView and repeat the process until the brainmask is as good as possible. A good technique is to start by steadily lowering the watershed parameter by ~2 until it starts cutting into the brain, and then bump it back up so it includes the entire brain.
-
Recon the brain. Once you deem the brainmask worthy, rerun
recon-all
on the brain by sending it to the queue on openmind. It's helpful to open a new terminal so you don't have to log out of openmind or whichever other machine you're on. In the new terminal, SSH into openmind:$ ssh -X <username>@openmind.mit.edu
Enter the password, and set up the subjects directory again:
$ export SUBJECTS_DIR=/path/to/subjects/directory
Now send your brain to the queue:
$ echo "recon-all -autorecon2 -autorecon3 -subjid <subject folder name>" | qsub -V -N <subject folder name> -o ./logs/ -e ./logs/ -q recon
This takes hours. Let it run overnight. You can also use the above command to restore the brain if you mess up the brainmask and forgot to make a copy of it beforehand (which should never happen!!). To check on the status of the brain, use:
$ iqstat -m
Make sure it stays there when you first submit it so you know there's no error (see Troubleshooting if it disappears). When it's not there anymore, the job is done! It's a good idea to open FreeView and look at the brainmask again to make sure nothing went wrong.
-
Editing the pial surface To load pial surface and cortex image for more detailed editing, use the following script in the command line:
freeview -v .mri/T1.mgz .mri/brainmask.mgz -f surf/lh.white:edgecolor=yellow surf/lh.pial:edgecolor=red surf/rh.white:edgecolor=yellow surf/rh.pial:edgecolor=red
Source: http://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/PialEdits_freeview
Next step: Control Point Edits