Control & Input/output

bye, quit, exit, stop

Exit the program gracefully.


help

Bring up an on-line menu. Like help function with other utilities, this assumes that the unix/linux environment variable “JIP_HOME” is correctly set, so that help documentation is read from $JIP_HOME/documentation. If the script define-jip.tcsh (or define-jip.bash) was executed, this variable will be defined. Note that some aspects of on-line help may be outdated.


show-stacks

Show a list of all stacks in memory, together with dimensions.


delete <stack list>

Delete a list of stacks from memory by referencing their names. If no names are given, delete all stacks.


delete-overlay

Delete the overlay that exists in memory. Only one overlay ever exist in memory; only stacks are named.


Using files of jip command

Rather than enter commands interactively, use an editor to create a file of commands (conventional extension is “.com”) to which you can pass arguments from the unix/linux command line. In the file, arguments will be designated $1, $2, …

    jip file.com input-name smoothing-factor output-directory output-name

This same method can be used inside jip command file to transfer program control to another text file of jip commands. For instance, one might want to average a series of fMRI data, each of which used the same fixed paradigm, in 4 dimensions without hitting memory limitations.

    read av.com 0-49

    read av.com 50-99

     …

where av.com also is a file of jip commands:

     read subject1/fMRI.nii>$1 s1

     read subject1/fMRI.nii>$1 s2

      

      average-stacks av s1 s2 s3 

     write fMRI-average.nii av

     delete

If the volume numbers vary between files (e.g., due a shift in paradigms or injection times), then define the sets of volumes in the file av.com, and use the “io-increment” variable to increment blocks of data.


Reading data files

Data is read from a file using the “read” command. The general syntax contains the “read" command, and optional list of volumes (or time points) to extract from the file, and an optional name to apply to the data stack in place of the default name that will be assigned, which is based upon the name of the file including the directory.

read file.extension>list [optional stack name]          example:  read data.nii>0-10 new_name

File types include NIFTI (.nii) or jip-style files, which are binary header-less data files together with ASCII key-word delimited header files. Multiple file can be read into memory, and each read statement creates a new data stack with the assigned name.


If memory is a limitation and you don’t need to read the entire file at one time, because the operations can be performed on individual volumes, then you can use the read-loop/end-loop structure.

     read-loop file.nii>0-3000

     # do things like registration or smoothing

     end-loop


Writing data files

Data is written using the “write” command. The syntax is

write file.extension <volume list>          example:  write data.nii stack1>0-10 stack2

For NIFTI files, alternative versions with the same general syntax include

write-short

write-float

in order to force the output to be short integers or floating points (not that format are explicit in file extensions when using the jip-style files).


An important feature of the write command is that multiple references of the same file name will append to the file, not overwrite the file. So the following sequence of commands

write T2.bfloat T2-single-volume

write T2.bfloat R2-single-volume

write T2.bfloat S0-single-volume

puts 3 volumes into the same file.


Writing overlays

For now, overlays are written with a completely separate command, rather than just a modified extension:

write-overlay file.ovl

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