[ImageJ-devel] Scripting examples

Curtis Rueden ctrueden at wisc.edu
Tue Feb 18 13:26:43 CST 2014


Hi Brian,

I am out of the office today, and will reply in more detail later, but just
wanted to quickly add: the example Johannes wrote should work with the
current master branch as well as the recent 2.0.0-beta-7.7 release.
Specifically, it will work if you "Run Script" since the parameter parsing
mechanism etc. is all already in place. It just doesn't work from the
Script Editor yet since that tool needs some TLC still. As Johannes says, I
am still actively hacking on scripting support.

Also note that you can inject a Context parameter then make a new ImageJ
gateway object wrapping it to easily access services the same way the
tutorials do. (I forget whether ImageJ gateways are injectable ATM but if
not, they will be.)

Anyway, please let us know if you are unable to run such scripts.

Regards,
Curtis
On Feb 18, 2014 12:41 PM, "Johannes Schindelin" <Johannes.Schindelin at gmx.de>
wrote:

> Hi Brian,
>
> On Tue, 18 Feb 2014, Brian Northan wrote:
>
> > Now I am trying to understand how one should be accessing ImageJ2
> > functionality from the scripts.  In ImageJ1 I use the static functions in
> > the IJ class, IJ.run, IJ.openImage etc.
>
> Yeah, in IJ2 you have to use a context. The static functions of ImageJ 1.x
> do not allow you to insulate separate processes from each other. That
> leads to surprising results, e.g. when you try to put more than one
> ImageJ 1.x applet into the same web page: it simply won't work, ever.
>
> > So far in ImageJ2 I have been writing java applications that start by
> > instantiating an ImageJ app and then use that to access services and run
> > commands. Basically following the tutorials.
> >
> > So how are things intended to work in a script??  Is there a simpler api
> > somewhere like the IJ API??  Or does one still need to use the service
> APIs
> > in a script??
>
> This is a work in progress right now, under heavy construction.
> Eventually, something like this will work:
>
> -- snip --
> # @StatusService status
> # @OUTPUT String greeting
>
> status.showStatus(1, 2, "In progress...")
> status.warn("This is a gentle warning")
> status.showStatus(2, 2)
>
> greeting = "Hello, world!"
> -- snap --
>
> In other words, your input and output parameters will be specified using a
> syntax similar to ImageJ2 commands' at the top of the script.
>
> Ciao,
> Johannes
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://imagej.net/pipermail/imagej-devel/attachments/20140218/89375ba6/attachment.html>


More information about the ImageJ-devel mailing list