Welcome to the scripting practical session. This practical contains
many parts, starting at a very simple level and moving through to
advanced scripting exercises. Do not expect to finish all of this
practical in a single session.
If you are very new to scripting then the first few exercises will
take a while but you will soon find that, having started, progressing
with the other scripting exercises becomes easier and you can work
through others on your own.
If you are experienced with scripting then feel free to skip the
exercises which you are already comfortable with and move onto the
ones more focussed on the FSL utilities towards the end.
The practicals explore both the basics of scripting and some
of the various FSL command-line utilities. The following overview
gives an indication of the content of each practical:
- First script
This practical starts with the very simplest of scripts: uses
- Echo and Wildmasks
Familiarisation with the use of wildmasks, and echo: uses
- Command Line Arguments
Take a the script from the first practical and modify it to use arguments passed in by the user as
$1, etc. Advanced section introduces
shift for more complicated command line argument passing.
Read the voxel dimensions of an image and display them: uses
fslval. Note - this script is modified later on.
- If and Test
Uses if and test commands to check for correct usage syntax and see if files exist.
- Batch Processing
Creating scripts to run on whole directories of files or a user-specified list of files. Examples involve the use of
basename as well as
- Calculating Volume and FOV
Use the calculator
bc to calculate image quantities and rescale images: uses
fslval, fslstats, fslmaths and a previous script (see above).
- Lightbox View
Make a script with loops to create a lightbox view of an image: uses
- Processing a Stimulus File
Create a custom Feat EV file from a general stimulus file. Learn to manipulate columns and entries with
grep, awk and
sed to create the desired output. Very useful exercise for those doing non-block-design fMRI experiments.
- File name handling
Make scripts ignore extensions like .nii.gz and change path names in Feat design files: uses
- Advanced scripting
A complicated exercise, to produce an animated image showing a
rotating maximum-intensity-projection activation colour overlay
combined with a mid-sagittal-slice from a background image.