[ImageJ-devel] ImageJ2 scripting

Jan Eglinger jan.eglinger at gmail.com
Mon Apr 27 08:58:18 CDT 2015


Dear all,

*** TL;DR:
How do I proceed to get multiple input Datasets as ImageJ2 parameters 
from open images in Fiji?
***

I was recently exploring ImageJ2 scripting in Fiji and found the 
OpsThresholdIJ1Analyze template [1] in the script editor very helpful.

When trying to get more than one @net.imagej.Dataset input parameter 
however, I noticed some inconsistencies.
Let me try to illustrate with the two following scripts:

     # @DisplayService display
     # @OpService ops
     # @net.imagej.Dataset inputData1

     from net.imglib2.meta import ImgPlus

     display.createDisplay("my1", ImgPlus(inputData1))


The above script re-displays the current image as expected (I tried with 
the Blobs sample image open, which will be re-displayed with a 
non-inverted LUT.)

When I ask for two input datasets (right after a fresh start of Fiji 
with only the Blobs sample image open):

     # @DisplayService display
     # @OpService ops
     # @net.imagej.Dataset inputData1
     # @net.imagej.Dataset inputData2

     from net.imglib2.meta import ImgPlus

     display.createDisplay("my1", ImgPlus(inputData1))
     display.createDisplay("my2", ImgPlus(inputData2))

an error message is displayed: "A Dataset is required but none exist."
The same error message is displayed when I open a second image in Fiji 
before running the script.

Now, when I run script #2 after script #1 was run at least once, I get a 
dialog with two choices "InputData1" and "InputData2", both choice 
fields containing "blobs.gif" and a number of "Untitled" entries (where 
can this title be set, by the way?).

I guess that a choice is only displayed if there are ImageJ2 datasets 
(i.e. wrapped ImagePlus) already available. The single input case seems 
to be special-cased as it auto-wraps the currently open image.

So how do I proceed to get more than one input in ImageJ2 scripting from 
open (ImageJ1-)images?

Thanks for your advice,
Regards,
Jan


[1]: 
https://github.com/imagej/imagej-legacy/blob/master/src/main/resources/script_templates/Python/OpsThresholdIJ1Analyze.py



More information about the ImageJ-devel mailing list