Hey guys, in this video I'm going to go over a short tutorial on how to create brain masks
using FSL.
In this video, I'm going to already assume that you have FSL, also known as "Fossil",
downloaded and installed on your local computer.
So if you open a terminal window you should be able to call FSL commands directly from
the command line before you start anything in the video.
So if I open fsleyes, that's a command to basically open the MRI or fMRI viewer in the
program FSL.
If I run that command and I already have FSL installed on my computer, it should open up
the viewer and we're going to use some commands from FSL to create these brain masks.
I'm going to go over two examples of creating brain masks and let me first go over basically
what a brain mask is first.
I'm going to cd into my desktop window, which has two different NIFTIs and I'm going to
open the viewer and view one of them.
And the one I'm going to view is basically the template MNI brain in a voxel size of
1mm by 1mm by 1mm.
So when that NIFTI file is open, it basically shows you by default a greyscaled image and
if I click on different voxel locations, it gives me the different voxel locations in
x, y, z coordinates in this window here.
And I see that each different voxel has basically a different intensity value, which is given
here.
And this basically produces the different shade of grey that's showing up in the image
at each 3D location, each voxel.
So what a brain mask is, it basically binarizes the different voxel locations.
It's going to give each voxel location an intensity value of either 1 or 0 and so it
makes every voxel in the NIFTI file either 1 or 0.
And then when you re-plot it, it's going to basically fill out a white looking mask.
And these binary brain masks that you can create are then usually used later on for
ROI studies.
So if you have a region of interest, maybe from an fMRI map, you can create a brain mask
of that one region and then basically use it for later ROI analysis.
So in the first example in this video, let me first show how I would create a brain mask
of this NIFTI file, and this would just create a brain mask of essentially the whole brain.
So I'm going to exit from here.
To create a brain mask using FSL, it's very easy.
There's a command in FSL called fslmaths, which basically let's you do a bunch of different
manipulations on different NIFTI files.
And so I'm going to type in fslmaths as the first command.
Then I'm going to pass in the name of the NIFTI file that I want to binarize or create
a mask for.
And then I'm just going to pass in the command or the flag "-bin".
And then you pass in whatever name you want the output image to be called.
So I'm just going to call it "brainmask1.nii".
And then if you click enter that will very quickly create the binary brain mask.
So it will create it as a compressed file by default, so I'm going to double-click that.
And then here I have my brain mask for the whole brain.
So now when I double-click the NIFTI file to open it, this is in a different viewer,
but you can see basically that now instead of having it look like different shades of
grey, the values are either 0 or 1 and the 1 value is given to everything that's brain
and the 0 value is given to everything outside of the brain.
So that's the method that you would use to create a whole brain binary mask or brain
mask.
And in the next example I want to do is creating a binary mask for a region of interest.
I'm going to do it based on an fMRI map.
So the second example is going to be this NIFTI file and this is basically the result
of an fMRI study that was done, so I have a brain fMRI activation map that I'm going
to open up now.
And then I'm going to change the scale to render1 and that will show me the activation
map that I have and again this is in three dimensions because it's a NIFTI.
I have some activated areas and from the analysis, I created this map and the analysis was based
on a Z score of greater than or equal to 3 would be considered activation.
Anything that's red is going to have an intensity value of at least 3.
You can also create a brain mask of just this region of interest instead of the whole brain.
So in the next example, let me show you how you would do that.
It's a very simple extension of what we just did.
So I'm going to exit out of here.
We're again going to pass in the input NIFTI, and so that's what I named it.
Then I'm going to set a threshold.
So the threshold is going to be what gives you just the activated areas.
So like I said before, those fMRI maps were based on an activation threshold where it's
considered activation if the intensity value is 3 or greater than 3.
So I'm going to set the threshold to 3, then I'm going to pass in the "-bin" flag.
You want to make sure you pass in the threshold first before the bin flag or else it won't
work correctly.
And then again, I'm going to name it whatever output I want.
I'm going to call it "brainmask2.nii".
I'm going to click enter, and then again that will take a minute to run.
And it creates the brainmask2 file that's compressed.
And then when I open that brainmask file, we see that it has created a binary NIFTI
file again, where values are either 0 or 1 and again, the region of interest was just
the activated areas and those all get a value of 1.
And any area of the brain that was outside of that activated region gets a 0.
And so that's it for this video, and thank you guys for watching.
*chiptune music*