Trackmate recordable macro error

Dear @tinevez ,

I use your “Trackmate” plugin for tracking blood cell and because the parameter I choose always same, I plan to record some macro by following the scripting example for “Making TrackMate macro recordable with a 64-line script” in Scripting TrackMate - ImageJ . However after setting the parameter and press “OK”, I always get error that showed:

SyntaxError: mismatched input ‘//’ expecting EOF

at org.python.core.ParserFacade.fixParseError(ParserFacade.java:95)
at org.python.core.ParserFacade.parseExpressionOrModule(ParserFacade.java:136)
at org.python.util.PythonInterpreter.compile(PythonInterpreter.java:321)
at org.python.util.PythonInterpreter.compile(PythonInterpreter.java:317)
at org.python.jsr223.PyScriptEngine.compileScript(PyScriptEngine.java:90)
at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:31)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
at org.scijava.script.ScriptModule.run(ScriptModule.java:157)
at org.scijava.module.ModuleRunner.run(ModuleRunner.java:165)
at org.scijava.module.ModuleRunner.call(ModuleRunner.java:124)
at org.scijava.module.ModuleRunner.call(ModuleRunner.java:63)
at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:225)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

I run the plugin on imageJ v.1.52v . For testing, I tried to copy paste the script you provide without changing the detector etc and I get these error. I am not good at machine language so I need your advice for this. Thank you.

Hello @Ferry_Saputra

I suspect you did not select the Groovy language in the Languages menu of the script editor:
image

It this the problem?

Dear @tinevez

Thank you for the reply.
This kinda solved the problem.

“kinda”? :slight_smile:

Can we 100% solve it? Are there still things that do not work?

The script already run perfectly right now, but sadly I still failed to integrate the script into the macro I made as I only able to use “recording macro” to make macro. When I try to run the macro with the script, it said:

and just stop in the black script editor window.
This is the macro I recorded to run the script:

run("Script...");
open("C:/Users/MAGNA/Desktop/New_.groovy");
run("script:C:\Users\MAGNA\Desktop\new_.groovy", "outputfolder=C:\\Users\\MAGNA\\Desktop filename=test.xml radius=50.0 threshold=0.1 framegap=2 linkingmax=50.0 closingmax=50.0");

Furthermore, I also want to change the result to export to all statistics but I believe it’s already out of this threat topic.

I can reproduce this error, but do not know how to fix it.
You know, for very serious problem it is best to summon Jan. He knows many many things :slight_smile:

@imagejan we summon thee. Come, fill the hearts of your faithful.

We have a problem calling the Groovy script you brewed in a macro. Do you have any clues for us?

2 Likes

The error message hints at it already; on Windows, you’ll have to either:

  • escape your backslashes (\) by adding a second backslash (\\):
    run("script:C:\\Users\\MAGNA\\Desktop\\new_.groovy", ...
    

or

  • use forward slashes:
    run("script:C:/Users/MAGNA/Desktop/new_.groovy", ...
    

Did it get recorded like this, with only single backslashes? If so, then this is a bug with the command recording.


Edit:
I’m not sure if calling the script with the script:... identifier would actually work (or is supposed to work…). I’d recommend saving your script into /Fiji.app/scripts/MyMenu/My_TrackMate_Runner.groovy and restart Fiji, then you can call it from the menu, and it gets recorded as:

run("My TrackMate Runner", "outputfolder=C:\\Users\\MAGNA\\Desktop filename=test.xml radius=50.0 threshold=0.1 framegap=2 linkingmax=50.0 closingmax=50.0");
1 Like

@imagejan I just copy paste it directly from the recorded macro without any change.
Yup it still does not working :slightly_smiling_face: :slightly_smiling_face: :slightly_smiling_face: . This time the error was :

I tried your idea to copy the script to imageJ->Script->MyMenu->My_TrackMate_Runner.groovy and this time it show:

Although in my scripts folder there was no MyMenu folder, i tried to create new folder and rename it to “MyMenu”. Will that be the problem?

Thank you for the recommendation. Really appreciate your reply :smiley: :smiley:.

The folder needs to be the /scripts/ folder (not Scripts, not script, not Script) in your Fiji.app/ installation, and the name(s) of the subfolder(s) will correspond to the menus where you’ll find your command (e.g. Plugins for the Plugins menu, or MyMenu if you want to create a new top level menu with that name).
If your command doesn’t show up in the menu after restarting Fiji, there’s something wrong with the location where you saved the script.
If it does show up in the menu, it will also be recorded as I described above with the correct run(...) command.

After give my computer a good night rest, suddenly the “MyMenu” appears in the ImageJ toolbar and now I can run the macro perfectly without any issue :joy: :joy: .

Thank you @tinevez & @imagejan really appreciate your help.

1 Like