Opening external tools from VivoQuant via VivoScript
Sometimes it is useful to be able to start external programs from within VivoQuant. VivoScript provides a function for this:
1 2 |
VQ.startTool("ProgramName"); VQ.startTool("ProgramName", baseDir, parameterList); |
with ProgramName being a pre-configured name of the tool to start (see below on how to add your own tools), while the optional baseDir defines the current working directory the tool is started in. Finally, the parameterList is an array of optional parameters passed into the tool from the command line. Depending on the tool you are using such parameters could be used to for instance pass in files to the new tool.
This features requires VivoQuant 1.23alpha29 or higher.
Adding new Tools
-
Windows: The easy way
An even easier way to add new tools might be to write a small reg-script and import that into the Windows registration editor. Open a text file in your favorite plain text editor (for instance in Windows’ Editor), and copy and paste this code:
1234Windows Registry Editor Version 5.00[HKEY_CURRENT_USER\Software\inviCRO\VivoQuant\Tools]"ImageJ"="C:\Program Files\ImageJ\ImageJ.exe"After adjusting it to your needs, save this as a ‘tools.reg’ file and double click to import it (there will be warnings, however, we know what we are doing).
-
Windows: The long way
For your own security VQ cannot just start any program installed on your computer, however, you have to add these tools first. On Windows this is done by adding an entry to HKEY_CURRENT_USER\Software\inviCRO\VivoQuant\Tools as shown below (please note you might have to create the Tools folder also, if no other tools have been added already):
- Find the VivoQuant entry under Software\inviCRO\VivoQuant under HKEY_CURRENT_USER in the left side bar.
- Unless available already: Create Tools entry, by right clicking on VivoQuant in the left bar, and choosing New|Key.
Otherwise click on Tools. - Click into the right field (under (Standard)) and select New|String, then give your new tool a name (see programName above, e.g. use ‘ImageJ’, ‘Matlab’, etc…); each tool needs its own unique name.
- Double click on your new name, and specify the path to the tool, e.g. something like ‘C:\Program Files\ImageJ\ImageJ.exe’
Your result should look similar to this now:
-
The Mac way
On your Mac open the Terminal application and copy and paste this to the command line:
1defaults write com.inviCRO.VivoQuant 'Tools.ImageJ' '/Applications/ImageJ/ImageJ64.app/Contents/MacOS/JavaApplicationStub' -
The Linux way
Should you be using Linux, please open ‘~/.config/inviCRO/VivoQuant.conf’ and add a [Tools] section:
123[Tools]LumiQuant=/opt/invicro/bin/lumiquantImageJ=/usr/local/bin/imagej
Using the new tool
Once you have setup the tools you need, you can call them from VivoScript and pass parameters to them. For instance, let us look at an application that opens the currently loaded reference image into ImageJ:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
// define the output path here: var path="C:/Users/lackas/Desktop/"; // Make sure data is loaded already: if (VQ.dataManager().size() < 1) { VQ.showMessage("Please load a dataset first."); VQ.abort(); } // store DICOM data into local folder, reference image, multi-slice format var filename = path+"export.dcm"; VQ.storeAsDICOM(filename, 0, 0); // start ImageJ with filename var res = VQ.startTool("ImageJ", ".", [filename]); // Check status if (res != "Done") { VQ.showMessage("Error: "+res); } |
And here is the result of running the script with a mouse CT dataset opened:
Please feel free to leave questions or comments below.
References
- Download ImageJ: http://rsbweb.nih.gov/ij/download.html
- VivoScript documentation: http://www.vivoquant.com/files/manual/vqscript.html
- Download VivoQuant: http://www.vivoquant.com/