I am trying to run the Mosaic particle tracker in Fiji/ImageJ from the command line. Ultimately, my goal is to use the Mosaic particle tracking plugin on a cluster. I was hoping you could help me fix the issue of a
java.lang.VerifyError: Bad type on operand stack generated by
When I call a file “particle-tracker.py”
#@ String path import os from ij import IJ path = str(path) files =  counta = 0 for file in os.listdir(path): if file.endswith('tif'): files.append(os.path.join(path, file)) counta+=1 files = sorted(files) if len(files) <1: raise Exception("No files matching the criteria in "+path) counti = 1 for file in files: print("("+str(counti)+"/"+str(counta)+") Processing: "+file) imp = IJ.openImage(file) IJ.run(imp, "Particle Tracker 2D/3D", "radius=3 cutoff=0.001 per/abs=0.500 link=2 displacement=10 dynamics=Brownian")
with this command (on MacOS) on a folder of tif files:
/Applications/Fiji.app/Contents/MacOS/ImageJ-macosx --ij2 --console --run /Users/rene/particle_tracker.py 'path="/Users/rene/TIFFs"'
Fiji opens, the Fiji status bar updates on frames it processes, and the terminal also spits out information on progress. The plugin successfully outputs particle tracking information as files in the “path” directory. Besides the Fiji program window, no other windows are displayed. I kill the program with ctrl-C.
However, as soon as I insert the
--headless option in the command, the program throws the above mentioned exception. I have seen this described as an issue here:
My unsuccessful attempts to fix this: I opened the mosaic jar file in Eclipse (and in JByteMod) and modified individual or all instances of NonBlockingGenericDialog to GenericDialog (i.e. I butchered other people’s code, without knowing anything about it or about the programming language). It sometimes throws other exceptions (java.awt.HeadlessException) and did not work.
I would really appreciate your help! and/or the answer to a few questions:
- The NonBlockingGenericDialog class seems to be called when a preview window is created. With or w/o headless mode, there is no actual preview window created, so why does one work, the other doesn’t?
- Would changing the plugin code require major rewriting, i.e. do the two classes NonBlockingGenericDialog and Generic Dialog have different attributes, i.e. why did my attempt fail?
- If there is no way I can change the plugin, and no fix to the referenced issue for headless mode in ImageJ in the foreseeable future, would you advise to implement something like a mock display via a program called xvfb?