trackmate-sc / TrackMate

TrackMate is your buddy for your everyday tracking.
https://imagej.net/plugins/trackmate
GNU General Public License v3.0
169 stars 76 forks source link

Cannot run jython scripts Example_Script1.py and Example_Script3.py #272

Closed simonguld closed 1 year ago

simonguld commented 1 year ago

Hi there,

I am trying to run Trackmate headlessly, and I am running into some trouble. To be specific, I am using Fiji Version 2.13.1 (newest version as of June 29 2023) ImageJ version v1.53t TrackMate 7.10.2 (this is the version I get by updating imageJ in the GUI)

I run the jython scripts as follows from the terminal:

jython -J-cp "C:\Users\Simon Andersen\Fiji.app\jars\*" script.py,

When running Example_Script1.py or Example_Script3.py (copied the Trackmate Github repository), I get the following error message:

settings.addAllAnalyzers()
        at org.scijava.service.ServiceHelper.createExactService(ServiceHelper.java:278)
        at org.scijava.service.ServiceHelper.loadService(ServiceHelper.java:229)
        at org.scijava.service.ServiceHelper.loadService(ServiceHelper.java:192)
        at org.scijava.service.ServiceHelper.loadServices(ServiceHelper.java:164)
        at org.scijava.Context.<init>(Context.java:285)
        at org.scijava.Context.<init>(Context.java:234)
        at org.scijava.Context.<init>(Context.java:130)
        at org.scijava.Context.<init>(Context.java:117)
        at org.scijava.Context.<init>(Context.java:106)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at java.lang.Class.newInstance(Class.java:442)
        at ij.IJ.runUserPlugIn(IJ.java:235)
        at ij.IJ.runPlugIn(IJ.java:203)
        at ij.IJ.runPlugIn(IJ.java:192)
        at fiji.plugin.trackmate.util.TMUtils.getContext(TMUtils.java:714)
        at fiji.plugin.trackmate.providers.AbstractProvider.registerModules(AbstractProvider.java:58)
        at fiji.plugin.trackmate.providers.AbstractProvider.<init>(AbstractProvider.java:45)
        at fiji.plugin.trackmate.providers.SpotAnalyzerProvider.<init>(SpotAnalyzerProvider.java:37)
        at fiji.plugin.trackmate.Settings.addAllAnalyzers(Settings.java:534)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Invalid service: net.imagej.legacy.LegacyService

Any help would be much appreciated!

Greetings from Denmark Simon

tinevez commented 1 year ago

Hello @simonguld It looks like a complicated issue related to obtaining a SciJava context. Can you confirm the scripts run: 1/ In the script editor of Fiji 2/ Using the Fiji command line to run script?

simonguld commented 1 year ago

Hi Tinevez,

1) It ran seamlessly in the script editor 2) It initally produced the same error as when running the jython script directly, but only when run headlessly. After removing the grapics parts of the script, like imp.show() and displayer, it works like a charm.

Thank you so much for your help! Simon

tinevez commented 1 year ago

Oh ok. So we can close this issue? Do you want to annotate the Wiki part dedicated to Fiji headless?

simonguld commented 1 year ago

Absolutely