Mipav.cit.nih - National Institutes Of Health

Transcription

http://mipav.cit.nih.gov1

Scripting MIPAV and the Java ImageScience ToolkitEvan McCreedyemail: mccreedy@mail.nih.gov(301) 496-3323Biomedical Image Processing Research Services Section (BIRSS)http://mipav.cit.nih.gov2

MIPAV TeamEmployeesRuida ChengWilliam GandlerMatthew McAuliffeEvan McCreedyJustin SenseneyFellowsSara ShenContractorsAlexandra Bokinsky, Geometric Tools Inc. (Visualization)Olga Vovk, SRA International Inc. (Technical Writing)AlumniPaul Hemler, Agatha Munzon, Nishith Pandya,Beth Tyriee, Hailong Wang3

ExtensibilityPlugins and Scripts Plugins– Written in Java using the MIPAV API. Scripting– Use MIPAV to record and save function(s) applied toimage dataset(s)– Apply the script to any number of image datasetsusing the ‘Run script’ dialog.– Apply the script to any number of image datasets fromthe command line.4

Usability Most NIH intramural researchers notinterested in software-development:– they want a GUI for interactive work MIPAV provides:––––a GUI driven application for user-interaction;scripts to automate repetitive functions;plugins for customized functionality;command line input for batch processing.5

Scripting6

Scripting (Macros) Automation of functions applied to a group of datasets– Increase efficiency and productivity MIPAV does NOT require learning a new scriptinglanguage.– Record and execute scripts via MIPAV’s GUI.– Scripts can also be executed from the command line to processimages from another program or script.7

Scripting8

ScriptingRun scriptRecord scriptAllows the user toselect the directoryused for scriptsList of scripts found in the script’shome directory. The usual suffix is “.sct”.Refresh the list of scripts.9

Script Recording10

Recording A ScriptResets the scriptrecorderInserts a commentinto the scriptOpens script fileInserts a commandto recover memoryInserts an exit command toquit MIPAV. Used inscripts that will be run fromthe command line.Saves script filePauses script recordingAllows manual editingof the script. Foradvanced users.11

Scripting Features Arbitrary ordering of parameters allowedParameter labels to facilitate parameter editingScript execution dialogMore robust error messages12

Script Example– GaussianBlur(“input image 1 ext image image1”,“do output new image boolean true”,“do process whole image boolean true”, )13

Script Lab1.Open an image2.If an algorithm is to operate using a VOI, the VOI must be loaded from disk using VOI OpenVOI Open VOI3.Start script recording4.Run the algorithms in the order specified5.Save the script when done14

Running a Script15

Running a Script16

Running a Script17

Scripting from the Command Line MIPAV can be called from scripts (Perl, batch,shell scripts, etc.)18

Calling a Script from theDOS command line19

Writing a Script for BatchProcessing Do not record loading VOIs into the script –we load these from the command line with the-v optionDon’t forget to “Save As ” before finishing– -o options saves the result image using the userprovide string. E.g. “-o outputFileName” Optionally, add an Exit() command to the endof the script– An Exit() will be automatically added to theend of a script executed with the -hidecommand20

Classroom LabWriting a Script for BatchProcessing – Lab1.Open an image2.Open a VOI3.Start script recording4.Mask the image5.Save result image as 6.Save as new script whendone – call it example.sct21

Batch Processing with MIPAV From the command line:– We can call MIPAV to run the script we have recorded– We can call a batch script or shell script to run a MIPAV active script– Windows: Batch scripts (.bat files) Cygwin (http://www.cygwin.com/) ActivePerl– Linux/UNIX/Mac OS X Shell scripting (bash, tcsh, zsh, etc.)PerlPython22

Lab for Batch Processing withMIPAV1. Open the command shell2. At the command prompt:mipav –s example.sct –i image.xml –v voi.voiNote: Runs the script just once on the given image23

Batch Processing with MIPAVMultiple images can also be processed through the use of scripting:@echo offrem usage: loop xml.bat image directory script voi fileecho processes xml files in a dir with a mipav script, using a voifor %%f in (%1\*.xml) do "C:\Program Files (x86)\mipav\mipav" -i %%f -s %2 -v %3Similar scripts are even easier to write in shell scripts and Perl programs.24

Command Line Notes Use the –hide option to prevent the MIPAV GUIfrom showing up. The –m option should be used to open multi-fileimages (such as DICOM volumes). Use the –help option to learn about othercommand line switches25

Java Image Science Toolkit Originally developed at Johns Hopkins, now alsosupported by Vanderbilt (LGPL license) Created as a set of MIPAV extensions & plugins Main features–––Automated GUI generation for application pluginsGraphical image processing workflow layout toolsCommand line interfaces http://www.nitrc.org/projects/jist26

Installing JIST Install MIPAV– Download & install the MIPAV version compatiblewith the release of JIST you will be using– Latest release of JIST works with MIPAV 5.3.127

Installing JIST (cont.) Download the JIST jar file Use MIPAV’s Plugins - Install plugin dialog28

JIST Plugin Selector Useful for running or debugging a single JISTmodule29

JIST Layout Tool Connects JIST modules together to create imageprocessing workflows GUI interface30

JIST Process Manager Run from the Layout Tool or standalone Executes layouts and displays status31

JIST Lab Get JIST from http://www.nitrc.org/projects/jistInstall JISTCreate a simple workflow–––Choose a MIPAV algorithm (e.g., Median filter)Select the input image for the moduleOutput the result image to an External file32

sUbiquitousfile readerFile writer33

Thank you!34

Matthew McAuliffe Evan McCreedy Justin Senseney Fellows Sara Shen Contractors Alexandra Bokinsky, Geometric Tools Inc. (Visualization) Olga Vovk, SRA International Inc. (Technical Writing) Alumni Paul Hemler, Agatha Munzon, Nishith Pandya, Beth Tyriee, Hailong W