Using the mipav command

Jump to: navigation, search

To call scripts from other programs, you use the mipav command in the Command Prompt dialog box. The correct syntax of this command follows.

Syntax of the mipav command
mipav [-hH] [-iI] imageFileName [-sS] ScriptFileName [-vV] voiFileName [-hideHide]
Displays help for the mipav command in a Command Prompt window
Hides application frame
Image file name, -m for multifile
Script file name
XML script file name
VOI file name
Specifies the output file name when "Save Image As" script command is used
[-d] [-D]
Set a value of a variable used in the script
[-inputdir] [-INPUTDIR]
Specifies the input directory with images
[-outpudir] [-OUTPUTDIR]
Specifies the output directory with images
Exits the MIPAV program

Figure 31 shows examples of the mipav command.

Note: When calling MIPAV scripts from other programs, be sure to enter an Exit command at the end of the MIPAV script.

Figure 31. Examples of using the mipav command
Example 1: Starts MIPAV

> mipav

Example 2: Starts MIPAV and opening an image
> mipav imageFileName
Example 3: Starts MIPAV but does not display frame, opens an image, and runs a script on the image.
> mipav -i imageFileName -s scriptFileName -hide
Example 4: Starts MIPAV, runs a script, opens the first image, opens two VOIs associated with that image, opens a second image, and associates another VOI with that image
> mipav -s scriptFileName -i imageFileName1 -v voiName1 -v voiName2 -i imageFileName2 -v voiName3
Example 5: Exiting the MIPAV program
> mipav Exit

To display help for using the mipav command
1 Navigate to the mipav directory on your computer.
2 Select Start > All Programs > Accessories > Command Prompt. The Command Prompt dialog box opens.

3 Type mipav -H (refer to Figure 32).
Figure 32. Command Prompt dialog box showing command to open Command Line Help dialog box


4 Press Enter. The Command Line Help dialog box (Figure 33) opens.

Figure 33. Command Line Help dialog box, which shows the syntax of the mipav command as well as examples


To open a DICOM image dataset
Suppose you want to open a single DICOM image from a collection of experiments made in 2004 named exp2004. You would type the following command in the Command Prompt dialog box in Microsoft Windows XP:

C:\ mipav -i i:\images\DICOM\exp2004\I04301.dcm

To open VOIs into that image
You can open VOIs as well as the image from the command line. In Windows XP, it would be the following:

C> mipav -i i:\images\DICOM\exp2004\I04301.dcm -v i:\VOIs\exp2004\levelset1.xml

In a UNIX BASH shell, this command looks like:

$ mipav -i ~/images/DICOM/exp2004/I043401.dcm -v ~/VOIs/exp2004/levelset1.xml

To open multiple images using compound commands
Suppose you know that there were multiple DICOM datasets in exp2004. To open every DICOM image on the Windows computer, you would type:

C> for %f in (i:\images\DICOM\exp2004\*01.dcm) do mipav -i %f

In this case, you must know something of the file structure of that dataset-you assumed that all image datasets had only one image ending in 01. However, the disadvantages of this format is the possibility of not opening all of the images at the same time.

A similar loop to open image sets on a UNIX BASH command line looks like:

$ for FI in `ls ~/images/DICOM/exp200?/*01.dcm`; do ./mipav -i $FI &; done

There are three significant differences between the BASH command and the Windows command (beside from how a directory is specified):

The use of the ls command when listing the directory-The reason you must list the ls is due to the way a for loop works in BASH. The for requires a command and uses that command's return value as the boolean test to continue repeating the interior list of commands. By contrast, the Windows command shell expects a list of files. So long as the file listing has more results to list, BASH continues to repeat the mipav command.
The use of a wildcard when listing the directory-BASH allows the directory list to use wildcard characters in more than one location, which permits searching for the images in any seven-character directory beginning with exp200 as well as all files ending in 01.dcm. This means that MIPAV starts with images from the exp2004 directory, as well as exp2003 or should it exist, exp200M, since the ? matches any character, not just a number. This is an example of a feature of the shell being used to expand the results. Windows command shell does not support this feature.
Sending the mipav command to operate in the background-BASH is a shell that allows job control. Using this feature allows you to start MIPAV and continue it asynchronously, permitting BASH to retain control. BASH can then continue processing the loop and starting MIPAV with the next matching file. Each MIPAV runs concurrently and allows you to manipulate each image with MIPAV at will. Although this allows you to see the images at the same time, the disadvantage is that the various windows begin to clutter the screen causing operator confusion.

When there is more than one MIPAV application window running, it's possible to close the wrong image by closing the wrong MIPAV application. In addition, operations that can occur between windows when running a single MIPAV may not be transferable between images being run by separate MIPAV windows.

While starting more than one MIPAV to display a set of images may be fine in limited applications, it causes needless overhead within in the operating system wasting system resources.

Using Shell scripting to lessen typing