Recording scripts

From MIPAV
Revision as of 22:22, 21 February 2012 by Angelfish100 (Talk)

(diff) <previousrevision> | Latest revision (diff) | <nextrevision> (diff)
Jump to: navigation, search

To record a script using the Scripts toolbar:
1 Start MIPAV. The initial MIPAV window and the Output window open.
2 Open the images on which you want to run the script. The MIPAV window expands.
3 Click the Start Recording Script icon on the scripting toolbar. See Figure 7.


Figure 7. Click the Start Recording Script icon to record a script

Script RecordScript1.png

Note: The Start Recording Script icon turns red to indicate that MIPAV is now recording a script.
4 The Record New Script dialog box (Figure 9) opens. The following placard message appears at the top of the dialog box: The script is now recording. Your actions will appear below.
5 Open any previously created VOIs that you want to use with the images. Perform any algorithm or utility.
6 Repeat steps above as needed.
7 In the Record New Script dialog box, select File > Save. The Save dialog box opens. Type a name for the script and either the .sct or .xml extension in File name.
8 Click Save. The program saves the script in the scripts home directory.
9 Click File > Exit to close the Record New Script dialog box. The dialog box closes. You should now be able to select and run the script from Current Script.


Figure 9. Record New Script dialog box
File
Open-Opens a previously saved script. When you select this command, the Open dialog box appears.

Script RecordScript2.png

Save-Saves the script under the specified name. When you select this command, the Save dialog box opens.
Exit-Closes this dialog box without saving the script.
IconOpen.jpg
Open script
Open-Opens a previously saved script. When you select this command, the Open dialog box appears.
IconSave.jpg
Save script
Save-Saves the script under the specified name. When you select this command, the Save dialog box opens.
IconPauseScripting.jpg
Pause scripting
Stops recording the script. When you select this icon, the icon changes to the Resume scripting icon.
IconRecordScript.jpg Resume scripting
Activates the recording process again. When you select this icon, the icon changes to the Pause scripting icon.
IconInsertComment.jpg Insert comment
Allows you to insert a comment into the script. When you select this icon, the Input dialog box opens. Type the comment in Enter comment and click OK. MIPAV adds your comment into the script after the word Comment.

File:MIPAV Scripting18.gif


Figure 8. Input dialog box (A) showing a comment and (B) the comment as it appears in the scripting box
IconFreeMemory.jpg Insert command to collect garbage (free memory)
Frees memory by inserting the command to collect garbage, a Java method that clears all unnecessarily reserved memory. For more information, refer to "Saving a history of actions on images (TBD)" .
IconInsertMIPAVExit.jpg Insert command to end MIPAV
Inserts the command for exiting MIPAV (Exit) into the script, which allows MIPAV to close as a part of the script.
Caution: Do not use the Exit command in MIPAV scripts unless you are calling the script from another program or scripts (Perl, C , Windows batch, etc.).
Scripting box
Displays the action commands (algorithms and utilities) and any comments in the script.
Pause
Stops recording the script. When you select this button, the name of the button changes to Resume.
Enable Edit
Paused the script recording first, then it allows you to make changes or corrections to the script. When you select this button, the scripting box turns from gray to white to indicate that 1) the script is paused and 2) that you can now type, copy, paste, or delete information from the script, and the button name changes to Disable Edit.
Disable Edit
Prevents any changes or corrections being made to the script from typing, pasting, inserting, or deleting information. It does, however, allow MIPAV to record actions on images. When you select this button, the scripting box turns from white to gray, and the button name changes to Enable Edit. It also restarts the script recording.
Help
Displays online help for this dialog box.

Recording a script using the Scripts > Record Script menu
1 Start MIPAV.
2 Select Scripts > Record Script. The Record New Script dialog box opens. The following appears at the top of the dialog box: The script is now recording. Your actions will appear below.

Figure 10. Recording a script via Scripts > Record Script menu

Script RecordScriptMenu1.png

3 Open an image on which you want to run the script. The MIPAV window expands.
4 Perform any algorithms or utilities that you want recorded in the script, as if you run recording from the Scripting toolbar.
For example,
flip the image twice applying step by step the Flip Vertically and then Flip Horizontally option. See Figure 11.

5 The following appears in the Record New Script window:
Flip("input_image_1 ext_image $image1", "flip_axis string X")
Flip("input_image_1 image $image1", "flip_axis string Y")
6 Then, save the image in MINC format using the Save As option and specifying an *.mnc extension in the dialog box. [ 3] The following string appears in the Record New Script window:
SaveImageAs("input_image_1 ext_image $image1", "file_type string .mnc")
Figure 11. At the top: the flipping options available via the Image Toolbar. Below: the original image (A), the same image flipped vertically (B) and then horizontally (C)

Scripts FliipingToolbar.png

Script Image1Unflipped.png>

Script Image2FlippedVertically.png

Script Image3FlippedHorizontally.png

7 In the Record New Script dialog box, select File > Save. The Save dialog box opens.
8 Enter a name for the script, for example, FlippingImagesTwice.sct, and then press Save. By default, the script will be saved in the Scripts Home directory. See "Scripts Home" for details.
9 Click File > Exit to close the Record New Script dialog box. The dialog box closes.
10 Use the Refresh button on the Scripts toolbar to refresh the Scripts Home directory.
11 You should now be able to select and run the script from the Current Script box. See Figure 11.

To pause recording a script

IconPauseScripting.jpg
Pause
IconRecordScript.jpg
Resume Recording

If you are interrupted or need to take a break while you are recording a script, use the Pause icon located on the Scripting toolbar. This allows you to stop recording the script. When you click Pause, the following message appears at the top of the Record New Script dialog box: The script is now paused. Press Resume to resume recording; and the Pause icon changes to Resume Recording. When you return to recording the script, click Resume Recording to resume.


Running scripts