I have been working on an ImageJ plugin in Eclipse (the plugin is based on a Matlab 3D denoting software) + simultaneously working on another copy in the Fiji script editor. The scripting is done in Jython. Up until now for my plugin, I have been using pretty basic ImageJ functionality and plugins that are included in the “imagej-1.47.jar” that I have added as a library to the project (they also come included with Fiji). The problem arises when dealing with plugins that are not already part of the “imagej-1.47.jar”.
For example, getting the jar file for the plugin Fractional Splines Wavelets and putting them in the plugin folder makes them appear in the Plugins menu of the Fiji gui on restarting. But when trying to import them from my plugin script in the Fiji editor by typing the command: Macro_Runner.run("Fractional Splines Wavelets" ,"Transform") Or Macro_Runner.runMacroFromJar("Fractional_Splines_Wavelets.jar" , "Transform") I get a message saying "TypeError: run(): self arg can't be coerced to ij.plugin.Macro_Runner". When trying to import the plugins from my eclipse Jython script, I have to add the two jar files as independent libraries to my project (and thus they can not be imported from the ij.plugin package). I was successful in importing the packages inside “Fractional_Splines_Wavelets.jar” by using the commands: import fractsplinewavelets_gui import imageware import fractsplinewavelets But I am unable to run the whole plugin like you can from the Fiji gui. I am hoping that someone would be able to shed some light on how to import and run these external plugins that are not an intrinsic part of the ImageJ plugins package from a script. Thanks Haider |
Hi Haider,
> I am hoping that someone would be able to shed some light on how to import > and run these external plugins that are not an intrinsic part of the ImageJ > plugins package from a script. There are two scenarios worth discussing: 1) Developing and running inside ImageJ 2) Developing outside of ImageJ (e.g., from Eclipse) When developing in the Script Editor, and running inside ImageJ, all the JAR libraries in jars and plugins are already available. Simply import what you need as described at http://imagej.net/Jython_Scripting#Importing_classes Or you can execute the plugins dynamically using IJ.run and/or IJ.runPlugIn. In the second case -- developing outside ImageJ -- it is up to you to add the necessary JAR libraries to your compile-time and/or runtime classpath. In Eclipse, you can add an external JAR dependency and point it at the relevant JAR file from your ImageJ installation. Then your plugin should be able to import classes defined in that JAR file. Or if you use Maven [1], just declare the relevant dependency in your pom.xml file, and Eclipse will pick it up. Running code from inside Eclipse is trickier though, due to ImageJ's plugin class loading mechanism. See http://fiji.sc/Developing_Fiji_in_Eclipse#Running_and_Debugging Regards, Curtis [1] http://imagej.net/Maven On Sun, Aug 10, 2014 at 1:46 AM, haider <[hidden email]> wrote: > I have been working on an ImageJ plugin in Eclipse (the plugin is based on > a > Matlab 3D denoting software) + simultaneously working on another copy in > the > Fiji script editor. The scripting is done in Jython. Up until now for my > plugin, I have been using pretty basic ImageJ functionality and plugins > that > are included in the “imagej-1.47.jar” that I have added as a library to the > project (they also come included with Fiji). The problem arises when > dealing > with plugins that are not already part of the “imagej-1.47.jar”. > > For example, getting the jar file for the plugin Fractional Splines > Wavelets > and putting them in the plugin folder makes them appear in the Plugins menu > of the Fiji gui on restarting. But when trying to import them from my > plugin > script in the Fiji editor by typing the command: > > Macro_Runner.run("Fractional Splines Wavelets" ,"Transform") > > Or > > Macro_Runner.runMacroFromJar("Fractional_Splines_Wavelets.jar" , > "Transform") > > I get a message saying "TypeError: run(): self arg can't be coerced to > ij.plugin.Macro_Runner". When trying to import the plugins from my eclipse > Jython script, I have to add the two jar files as independent libraries to > my project (and thus they can not be imported from the ij.plugin package). > I > was successful in importing the packages inside > “Fractional_Splines_Wavelets.jar” by using the commands: > > import fractsplinewavelets_gui > import imageware > import fractsplinewavelets > > But I am unable to run the whole plugin like you can from the Fiji gui. I > am > hoping that someone would be able to shed some light on how to import and > run these external plugins that are not an intrinsic part of the ImageJ > plugins package from a script. Thanks > > Haider > > > > -- > View this message in context: > http://imagej.1557.x6.nabble.com/Importing-ImageJ-plugins-from-an-ImageJ-script-tp5009079.html > Sent from the ImageJ mailing list archive at Nabble.com. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |