[ImageJ-devel] Macros and scripting in Imagej 2.0

Grant B. Harris gharris at mbl.edu
Wed Sep 7 15:18:42 CDT 2011


All --

Following-up on Lee's message this morning and some of the chatter on 
the chat, I'm adding my two (perhaps even three)  cent's worth...

-- Scripting Languages

Our plan is to use the scripting engine in Java 6 (JSR-223 Scripting for 
the Java Platform).  This enables us to be 
polyglotic/language-agnostic... Jython, Closure, JavaScript, etc.

As mentioned in the chat, BeanShell is interesting for the fact that it 
is syntactically very similar to the ImageJ Macro language - The Macro 
Language is a DSL (domain specific language) for image processing and 
manipulating the ImageJ environment.   "Porting" it to Beanshell (as 
suggested by Dscho) sounds like a good idea.  And it seems that that 
process could produce a layer (i.e. API) that could be accessed by any 
scripting language that works with JSR-223.

(Note that MicroManager also uses BeanShell - 
http://valelab.ucsf.edu/~MM/MMwiki/index.php/Example_Beanshell_scripts)

-- Macro Recording

Our EventBus-based architecture enables straight-forward macro recording 
events.  A simple experiment/example is the 
imagej.ui.swing.plugins.SwingScriptRecorder.  It records plugin/module 
invocations and their parameter values, and then generates a chunk of 
Java-like code.

It remains to be decided how to handle
(this applies to undo/redo as well)

-- Code/Script Generation

The plan is to have a Code Generation API which will enable the 
generation of code/script in a variety of languages.
In imagej.ext.script there is a very simple CodeGenerator with a 
JavaCodeGenerator implementation.

-- Script Execution

A simple example of programmatic invocation of a plugins is in 
imagej.core.plugins.debug.InvokePluginTest which passes the parameters 
using varargs.

Using the JSR-223 Scripting engine, scripts can easily access Java 
classes.  The 'layer' I mentioned earlier would ease the script-writers 
effort by providing wrappers to commonly used classes/objects and services.

I'm interested to here other thoughts on these issues.

(See my links and references on scripting here: 
http://dev.imagejdev.org/gbh/arch/Scripting.html)



Grant B. Harris
---------------------------------------------------------
Scientific Informatics Analyst, Cellular Dynamics Program
Marine Biological Laboratory, Woods Hole, Mass. 02543
gharris at mbl.edu


On 9/7/2011 8:55 AM, Lee Kamentsky wrote:
> Hi all,
> What are the plans and timeline for bringing macros and scripting into 
> ImageJ 2.0? I'm looking for a way to programatically run a script from 
> CellProfiler. I'm guessing that, as a first pass, I create a legacy 
> plugin for some ImageJ 1.0 plugin that takes the script as its 
> argument - I could really use pointers on how to do this. Also, I'm 
> not sure where scripting is on the roadmap and what the planned 
> architecture is. I'd opt for a macro / scripting service. As a start, 
> that sort of thing could talk to the legacy code, but would end up 
> using the same interfaces to talk to the IJ2 code. I'm also guessing 
> that the IJ1 scripting engine might only need minor modifications to 
> reference displays instead of ImagePlus.
>
> --Lee
>
> _______________________________________________
> ImageJ-devel mailing list
> ImageJ-devel at imagejdev.org
> http://imagejdev.org/mailman/listinfo/imagej-devel




More information about the ImageJ-devel mailing list