The First Script - Applying BET

cd ~/fsl_course_data/scripting

This first exercise will create a script that applies BET to an image prior to registering it with another image.

  1. Editing a text file
    Create a new file called bet_vol using the nano text editor.
    To do this just type (in a terminal):
        nano bet_vol
    Notes:
    • Feel free to use any other text editor that you prefer

  2. Making the script
    In this file write a script (one command) which applies BET to a volume called vol and saves the result as vol_brain.
    That is use the same command as you would use in the terminal:
        bet vol vol_brain
    Remember that the first line must be #!/bin/sh

  3. Running the script
    Save the script
    Copy the image im1 to vol (with the .nii.gz extensions)
    Remember to make the script executable with:
        chmod a+x bet_vol
    Run the script by typing ./bet_vol (you need the "./" because the current directory (".") may not be in your PATH)

  4. Testing the script
    Check that the script wrote out the image vol_brain and that the result is sensible (do a visual check with slices)

  5. Commenting the script
    Add a comment to the script that explains what it does.
    A comment is any line (except the first) which starts with #

    If you are stuck you can look at the cheat.