Introduction - BET

Brain Extraction is a crucial step in many analysis pipelines - particularly for structural analysis involving segmentation, where an accurate brain extraction is important. It is also important for registration, but in this case the brain extraction does not have to be highly accurate, and small errors are fine. Running BET, to perform the brain extraction, is very easy to do, but getting highly accurate results can involve some skill and patience.

Contents:

BET basics
Explaining the basics of BET brain extraction and how to adjust the parameters to cope with difficult images.
Troubleshooting Brain Extraction (optional)
Learn how to deal with some more problematic brain extraction cases.

BET basics

Starting the GUI

Start by opening a terminal and going to the correct directory:

cd ~/fsl_course_data/intro

Most FSL programs can be run from the command-line without using a GUI, by typing fully lowercase names (e.g. bet). Many programs also have a GUI, which can be started via the fsl mini-GUI (type fsl) or by typing a capitalised version of the command name (e.g. Bet).

(Note that on Mac OS, the command line call to the GUI has _gui appended (e.g. Bet_gui), because Macs can't distinguish between lower-case and upper-case...)

Start the fsl GUI and click on BET, to see how this all works. Now exit both of these GUIs and start the Bet GUI directly from the terminal (note: use & after the command to make it run in the background).

Running BET

Using the Bet GUI, set the input file to structural.nii.gz; use the right-hand file selector button rather than typing this in by hand as it minimises the chances of errors. Turn on various optional outputs (brain extracted image, binary brain mask and skull surface image - see Advanced Options tab) but leave the other settings as they are. Note that the GUI suggests the default output name structural_brain.

When done click on Go to run BET and then exit the GUI once it's done. You will see that when you pressed Go the actual command carried out was printed in the terminal; many of the FSL GUIs will do this, in order to help you see what's actually going on. Also in the terminal you will see Finished appear once BET has finished running (you may need to hit return to get a visible prompt back after seeing "Finished").

Use ls -lrt to see what files got created and view the various outputs (this sorts the files according to file creation date, with the most recent at the bottom, making it very easy to see what the most recently created files in a directory are). Note that if this does not give any output then your GUI is probably not running in the background, but you can still make it run in the background by pressing control z, and then typing bg in the terminal (and after this you can run the ls command).

Viewing the results

View the brain mask overlaid onto the original image by first loading the original image into FSLeyes and then adding the mask image. Change the transparency and colour of the overlay so that you can get a better view of the success of the brain extraction. Remember that for registration purposes the brain extraction can contain some small errors, but if you were going to use it for segmentation purposes then it would need to be much more accurate.

Varying the fractional intensity threshold parameter (-f)

The usage for the command-line version of bet is:

bet <input> <output> [options]

where input and output stand for filenames and options can be many, or none, of the available extra options.

You can just type bet to see the usage description (first line of the output) as well as a description of the many options available. Have a look at the command that the GUI printed in the terminal when you pressed OK previously, which gives an example of how it works.

Using the command line, try setting the Fractional intensity threshold (the -f option on the command line) to 0.2 and 0.8, in turn, to see the effect it has (save these with different output image names and load both into FSLeyes). This option controls the threshold that distinguishes brain from non-brain; if you reduce it from the default value of 0.5 then the brain estimate gets larger, and vice versa.


Troubleshooting Brain Extraction (optional)

cd ~/fsl_course_data/intro

This part of the practical is optional, but you are encouraged to do it in the session, if you have time, or outside of the session. The objective is to learn how to deal with some more problematic brain extraction cases (which are relatively common with images that have large FOV and/or substantial bias field - so this is a highly useful skill).

Using the gradient threshold option (-g)

Run BET on sub3m0. Note that the cerebellum is underestimated. We can improve this by changing the gradient threshold -g (from its default of 0) to 0.5. This option causes the overall fractional threshold (controlled globally by -f) to vary linearly with slice number - to get smaller at the bottom and bigger at the top, or vice versa. Run this and note that we have now underestimated the top slices! However by combining the gradient option with the main (-f) option we can get a good overall result: try -f 0.3 -g 0.2 (or maybe you can do even better!).

Dealing with large FOV images

The final example is of a head image with a large amount of neck present - run BET on bighead to see a problem. Because of the neck, the initial brain surface is initialised too low in the image. There are several ways to deal with this:

  1. crop your image first to remove the neck
  2. provide an estimate of the centre of the brain
  3. use other BET options that might be more robust

Cropping the image can be performed manually using fslroi but is easier using the automated tool robustfov. For example:

robustfov -i bighead -r bighead_crop

Run this command and look at the output image. It is then possible to run bet directly on this cropped image (try it and see how it performs).

It is also possible to crop images directly in FSLeyes: Settings > Ortho view > Tools > Crop.

The second option, which leaves the large FOV, is to set the initial centre by hand via the -c option on the command line. Try this out using FSLeyes to get a rough guess (in voxels) of where the centre of the brain is in the image and use the values when you call bet with the -c option. Check the output and see whether it improves.

The third option, that can work better in some cases is to use the automatic -R option; this re-runs BET several times, each starting its brain centre at the centre of the previously-estimated brain. Try the -R option instead of the -c option above.

In general our recommendation is to combine the cropping and the -R option, as we have found this to be quite robust on a range of images. However, it may not work on all images, which is why there are a variety of options, as some types of images work better with one strategy than with another. Therefore it is good to be familiar with a range of options.


The End.