Cannot instantiate headless - Multiple Macros Simultaneously

Hello,

I created a macro that works well in Fiji pulling in a directory of images and converting/compressing into AVI files. I have many files in the directory and it only uses one logical core on my PC at a time. To decrease the long processing time I am trying to run multiple instances of ImageJ at once and having multiple macros deal with different subsets of files in the directory separately. If I open five windows of Fiji and manually click run the macro will work fine and utilize most of CPU (I cut my analysis time on a sample subset by 5x as a proof of concept). However, when I try to run multiple macros at once in headless mode I get instance errors. Here is what I did. I am assuming I am not calling the macro correctly for headless mode. Please advise. Thank you in advance for any input or advice.

Kevin


I created a windows batch script to start the macro in headless mode and it works well with just once instance:


start C:\Fiji.app\ImageJ-win64.exe --console --headless -macro C:\Users\kmurph59\Desktop\ConvertMacro\Thread1.ijm


When I add four more lines to run the four other macros (that have different files from the main directory) it comes up with the following error - see below for batch file here:

start C:\Fiji.app\ImageJ-win64.exe --console --headless -macro C:\Users\kmurph59\Desktop\ConvertMacro\Thread1.ijm

start C:\Fiji.app\ImageJ-win64.exe --console --headless -macro C:\Users\kmurph59\Desktop\ConvertMacro\Thread2.ijm

start C:\Fiji.app\ImageJ-win64.exe --console --headless -macro C:\Users\kmurph59\Desktop\ConvertMacro\Thread3.ijm

start C:\Fiji.app\ImageJ-win64.exe --console --headless -macro C:\Users\kmurph59\Desktop\ConvertMacro\Thread4.ijm

start C:\Fiji.app\ImageJ-win64.exe --console --headless -macro C:\Users\kmurph59\Desktop\ConvertMacro\Thread5.ijm


And for the corresponding error here after I execute the batch file. The first macro executes properly and outputs the expected data. The last four macros fail to run at all - nevermind simultaneously as I was hoping.

java.lang.RuntimeException: Cannot instantiate headless dialog except in macro mode
at net.imagej.patcher.HeadlessGenericDialog.(HeadlessGenericDialog.java:93)
at ij.gui.GenericDialog.(GenericDialog.java:108)
at ij.gui.GenericDialog.(GenericDialog.java:90)
at ij.macro.Functions.doDialog(Functions.java:3800)
at ij.macro.Functions.getStringFunction(Functions.java:268)
at ij.macro.Interpreter.getStringTerm(Interpreter.java:1407)
at ij.macro.Interpreter.getString(Interpreter.java:1385)
at ij.macro.Interpreter.doStatement(Interpreter.java:324)
at ij.macro.Interpreter.doStatements(Interpreter.java:256)
at ij.macro.Interpreter.run(Interpreter.java:152)
at ij.macro.Interpreter.run(Interpreter.java:91)
at ij.macro.Interpreter.run(Interpreter.java:102)
at ij.plugin.Macro_Runner.runMacro(Macro_Runner.java:161)
at ij.plugin.Macro_Runner.runMacroFile(Macro_Runner.java:145)
at ij.IJ.runMacroFile(IJ.java:160)
at net.imagej.legacy.IJ1Helper$4.call(IJ1Helper.java:1125)
at net.imagej.legacy.IJ1Helper$4.call(IJ1Helper.java:1121)
at net.imagej.legacy.IJ1Helper.runMacroFriendly(IJ1Helper.java:1055)
at net.imagej.legacy.IJ1Helper.runMacroFile(IJ1Helper.java:1121)
at net.imagej.legacy.LegacyCommandline$Macro.handle(LegacyCommandline.java:187)
at org.scijava.console.DefaultConsoleService.processArgs(DefaultConsoleService.java:102)
at org.scijava.AbstractGateway.launch(AbstractGateway.java:97)
at net.imagej.Main.main(Main.java:55)
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)
at net.imagej.launcher.ClassLauncher.launch(ClassLauncher.java:279)
at net.imagej.launcher.ClassLauncher.run(ClassLauncher.java:186)
at net.imagej.launcher.ClassLauncher.main(ClassLauncher.java:77)