<div dir="ltr">Hi Adrian,<div><br></div><div><div>> <a href="https://gitlab.com/pendant-drop/pendant-drop.git">https://gitlab.com/pendant-drop/pendant-drop.git</a></div><div>> (checkout branch overlay_issue (commit 2887f8ec))</div><div>></div><div>> This is a MVCE that has parameters</div></div><div><br></div><div>Thanks, I was able to replicate the problems using your code.</div><div><br></div><div>I tried to reproduce using a script with various parameter combinations mirroring yours, but was initially unsuccessful. It seems the problem is a little subtle.</div><div><br></div><div>It is likely related to the syncing of IJ1 and IJ2 data structures. So I'm not going to worry about further for the time being—that logic will be revised in the future anyway.</div><div><br></div><div><div>> More than a tutorial I missed some explanations on the technical</div><div>> design of, and the interplay between, the different parts that now</div><div>> make up ImageJ2.</div></div><div><br></div><div>The best I have to offer right now is:</div><div>* <a href="http://imagej.net/Architecture">http://imagej.net/Architecture</a></div><div>* <a href="http://imagej.net/Development">http://imagej.net/Development</a></div><div><br></div><div><div>> I just opened a sheet in an editor on which I will jot down notes as I</div><div>> go ahead with my plugin, about problems, discoveries and things I</div><div>> suddenly understand. Maybe this can be a starting point or</div><div>> contribution for a transition guide.</div></div><div><br></div><div>That would be fantastic! It is physically impossible for Mark and me to write the entire wiki...</div><div><br></div><div>Regards,</div><div>Curtis</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 27, 2015 at 2:18 PM, Adrian Daerr <span dir="ltr"><<a href="mailto:adrian.daerr@univ-paris-diderot.fr" target="_blank">adrian.daerr@univ-paris-diderot.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello Curtis,<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
@Parameter(persist = false) private RectangleOverlay roi;<br>
<br>
which appears to be populated only after the initializer is called<br>
(its value is null in the initializer and valid in the run() method).<br>
</blockquote>
<br></span>
Hmm, that should not be the case. [..]<span class=""><br>
The issue might be typing-related: try using Overlay instead of<br>
RectangleOverlay and see if that makes a difference.<br>
<br></span><span class="">
Alternately: can you post an MVCE [3, 4] illustrating the issue?<br>
</span></blockquote>
<br>
<a href="https://gitlab.com/pendant-drop/pendant-drop.git" rel="noreferrer" target="_blank">https://gitlab.com/pendant-drop/pendant-drop.git</a><br>
(checkout branch overlay_issue (commit 2887f8ec))<br>
<br>
This is a MVCE that has parameters<br>
<br>
@Parameter<br>
private ImagePlus imp;<br>
<br>
@Parameter(persist = false)<br>
private RectangleOverlay region;<br>
<br>
@Parameter(persist = false)<br>
private Overlay overlay;<br>
<br>
It compiles and executes with<br>
<br>
mvn -o package && fiji --class-path \<br>
target/pendant_drop-2.0.0-SNAPSHOT.jar Goutte_pendante.class<br>
<br>
and logs the following to the console:<br>
<br>
[INFO] imp parameter in initializer(): non-null<br>
[INFO] region parameter in initializer(): null<br>
[INFO] overlay parameter in initializer(): null<br>
[INFO] imp parameter in preview(): non-null<br>
[INFO] region parameter in preview(): non-null<br>
[INFO] overlay parameter in preview(): non-null<br>
[INFO] imp parameter in run(): non-null<br>
[INFO] region parameter in run(): non-null<br>
[INFO] overlay parameter in run(): non-null<br>
[ERROR] Module threw exception<br>
java.lang.NullPointerException<br>
at ij.plugin.frame.Recorder.addQuotes(Recorder.java:612)<br>
...<br>
<br>
Note 1) Since I switched to the OverlayService.getSelectionBounds()<br>
solution you suggested in another thread, do not bother looking into<br>
this for me. I just submit this MVCE in case the issue is more<br>
important than I suspect.<br>
<br>
Note 2) It appears (RectangleOverlay).toString() returns null in any<br>
case.<br>
<br>
Note 3) Overlay and RectangleOverlay have the same issue with respect<br>
to initialization, but the reason I used RectangleOverlay is that I<br>
did not see how to get the bounds of an Overlay.<span class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I am sorry—the tutorials need to be improved. What sort of tutorial do you think would aid your understanding here?<br>
</blockquote>
<br></span>
More than a tutorial I missed some explanations on the technical<br>
design of, and the interplay between, the different parts that now<br>
make up ImageJ2. Instead of one single place to find the API and<br>
Source of ij.*, things are split up into packages (org.scijava.*,<br>
net.imagej.*, imglib) and it takes a bit to figure out how things are<br>
organized and why this division of labour makes sense. So deciding<br>
e.g. where to look for ROI/Overlay related stuff was not easy<br>
(net.imagej? imglib? both seem to have bits). For someone used to the<br>
often static, in any case ultra specific ImageJ1 API, understanding<br>
what a context is, what Services are good for, how menus, views, even<br>
whole GUIs are flexibly handled, how roughly plugins are recognized,<br>
how and when annotations are parsed (what's an annotation anyway from<br>
a Java perspective ?) and how they are instantiated and executed, well<br>
all this is quite a lot of new stuff. Not to speak about understanding<br>
how the new Dataset/ImageDisplay/Views classes replacing ImageJ1's<br>
ImagePlus/ImageWindow/.. work together, and why some of them are<br>
already deprecated ;-)<br>
<br>
Now this very design still seems to be changing, so I understand<br>
writing up something might be a bit early. Besides, it's a good thing<br>
not to pin it down to early, and producing documentation wikis that<br>
may soon prove outdated can be not only a waste of time, but even<br>
prove quite perturbing later when they contradict reality. Even if I'd<br>
like to see some gently (but technically oriented) introduction to the<br>
class zoo and ecosystem of ImageJ2, and also a guide to plugin<br>
programming specifically for the ImageJ1 veteran (with, for now, your<br>
recommendation to just take advantage of the parameter harvesting<br>
features but to stick to IJ1 data structures), I think this is<br>
probably too early to do. But I just opened a sheet in an editor on<br>
which I will jot down notes as I go ahead with my plugin, about<br>
problems, discoveries and things I suddenly understand. Maybe this can<br>
be a starting point or contribution for a transition guide.<br>
<br>
If I do have ideas about specific programming examples for the<br>
imagej-tutorials, I'll voice them of course.<br>
<br>
In any case your reactivity on this list is simply invaluable, thanks<br>
a lot for adding communication efforts to your programming mission.<br>
<br>
best regards,<br>
Adrian<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
<br>
On Mon, 24 Aug 2015 10:25:59 -0500<br>
Curtis Rueden <<a href="mailto:ctrueden@wisc.edu" target="_blank">ctrueden@wisc.edu</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Adrian,<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Thanks for the suggestion, which almost does the job, except that the<br>
initialization also depends on a parameter<br>
<br>
@Parameter(persist = false) private RectangleOverlay roi;<br>
<br>
which appears to be populated only after the initializer is called<br>
(its value is null in the initializer and valid in the run() method).<br>
</blockquote>
<br>
Hmm, that should not be the case. Commands that include a single overlay<br>
parameter should automatically draw from the active image's active overlay,<br>
when possible [1]. This happens _before_ the initializers are called [2]<br>
(because Priority.VERY_HIGH_PRIORITY > Priority.HIGH_PRIORITY).<br>
<br>
The issue might be typing-related: try using Overlay instead of<br>
RectangleOverlay and see if that makes a difference. If so, it is probably<br>
a limitation of the ActiveOverlayPreprocessor [1]; patches welcome.<br>
<br>
Alternately: can you post an MVCE [3, 4] illustrating the issue?<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
do I have to write a Preprocessor of some sorts<br>
</blockquote>
<br>
This is certainly possible to do, but I would hope not necessary.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
can the initializer 'manually' call the code which normally harvest<br>
the RectangleOverlay parameter later on ?<br>
</blockquote>
<br>
Sure, you can always code in whatever logic you want to the plugin<br>
initializer method. But again, hopefully not necessary in this case.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
even after some reading of the tutorials and the scijava source code<br>
around org.scijava.command.CommandInfo my understanding of how the<br>
plugin initialisation works is still poor.<br>
</blockquote>
<br>
I am sorry—the tutorials need to be improved. What sort of tutorial do you<br>
think would aid your understanding here? The "execute-commands" and<br>
"custom-preprocessor-plugin" tutorials are probably touch on these topics<br>
most closely, although neither provides a real overview of the<br>
pre-/post-processing chain in conjunction with module execution.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Would it make sense to distinguish (by an annotation ?) parameters<br>
that are to be initialized from the context (i.e. services, active<br>
image, roi etc), and whose lack should be immediately fatal to the<br>
plugin (no UI harvesting, and in exchange can be assumed final for the<br>
rest of the command execution), from parameters that, if they cannot<br>
be populated from already available data, should be harvested through<br>
a dialog (and may change several times) ?<br>
</blockquote>
<br>
Potentially, yes. Feel free to comment on the issue on GitHub!<br>
<br>
Regards,<br>
Curtis<br>
<br>
[1]<br>
<a href="https://github.com/imagej/imagej-common/blob/imagej-common-0.15.1/src/main/java/net/imagej/display/process/ActiveOverlayPreprocessor.java#L57" rel="noreferrer" target="_blank">https://github.com/imagej/imagej-common/blob/imagej-common-0.15.1/src/main/java/net/imagej/display/process/ActiveOverlayPreprocessor.java#L57</a><br>
<br>
[2]<br>
<a href="https://github.com/scijava/scijava-common/blob/scijava-common-2.44.2/src/main/java/org/scijava/module/process/InitPreprocessor.java#L49" rel="noreferrer" target="_blank">https://github.com/scijava/scijava-common/blob/scijava-common-2.44.2/src/main/java/org/scijava/module/process/InitPreprocessor.java#L49</a><br>
<br>
[3] <a href="http://imagej.net/Bug_reporting_best_practices" rel="noreferrer" target="_blank">http://imagej.net/Bug_reporting_best_practices</a><br>
<br>
[4] <a href="http://stackoverflow.com/help/mcve" rel="noreferrer" target="_blank">http://stackoverflow.com/help/mcve</a><br>
<br>
<br>
On Mon, Aug 24, 2015 at 9:07 AM, Adrian Daerr <<br>
<a href="mailto:adrian.daerr@univ-paris-diderot.fr" target="_blank">adrian.daerr@univ-paris-diderot.fr</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Curtis,<br>
<br>
I have parameters a, b, c whose initialisation depend on a common<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
calculation (depending on the image gotten through a previous<br>
@Parameter ImagePlus imp): can I do this calculation in the<br>
initialiser for the first parameter a, and then in the initialisers of b<br>
and c rely on the fact that the calculation was already done ?<br>
<br>
</blockquote>
<br>
Perhaps simplest at the moment would be to give your command a global<br>
initializer -- i.e., set the initializer method in the<br>
@Plugin annotation itself, rather than on specific parameters.<br>
The ImagePlus will be populated by a preprocessor _before_ the<br>
initialize method is called, so when your global initializer gets<br>
called you will already have access to the ImagePlus.<br>
<br>
</blockquote>
<br>
Thanks for the suggestion, which almost does the job, except that the<br>
initialization also depends on a parameter<br>
<br>
@Parameter(persist = false) private RectangleOverlay roi;<br>
<br>
which appears to be populated only after the initializer is called (its<br>
value is null in the initializer and valid in the run() method).<br>
<br>
I am not sure how to solve this: do I have to write a Preprocessor of some<br>
sorts, or can the initializer 'manually' call the code which normally<br>
harvest the RectangleOverlay parameter later on ? Somehow the fact that<br>
ImagePlus is populated by a Preprocessor but RectangleOverlay isn't, seems<br>
linked to issues that I mentionned in another post[1], but even after some<br>
reading of the tutorials and the scijava source code around<br>
org.scijava.command.CommandInfo my understanding of how the plugin<br>
initialisation works is still poor.<br>
<br>
[1]<br>
(e.g. that the Overlay appears in the harvesting dialog, or that an<br>
Exception is thrown because of the overlay after command execution)<br>
<br>
<a href="http://imagej-devel.54429.x6.nabble.com/Masking-Parameter-from-GUI-harvesting-td1098.html" rel="noreferrer" target="_blank">http://imagej-devel.54429.x6.nabble.com/Masking-Parameter-from-GUI-harvesting-td1098.html</a><br>
<br>
But again, scijava/scijava-common#181 is very relevant here.<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
</blockquote>
<br>
Would it make sense to distinguish (by an annotation ?) parameters that<br>
are to be initialized from the context (i.e. services, active image, roi<br>
etc), and whose lack should be immediately fatal to the plugin (no UI<br>
harvesting, and in exchange can be assumed final for the rest of the<br>
command execution), from parameters that, if they cannot be populated from<br>
already available data, should be harvested through a dialog (and may<br>
change several times) ?<br>
<br>
cheers,<br>
Adrian<br>
<br>
</blockquote></blockquote>
<br></div></div><span class="HOEnZb"><font color="#888888">
-- <br>
<a href="http://www.msc.univ-paris-diderot.fr/~daerr/" rel="noreferrer" target="_blank">http://www.msc.univ-paris-diderot.fr/~daerr/</a><br>
</font></span></blockquote></div><br></div>