scripting / batch

Although these tools often are used alone as described, for routine analysis streams it makes sense to incorporate the tools as needed into shell scripts. The following command-line options facilitate batch processing. Most options have a short form (e.g., -f) and a long form (e.g.,  --fastmap-input):

  • -b / --batch                         do not show the GUI (batch mode)
  • -q / --quit                           quit after performing requested functions
  • -M / --map                          create maps using the current time model (defined by other options: -f, -t, -O)
  • --preprocess [name]             apply preprocessing function with given name
  • -O / --open [name]              open time model or preprocessing panel (names below); does not perform mapping/processing
  • -f  / --fastmap-input            read all arguments from file “fastmap” (if present); append further arguments
  • --output-file [file name]        set the output-file as requested
  • --output-condition [name]    output condition (e.g., “A) to a file with default value “condition-A.dat”; this command can be            combined with --output-file [file name] to specify a file name; use of an absolute file path will cause results to be appended so that a series of commands will provide concatenated results
  • -I / --alignment-file [name]  set the alignment input file (defining affine transformation) as requested

Processing panels names: smooth, clip, reslice, asl, pvc, align, register, register-overlays-forward                                                     Note that “align” calculates affine parameters whereas “register” performs image transforms based upon pre-calculated parameters.

Time model names: fmri, pet-rtm, mem, adc, dti, t1, t2

Looping:       “Batch” mode is most useful in a looping structure provided by the OS. For instance, using Linux c-shell,

set here = $PWD;  foreach file (`find . -name myAnalysis`) ;  cd $dir; ff -f ---calibrate putamen --map -q ;  cd $here ;  end;

Examples:

ff raw.nii -O alignment --preprocess register --alignment-file align.com --smoothing 6 --output-file align -q                                will register (“normalize”) file raw.nii using parameters in align.com, smooth by 6 mm, output file align.nii, and quit.

ff epi/011/raw.nii --preprocess reslice -a epi/010/raw.nii --output-file reslice -q                                                                             will reslice file epi/011/raw.nii into voxels defined by epic/010/raw.nii, output the result in epic/011/reslice.nii, and quit.

ff  pet/002/raw.nii --preprocess pvc -q                                                                                                                                              will open the last save PVC file, which specifies the PVC flavor and parameters, apply the PVC correction frame by frame, write the file using the last saved file name, and quit. Note that this example illustrates a general use method: if the output file name is not specified, the file name will be the last name used in the particular preprocessing module.

ff epi/011/raw.nii --open align --alignment-file t1/001/align.com                                                                                                    will apply alignment parameters in t1/001/align.com to epi/011/raw.nii and sit waiting for the user to refine parameters 

ff -f --map --calibrate putamen -q                                                                                                                                                     will read all the things in file “fastmap” (assuming here a PET-RTM model), calibrate k2’ from region “putamen, map & quit

ff -f --output-condition A --output-file /space/myDisk/myGrant/analysisTop/conditionA.dat -q                                                                                                                                               will open the time model and write all info for condition “A” for all ROIs into the specified file. The condition name must match                     an existing condition. If the file name is a absolute file, then information will be appended to it. Otherwise, multiple runs of the application will generate multiple files are local to the respective working directories.

Joseph B. Mandeville, Athinoula A. Martinos Center for Biomedical Imaging at MGH/MIT/Harvard