Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limited IJM commands #14

Open
gosipe opened this issue May 27, 2017 · 1 comment
Open

Limited IJM commands #14

gosipe opened this issue May 27, 2017 · 1 comment

Comments

@gosipe
Copy link

gosipe commented May 27, 2017

Greetings, I am trying to run ImageJ/Fiji JavaScripts from within MATLAB. It seems that the transition to Java 8 is a rocky road. I was able to follow all the helpful instructions to get ImageJ running within MATLAB. But I'd prefer to have the custom JavaScript scripts or even stock Fiji scripts run without interfacing with the ImageJ GUI and that is where I am running into problems. When I list the available commands using IJM.help, I only see 4 commands. Does this mean that even built-in Fiji plugins are not able to be executed via ImageJ running in MATLAB?

Below is what the startup looks like. I get the reported "log4j" and "No such script engine: javascript." I suspect the latter is one of the reasons that I am having issues.

I am running Java 8, MATLAB2017a, and the latest Fiji installation. Any insight is very much appreciated.

ImageJ
java.lang.IllegalArgumentException: Cannot handle app name in ij.gui.YesNoCancelDialog's public (java.awt.Frame parent, java.lang.String title, java.lang.String msg)
at net.imagej.patcher.CodeHacker.replaceAppNameInCall(CodeHacker.java:446)
at net.imagej.patcher.LegacyExtensions.insertAppNameHooks(LegacyExtensions.java:419)
at net.imagej.patcher.LegacyExtensions.injectHooks(LegacyExtensions.java:291)
at net.imagej.patcher.LegacyInjector.inject(LegacyInjector.java:308)
at net.imagej.patcher.LegacyInjector.injectHooks(LegacyInjector.java:109)
at net.imagej.patcher.LegacyEnvironment.initialize(LegacyEnvironment.java:101)
at net.imagej.patcher.LegacyEnvironment.applyPatches(LegacyEnvironment.java:495)
at net.imagej.patcher.LegacyInjector.preinit(LegacyInjector.java:397)
at net.imagej.patcher.LegacyInjector.preinit(LegacyInjector.java:376)
at net.imagej.legacy.LegacyService.(LegacyService.java:134)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.scijava.service.ServiceHelper.createServiceRecursively(ServiceHelper.java:302)
at org.scijava.service.ServiceHelper.createExactService(ServiceHelper.java:269)
at org.scijava.service.ServiceHelper.loadService(ServiceHelper.java:231)
at org.scijava.service.ServiceHelper.createServiceRecursively(ServiceHelper.java:340)
at org.scijava.service.ServiceHelper.createExactService(ServiceHelper.java:269)
at org.scijava.service.ServiceHelper.loadService(ServiceHelper.java:231)
at org.scijava.service.ServiceHelper.loadService(ServiceHelper.java:194)
at org.scijava.service.ServiceHelper.loadServices(ServiceHelper.java:166)
at org.scijava.Context.(Context.java:278)
at org.scijava.Context.(Context.java:234)
at org.scijava.Context.(Context.java:174)
at org.scijava.Context.(Context.java:160)
at net.imagej.ImageJ.(ImageJ.java:77)
at net.imagej.Main.launch(Main.java:61)
at net.imagej.matlab.ImageJMATLAB.launch(ImageJMATLAB.java:151)
at net.imagej.matlab.ImageJMATLAB.start(ImageJMATLAB.java:105)
at net.imagej.matlab.ImageJMATLAB.start(ImageJMATLAB.java:92)
at net.imagej.matlab.ImageJMATLAB.start(ImageJMATLAB.java:81)
Caused by: javassist.CannotCompileException: No code replaced!
at net.imagej.patcher.CodeHacker$EagerExprEditor.instrument(CodeHacker.java:1280)
at net.imagej.patcher.CodeHacker.replaceAppNameInCall(CodeHacker.java:443)
... 32 more
[ERROR] Cannot create plugin: class='org.scijava.plugins.scripting.javascript.JavaScriptScriptLanguage', name='JavaScript', priority=0.0, enabled=true, pluginType=ScriptLanguage
java.lang.IllegalArgumentException: No such script engine: javascript
at org.scijava.script.AdaptedScriptLanguage.findFactory(AdaptedScriptLanguage.java:151)
at org.scijava.script.AdaptedScriptLanguage.(AdaptedScriptLanguage.java:73)
at org.scijava.plugins.scripting.javascript.JavaScriptScriptLanguage.(JavaScriptScriptLanguage.java:59)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.scijava.plugin.PluginInfo.createInstance(PluginInfo.java:304)
at org.scijava.plugin.DefaultPluginService.createInstance(DefaultPluginService.java:236)
at org.scijava.plugin.DefaultPluginService.createInstances(DefaultPluginService.java:225)
at org.scijava.plugin.DefaultPluginService.createInstancesOfType(DefaultPluginService.java:216)
at org.scijava.plugin.AbstractSingletonService.initInstances(AbstractSingletonService.java:92)
at org.scijava.plugin.AbstractSingletonService.getInstances(AbstractSingletonService.java:75)
at org.scijava.script.DefaultScriptService.initScriptLanguageIndex(DefaultScriptService.java:273)
at org.scijava.script.DefaultScriptService.scriptLanguageIndex(DefaultScriptService.java:238)
at org.scijava.script.DefaultScriptService.getIndex(DefaultScriptService.java:118)
at org.scijava.script.ScriptService.canHandleFile(ScriptService.java:314)
at org.scijava.script.ScriptFinder.createInfos(ScriptFinder.java:165)
at org.scijava.script.ScriptFinder.scanResources(ScriptFinder.java:133)
at org.scijava.script.ScriptFinder.findScripts(ScriptFinder.java:109)
at org.scijava.script.DefaultScriptService.initScripts(DefaultScriptService.java:314)
at org.scijava.script.DefaultScriptService.scripts(DefaultScriptService.java:256)
at org.scijava.script.DefaultScriptService.getScripts(DefaultScriptService.java:153)
at net.imagej.legacy.LegacyService.getScriptsAndNonLegacyCommands(LegacyService.java:628)
at net.imagej.legacy.IJ1Helper.addMenuItems(IJ1Helper.java:744)
at net.imagej.legacy.LegacyService.initialize(LegacyService.java:488)
at org.scijava.service.ServiceHelper.createServiceRecursively(ServiceHelper.java:353)
at org.scijava.service.ServiceHelper.createExactService(ServiceHelper.java:269)
at org.scijava.service.ServiceHelper.loadService(ServiceHelper.java:231)
at org.scijava.service.ServiceHelper.createServiceRecursively(ServiceHelper.java:340)
at org.scijava.service.ServiceHelper.createExactService(ServiceHelper.java:269)
at org.scijava.service.ServiceHelper.loadService(ServiceHelper.java:231)
at org.scijava.service.ServiceHelper.loadService(ServiceHelper.java:194)
at org.scijava.service.ServiceHelper.loadServices(ServiceHelper.java:166)
at org.scijava.Context.(Context.java:278)
at org.scijava.Context.(Context.java:234)
at org.scijava.Context.(Context.java:174)
at org.scijava.Context.(Context.java:160)
at net.imagej.ImageJ.(ImageJ.java:77)
at net.imagej.Main.launch(Main.java:61)
at net.imagej.matlab.ImageJMATLAB.launch(ImageJMATLAB.java:151)
at net.imagej.matlab.ImageJMATLAB.start(ImageJMATLAB.java:105)
at net.imagej.matlab.ImageJMATLAB.start(ImageJMATLAB.java:92)
at net.imagej.matlab.ImageJMATLAB.start(ImageJMATLAB.java:81)


