imagej-ops icon indicating copy to clipboard operation
imagej-ops copied to clipboard

Support @Parameter annotation for Ops (in scripts)

Open stelfrich opened this issue 9 years ago • 5 comments

It would be great to be able to use ops with the @Parameter annotation and as script parameter, as pointed out in a forum thread.

Something like:

// @Threshold(label="What Threshold to use?") threshold
// @Img input
// @OUTPUT Img output
output = threshold.compute(img)

I guess this requires establishing a connection between the requested op and input to enable matching?

stelfrich avatar Dec 01 '16 06:12 stelfrich

~~I'm not sure if I like this idea. Will we introduce special annotations for each and every type of input parameter? I think the idea with such plugins as Threshold was that there is something like a Threshold class which can be annotated. SciJava detects, that this actually a plugin of many types and offers you a drop-down to select the threshold. Basically the same idea, just on class or plugin level. Correct me if I'm wrong @ctrueden.~~~

I didn't recognize that we are in the script world.

dietzc avatar Dec 01 '16 09:12 dietzc

Will we introduce special annotations for each and every type of input parameter?

@Threshold is an annotation just like @Img, isn't it? In the example, I am trying to request something like Ops.Threshold.*.

I think the idea with such plugins as Threshold

About which plugin(s) are you talking? The deprecated ThresholdMethod et al?

stelfrich avatar Dec 01 '16 09:12 stelfrich

Yes, I meant something like ThresholdMethod et al. If we introduce them, I think there are mechanisms in SciJava that @Threshold in the script world would deliver the plugins as a drop-down. I think the pattern is https://github.com/scijava/scijava-common/blob/master/src/main/java/org/scijava/plugin/SingletonService.java.

dietzc avatar Dec 01 '16 09:12 dietzc

I think there are mechanisms in SciJava that @Threshold in the script world would deliver the plugins as a drop-down.

That's right. The following Groovy script produces the mentioned drop-down:

// @net.imagej.threshold.ThresholdMethod threshold

I was just thinking out loud about adding something like that on the Ops level (since ThresholdMethod el al are deprecated) as well. AFAICT, implementations of ThresholdMethod are Plugins themselves, that's why Scijava picks them up.

stelfrich avatar Dec 01 '16 09:12 stelfrich

I definitely have thoughts, opinions and plans surrounding this, and have for a long time. I will try to elaborate in this here issue when I get a chance, but there will be some delay.

ctrueden avatar Dec 02 '16 02:12 ctrueden