Call plugins wth parameters the imagej2 way

Dear all,

This is a really basic (and stupid, most probably) question, but I have not found a direct answer so far. How do I call a command plugin from ImageJ2? So instead of the IJ1 style

IJ.run(imp,"command_plugin","parameters")

what do I use?. I believe it is the org.scijava.command, but what syntax does it use? (do I have to import the plugin like

from org.scijava.command import pluginname

BTW, I want to call it from jython.

Juan

It’s definitely not a stupid question. As some parts of ImageJ2 and SciJava are being actively developed, good documentation is sometimes lacking, and community help is welcome to bring wiki pages etc. up to date.


You can use the CommandService (that you get via script parameter) to call your Command:

#@ CommandService commands

module = commands.run("your.fully.qualified.Classname", true, "input1", "value1", "input2", "value2").get()

and then query module for its outputs if required.


If your Command has a menuPath defined, you can also run it from the menu while the Macro Recorder is active (e.g. in Javascript mode), and it will record the command that allows to call it in the legacy-compatible way:

IJ.run("My Command", "input1=this input2=that");
1 Like