ImageJ-MATLAB 0.7.2: MATLAB to ImageJ Interface

JVM> Version: 1.8.0_131
JVM> Total amount of memory: 178176 Kb
JVM> Amount of free memory: 53601 Kb

-- Welcome to ImageJ-MATLAB --
ImageJ-MATLAB consists of an extensible set of commands for passing information between ImageJ and MATLAB.
See the individual sections below for a list of available commands.

For more information and examples see:
http://imagej.net/MATLAB-Scripting

--- MATLAB Command Plugins ---

-- ImageJ MATLAB commands --

Usage: IJM.[command]
help - prints a brief description of available commands
getDataset - creates a MATLAB matrix from the active ImageJ image
getDatasetAs(name) - creates a MATLAB matrix from the active ImageJ image, and assigns it to the specified variable name
show(name) - takes the MATLAB matrix with the specified name and displays it as an image


Status> ImageJ is running.

log4j:WARN No appenders could be found for logger (loci.formats.ClassList).
log4j:WARN Please initialize the log4j system properly.

@ctrueden
Copy link
Member

java.lang.IllegalArgumentException: Cannot handle app name in ij.gui.YesNoCancelDialog's public (java.awt.Frame parent, java.lang.String title, java.lang.String msg)

That means your version of ImageJ 1.x is too new for the version of imagej-legacy being used. Sorry for these kinds of skew, but every time IJ1 changes in certain ways, we need to react to it on the ImageJ2 side. The good news is that this issue has been fixed for quite some time now; are you sure you are using a fully up-to-date Fiji with the Java-8 update site enabled?

When I list the available commands using IJM.help, I only see 4 commands. Does this mean that even built-in Fiji plugins are not able to be executed via ImageJ running in MATLAB?

We only implemented a handful of proof-of-concept commands for ImageJ-MATLAB so far. To fill in the gaps, you could enable the BIG-EPFL update site, which will install MIJ, which offers some additional features—just be aware it is not OSS licensed.

I wish I had time to implement more useful IJM commands, but unfortunately I have zero bandwidth this summer for that. Perhaps @hinerm (the ImageJ-MATLAB author + maintainer) can help. Or if not, and you are proficient in Java, then you can certainly implement your own IJM commands—they are just SciJava plugins after all. See this code for a starting point. Or if you don't know Java and/or don't have time, feel free to file additional issues here outlining the specific commands you would like to see exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants