Processing Image Batches

  1. Specifying a file basename as a variable
    Write a script ("baserun") that echoes the basename (i.e. vol0001 for vol0001.nii.gz) of every file in a directory. You will need to use the command basename. Hint: basename vol0001.nii.gz .nii.gz will output vol0001

  2. Specifying multiple inputs
    Modify one of the above script to use all of the user specified arguments, rather than everything in the directory.
    If you type
    ./baserun im2.nii.gz im3.nii.gz
    you should get
    im2
    im3

  3. Multiple BET calls
    Write a script that applies BET to all images in a directory.
    Call the output images imagename_brain
    Type
    ./baserun im2.nii.gz im3.nii.gz
    and check that BET runs on these two images.

    Look here for the cheat.