• Before learning things systematically, here is a fairly simple script which is very powerful and useful for modifying for many different tasks.
      for filename in *.nii.gz ; do
        fname=`$FSLDIR/bin/remove_ext ${filename}`
        fslmaths ${fname} -s 2 ${fname}_smooth2
        mv ${fname}.nii.gz ${fname}_smooth0.nii.gz

  • What this does:
      For each image (*.nii.gz) it smooths it to make a new one of the same name but ending in _smooth2 and also renames the unsmoothed image to end with _smooth0
  • How this works:
    • The variable filename is used in a for loop to go through each name matching *.nii.gz
    • The variable fname is set to the filename with the ending (e.g. .nii.gz) removed.
        Don't worry about how this works for now - the details will be explained later.
    • ${filename} and ${fname} are used to get the values (contents) of the variables
    • fslmaths is used to do the smoothing.
    • mv is used to do the renaming (notice that .nii.gz is needed here, but not for the fsl tools, as they work with or without the .nii.gz endings).