<div dir="ltr">Hi Jan,<div><br></div><div>Here is another version of the script, which avoids wrapping each Dataset in another ImgPlus (which the framework would then wrap into yet another Dataset....):</div><div><br></div><div><span class="im" style="font-size:12.8000001907349px"> # @DisplayService display<br> # @OpService ops<br> # @net.imagej.Dataset inputData1<br> # @net.imagej.Dataset inputData2<br><br> inputData1.setName("my1")</span></div><div><span class="im" style="font-size:12.8000001907349px"> inputData2.setName("my2")<br></span><span style="font-size:12.8000001907349px"> display.createDisplay(inputData1</span><span style="font-size:12.8000001907349px">)</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px"> display.createDisplay(inputData2</span><span style="font-size:12.8000001907349px">)</span><br></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">But note that you also don't need to explicitly call createDisplay. Any output parameters of your script will automatically have displays created for them. E.g.:</span></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px"> # @OUTPUT net.imagej.Dataset outputData</span></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">Will be shown at the conclusion of the script.</span></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">Apologies for the appalling lack of documentation -- it would be great to flesh out the wiki docs about all this.</span></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">HTH,</span></div><div><span style="font-size:12.8000001907349px">Curtis</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 27, 2015 at 1:23 PM, Mark Hiner <span dir="ltr"><<a href="mailto:hiner@wisc.edu" target="_blank">hiner@wisc.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div>Hi Jan,<span class=""><br><br>>an error message is displayed: "A Dataset is required but none exist."<br><br></span></div>This was due to limitations with the input preprocessor presenting the list of datasets. Since ImagePluses aren't explicitly tracked by the IJ2 framework, having an ImagePlus recognized as a Dataset requires some extra layers. We had covered the single input case (which is why your first script worked) but not the general multi-input case. There is an <a href="https://github.com/imagej/imagej-legacy/issues/106" target="_blank">issue tracking the multi-input</a> case, which I resolved today. So this should work as intended in our next release - and thank you for the motivation to wrap this up!<br><br></div>You can also manually enable ImagePlus <> Dataset synchronization to ensure ImagePluses always have a corresponding Dataset: <a href="http://imagej.net/Compatibility#Translation_of_data_structures" target="_blank">http://imagej.net/Compatibility#Translation_of_data_structures</a><span class=""><br><br>>(where can this title be set, by the way?)<br><br></span></div>For the multiple choice input selection, the labels are based on the name of the input type. Since the input type is Dataset, the Dataset name is used (which delegates to the wrapped ImgPlus). In your code you are applying labels to the Display, but not the underlying dataset - if you name the ImgPlus, or explicitly create a Dataset and set its name, that name will propagate up to the input chooser (and the Display). As a side note, you should use the net.imagej.ImgPlus instead of the net.imglib2.meta.<br><br></div>An updated script would be:<span class=""><br><br><br> # @DisplayService display<br> # @OpService ops<br> # @net.imagej.Dataset inputData1<br> # @net.imagej.Dataset inputData2<br><br></span> from net.imagej import ImgPlus<br><br> display.createDisplay(ImgPlus(inputData1, "my1"))<br> display.createDisplay(ImgPlus(inputData2, "my2"))<br><div><br></div><div>Hope that helps. Let me know if you have any other questions.<br><br></div><div>Best,<br></div><div>Mark<br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 27, 2015 at 8:58 AM, Jan Eglinger <span dir="ltr"><<a href="mailto:jan.eglinger@gmail.com" target="_blank">jan.eglinger@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear all,<br>
<br>
*** TL;DR:<br>
How do I proceed to get multiple input Datasets as ImageJ2 parameters from open images in Fiji?<br>
***<br>
<br>
I was recently exploring ImageJ2 scripting in Fiji and found the OpsThresholdIJ1Analyze template [1] in the script editor very helpful.<br>
<br>
When trying to get more than one @net.imagej.Dataset input parameter however, I noticed some inconsistencies.<br>
Let me try to illustrate with the two following scripts:<br>
<br>
# @DisplayService display<br>
# @OpService ops<br>
# @net.imagej.Dataset inputData1<br>
<br>
from net.imglib2.meta import ImgPlus<br>
<br>
display.createDisplay("my1", ImgPlus(inputData1))<br>
<br>
<br>
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.)<br>
<br>
When I ask for two input datasets (right after a fresh start of Fiji with only the Blobs sample image open):<br>
<br>
# @DisplayService display<br>
# @OpService ops<br>
# @net.imagej.Dataset inputData1<br>
# @net.imagej.Dataset inputData2<br>
<br>
from net.imglib2.meta import ImgPlus<br>
<br>
display.createDisplay("my1", ImgPlus(inputData1))<br>
display.createDisplay("my2", ImgPlus(inputData2))<br>
<br>
an error message is displayed: "A Dataset is required but none exist."<br>
The same error message is displayed when I open a second image in Fiji before running the script.<br>
<br>
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?).<br>
<br>
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.<br>
<br>
So how do I proceed to get more than one input in ImageJ2 scripting from open (ImageJ1-)images?<br>
<br>
Thanks for your advice,<br>
Regards,<br>
Jan<br>
<br>
<br>
[1]: <a href="https://github.com/imagej/imagej-legacy/blob/master/src/main/resources/script_templates/Python/OpsThresholdIJ1Analyze.py" target="_blank">https://github.com/imagej/imagej-legacy/blob/master/src/main/resources/script_templates/Python/OpsThresholdIJ1Analyze.py</a><br>
<br>
_______________________________________________<br>
ImageJ-devel mailing list<br>
<a href="mailto:ImageJ-devel@imagej.net" target="_blank">ImageJ-devel@imagej.net</a><br>
<a href="http://imagej.net/mailman/listinfo/imagej-devel" target="_blank">http://imagej.net/mailman/listinfo/imagej-devel</a><br>
</blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
ImageJ-devel mailing list<br>
<a href="mailto:ImageJ-devel@imagej.net">ImageJ-devel@imagej.net</a><br>
<a href="http://imagej.net/mailman/listinfo/imagej-devel" target="_blank">http://imagej.net/mailman/listinfo/imagej-devel</a><br>
<br></blockquote></div><br></div>