ImageScript: The Programming Language of MEDx

The goal of ImageScript is to provide users with a simple, easy to use scripting language interface to the MEDx image processing engine. The primary goal is to provide script writers with access to the complete functionality of MEDx that is available through the user interface. To that end we have chosen Tcl as the basis for the scripting language since the style and nature of programming in Tcl is very similar to that of existing shell scripting languages which many scientists currently use. Additionally, we believe that the combination of Tcl and the MEDx programming environment provides important advantages other alternatives such as IDL (interactive data language).

Advantage #1: Data Primitives for Images

ImageScript has data primitives for images, volumes, and ROI's. This has major implications for the level of programming effort required to process images. In particular, the IDL programmer must manage memory, file I/O, and the display of images directly. However, MEDx and ImageScript handle all of these tasks for the script writer.

Naturally, there are functions in ImageScript for accessing data at the pixel level (MxGetVoxel, MxSetVoxel, MxExternCanvas, and MxInternCanvas).

Advantage #2: Medical Image Processing Functions

Another important difference is the large number of functions specialized for medical image processing available through ImageScript. There are over 24 functions for for functional image processing, both voxel- and ROI-based, functions for segmenting images, and for multi-modality registration.

Advantage #3: High-level Programming Environment

Finally, the level of programming in ImageScript is higher than is typically possible with IDL. This arises from the fact that the ImageScript treats images, volumes, and ROI's as primitive data types. The script writer does not need to worry about how to read in different image formats, how the data are stored in memory, or even the details of how they are displayed. The simplicity of programming in ImageScript is exemplified in the following script which performs multi-modality registration:

 
 
MxNewFolder Folder Window

set files [glob $PXHOME/images/API/nec*.img]

MxOpenImage $Folder {{Op 3D}} $files UnRegGroup

MxGetPagesFromGroup $UnRegGroup pages

set PET1 [linedx $pages 0]

MxAlignLinear $PET1 $UnRegGroup 6 {{StdThr 25} \
    {ResliceThr 25}} RegGroup

MxMeanImages $RegGroup MeanPET

MxOpenImage $Folder {{Op 3D}} \
    $PXHOME/images/API/nec.segmri.img MRI

MxAlignLinear $MRI $MeanPET 6 {{MRIThr 10}} RegMeanPET

In this example, all the PET images with file names beginning with nec and ending with .img are read into MEDx as a group. This group of PET images is registered to the first PET image in a single function call. In another function call, the mean of the registered PET images is computed. This mean PET image is then registered to the subject's MRI. This complete script is only 9 lines long!

Top