BigStitcher HEADLESS fails

Hi @hoerldavid @StephanPreibisch,

I have a Bigstitcher macro which runs perfectly well when I opne Fiji and run it from the script editor(awesome! :star_struck: ).
here is the macro

#@ File input_path

start_time = getTime();

first_czi = replace(input_path, "\\", "/");
filename = File.getName(first_czi);
parent_dir = replace( File.getParent(first_czi), "\\", "/" );
project_filename = replace(filename, ".czi", ".xml");
project_filename_short = replace(filename, ".czi", "");
export_path = parent_dir + "/" + project_filename_short;
project_path = parent_dir + "/" + project_filename;
export_path_fused = parent_dir + "/" + project_filename_short + "_fused.xml";


// define dataset
run("Define dataset ...", "define_dataset=[Automatic Loader (Bioformats based)] project_filename=" + project_filename +" path=" + first_czi + " exclude=10 bioformats_series_are?=Tiles move_tiles_to_grid_(per_angle)?=[Do not move Tiles to Grid (use Metadata if available)] how_to_load_images=[Re-save as multiresolution HDF5] dataset_save_path=" + parent_dir + " check_stack_sizes use_deflate_compression export_path=" + export_path);

// calculate pairwise shifts // at this step the views dual side illum can be averaged?
run("Calculate pairwise shifts ...", "select=" + project_path + " process_angle=[All angles] process_channel=[All channels] process_illumination=[All illuminations] process_tile=[All tiles] process_timepoint=[All Timepoints] method=[Phase Correlation] channels=[Average Channels] illuminations=[Average Illuminations]");

// filter shifts with 0.7 corr. threshold
run("Filter pairwise shifts ...", "select=" + project_path + " filter_by_link_quality min_r=0.7 max_r=1 max_shift_in_x=0 max_shift_in_y=0 max_shift_in_z=0 max_displacement=0");

// do global optimization
run("Optimize globally and apply shifts ...", "select=" + project_path + " process_angle=[All angles] process_channel=[All channels] process_illumination=[All illuminations] process_tile=[All tiles] process_timepoint=[All Timepoints] relative=2.500 absolute=3.500 global_optimization_strategy=[Two-Round using Metadata to align unconnected Tiles] fix_group_0-0,");

// select illuminations
run("Select Illuminations", "select=" + project_path + " selection=[Pick brightest]");

// note: at his point the dataset is already stitched and can be inspected from any client using bigstitcher/BDV/BVV

// fuse dataset, save as new hdf5
image=[Precompute Image] vs image=Cached
run("Fuse dataset ...", "select=" + project_path + " process_angle=[All angles] process_channel=[All channels] process_illumination=[All illuminations] process_tile=[All tiles] process_timepoint=[All Timepoints] bounding_box=[Currently Selected Views] downsampling=8 pixel_type=[16-bit unsigned integer] interpolation=[Linear Interpolation] image=[Precompute Image] interest_points_for_non_rigid=[-= Disable Non-Rigid =-] blend produce=[Each timepoint & channel] fused_image=[Save as new XML Project (HDF5)] use_deflate_compression export_path="+ export_path_fused);

end_time = getTime();
total_time_in_min = (end_time - start_time) / 60000;
print(total_time_in_min + " min");

// terminate IJ. not sure if necessary
eval("script", "System.exit(0);");

I would now like to run this macro headless on Windows 10 using the command prompt:

cd "C:\Tools\Fiji.app-bigstitcher\"
ImageJ-win64 --ij2 --headless --console --run zeiss-lightsheet-bigstitcher.ijm "input_path='D:\Kai\LS-tests\E16_mcherry\E16_mcherry.czi'"

But this fails with

C:\Tools\Fiji.app-bigstitcher>Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
Jun 17, 2020 5:24:29 PM java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
java.lang.VerifyError: Bad invokespecial instruction: current class isn't assignable to reference class.
Exception Details:
  Location:
    ij/gui/GenericDialog.show()V @1: invokespecial
  Reason:
    Error exists in the bytecode
  Bytecode:
    0x0000000: 2ab7 0314 2ab4 0317 9a00 0c13 0319 1303
    0x0000010: 1bb8 031e b1
  Stackmap Table:
    same_frame(@20)

        at net.preibisch.mvrecon.fiji.plugin.Define_Multi_View_Dataset.defineDataset(Define_Multi_View_Dataset.java:106)
        at net.preibisch.mvrecon.fiji.plugin.Define_Multi_View_Dataset.run(Define_Multi_View_Dataset.java:80)
        at ij.IJ.runUserPlugIn(IJ.java:235)
        at ij.IJ.runPlugIn(IJ.java:198)
        at ij.Executer.runCommand(Executer.java:150)
        at ij.Executer.run(Executer.java:68)
        at ij.IJ.run(IJ.java:317)
        at ij.IJ.run(IJ.java:328)
        at ij.macro.Functions.doRun(Functions.java:685)
        at ij.macro.Functions.doFunction(Functions.java:98)
        at ij.macro.Interpreter.doStatement(Interpreter.java:278)
        at ij.macro.Interpreter.doStatements(Interpreter.java:264)
        at ij.macro.Interpreter.run(Interpreter.java:160)
        at ij.macro.Interpreter.run(Interpreter.java:93)
        at ij.macro.Interpreter.run(Interpreter.java:104)
        at ij.plugin.Macro_Runner.runMacro(Macro_Runner.java:161)
        at ij.IJ.runMacro(IJ.java:153)
        at ij.IJ.runMacro(IJ.java:142)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1148)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1144)
        at net.imagej.legacy.IJ1Helper.runMacroFriendly(IJ1Helper.java:1095)
        at net.imagej.legacy.IJ1Helper.runMacro(IJ1Helper.java:1144)
        at net.imagej.legacy.plugin.IJ1MacroEngine.eval(IJ1MacroEngine.java:145)
        at org.scijava.script.ScriptModule.run(ScriptModule.java:160)
        at org.scijava.module.ModuleRunner.run(ModuleRunner.java:168)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
        at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:228)
        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)

Using spimdata version: 0.9-revision
Using multiview-reconstruction version: 0.7.2
java.lang.VerifyError: Bad invokespecial instruction: current class isn't assignable to reference class.
Exception Details:
  Location:
    ij/gui/GenericDialog.show()V @1: invokespecial
  Reason:
    Error exists in the bytecode
  Bytecode:
    0x0000000: 2ab7 0314 2ab4 0317 9a00 0c13 0319 1303
    0x0000010: 1bb8 031e b1
  Stackmap Table:
    same_frame(@20)

        at net.preibisch.mvrecon.fiji.plugin.queryXML.GenericLoadParseQueryXML.queryXML(GenericLoadParseQueryXML.java:265)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:118)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:109)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:58)
        at net.preibisch.stitcher.plugin.Calculate_Pairwise_Shifts.run(Calculate_Pairwise_Shifts.java:90)
        at ij.IJ.runUserPlugIn(IJ.java:235)
        at ij.IJ.runPlugIn(IJ.java:198)
        at ij.Executer.runCommand(Executer.java:150)
        at ij.Executer.run(Executer.java:68)
        at ij.IJ.run(IJ.java:317)
        at ij.IJ.run(IJ.java:328)
        at ij.macro.Functions.doRun(Functions.java:685)
        at ij.macro.Functions.doFunction(Functions.java:98)
        at ij.macro.Interpreter.doStatement(Interpreter.java:278)
        at ij.macro.Interpreter.doStatements(Interpreter.java:264)
        at ij.macro.Interpreter.run(Interpreter.java:160)
        at ij.macro.Interpreter.run(Interpreter.java:93)
        at ij.macro.Interpreter.run(Interpreter.java:104)
        at ij.plugin.Macro_Runner.runMacro(Macro_Runner.java:161)
        at ij.IJ.runMacro(IJ.java:153)
        at ij.IJ.runMacro(IJ.java:142)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1148)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1144)
        at net.imagej.legacy.IJ1Helper.runMacroFriendly(IJ1Helper.java:1095)
        at net.imagej.legacy.IJ1Helper.runMacro(IJ1Helper.java:1144)
        at net.imagej.legacy.plugin.IJ1MacroEngine.eval(IJ1MacroEngine.java:145)
        at org.scijava.script.ScriptModule.run(ScriptModule.java:160)
        at org.scijava.module.ModuleRunner.run(ModuleRunner.java:168)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
        at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:228)
        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)

Using spimdata version: 0.9-revision
java.lang.VerifyError: Bad invokespecial instruction: current class isn't assignable to reference class.
Exception Details:
  Location:
    ij/gui/GenericDialog.show()V @1: invokespecial
  Reason:
    Error exists in the bytecode
  Bytecode:
    0x0000000: 2ab7 0314 2ab4 0317 9a00 0c13 0319 1303
    0x0000010: 1bb8 031e b1
  Stackmap Table:
    same_frame(@20)

        at net.preibisch.mvrecon.fiji.plugin.queryXML.GenericLoadParseQueryXML.queryXML(GenericLoadParseQueryXML.java:265)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:118)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:109)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:58)
        at net.preibisch.stitcher.plugin.Filter_Pairwise_Shifts.run(Filter_Pairwise_Shifts.java:36)
        at ij.IJ.runUserPlugIn(IJ.java:235)
        at ij.IJ.runPlugIn(IJ.java:198)
        at ij.Executer.runCommand(Executer.java:150)
        at ij.Executer.run(Executer.java:68)
        at ij.IJ.run(IJ.java:317)
        at ij.IJ.run(IJ.java:328)
        at ij.macro.Functions.doRun(Functions.java:685)
        at ij.macro.Functions.doFunction(Functions.java:98)
        at ij.macro.Interpreter.doStatement(Interpreter.java:278)
        at ij.macro.Interpreter.doStatements(Interpreter.java:264)
        at ij.macro.Interpreter.run(Interpreter.java:160)
        at ij.macro.Interpreter.run(Interpreter.java:93)
        at ij.macro.Interpreter.run(Interpreter.java:104)
        at ij.plugin.Macro_Runner.runMacro(Macro_Runner.java:161)
        at ij.IJ.runMacro(IJ.java:153)
        at ij.IJ.runMacro(IJ.java:142)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1148)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1144)
        at net.imagej.legacy.IJ1Helper.runMacroFriendly(IJ1Helper.java:1095)
        at net.imagej.legacy.IJ1Helper.runMacro(IJ1Helper.java:1144)
        at net.imagej.legacy.plugin.IJ1MacroEngine.eval(IJ1MacroEngine.java:145)
        at org.scijava.script.ScriptModule.run(ScriptModule.java:160)
        at org.scijava.module.ModuleRunner.run(ModuleRunner.java:168)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
        at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:228)
        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)

Using multiview-reconstruction version: 0.7.2
Using spimdata version: 0.9-revision
Using multiview-reconstruction version: 0.7.2
java.lang.VerifyError: Bad invokespecial instruction: current class isn't assignable to reference class.
Exception Details:
  Location:
    ij/gui/GenericDialog.show()V @1: invokespecial
  Reason:
    Error exists in the bytecode
  Bytecode:
    0x0000000: 2ab7 0314 2ab4 0317 9a00 0c13 0319 1303
    0x0000010: 1bb8 031e b1
  Stackmap Table:
    same_frame(@20)

        at net.preibisch.mvrecon.fiji.plugin.queryXML.GenericLoadParseQueryXML.queryXML(GenericLoadParseQueryXML.java:265)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:118)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:109)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:58)
        at net.preibisch.stitcher.plugin.Global_Optimization_Stitching.run(Global_Optimization_Stitching.java:50)
        at ij.IJ.runUserPlugIn(IJ.java:235)
        at ij.IJ.runPlugIn(IJ.java:198)
        at ij.Executer.runCommand(Executer.java:150)
        at ij.Executer.run(Executer.java:68)
        at ij.IJ.run(IJ.java:317)
        at ij.IJ.run(IJ.java:328)
        at ij.macro.Functions.doRun(Functions.java:685)
        at ij.macro.Functions.doFunction(Functions.java:98)
        at ij.macro.Interpreter.doStatement(Interpreter.java:278)
        at ij.macro.Interpreter.doStatements(Interpreter.java:264)
        at ij.macro.Interpreter.run(Interpreter.java:160)
        at ij.macro.Interpreter.run(Interpreter.java:93)
        at ij.macro.Interpreter.run(Interpreter.java:104)
        at ij.plugin.Macro_Runner.runMacro(Macro_Runner.java:161)
        at ij.IJ.runMacro(IJ.java:153)
        at ij.IJ.runMacro(IJ.java:142)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1148)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1144)
        at net.imagej.legacy.IJ1Helper.runMacroFriendly(IJ1Helper.java:1095)
        at net.imagej.legacy.IJ1Helper.runMacro(IJ1Helper.java:1144)
        at net.imagej.legacy.plugin.IJ1MacroEngine.eval(IJ1MacroEngine.java:145)
        at org.scijava.script.ScriptModule.run(ScriptModule.java:160)
        at org.scijava.module.ModuleRunner.run(ModuleRunner.java:168)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
        at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:228)
        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)

Using spimdata version: 0.9-revision
Using multiview-reconstruction version: 0.7.2
java.lang.VerifyError: Bad invokespecial instruction: current class isn't assignable to reference class.
Exception Details:
  Location:
    ij/gui/GenericDialog.show()V @1: invokespecial
  Reason:
    Error exists in the bytecode
  Bytecode:
    0x0000000: 2ab7 0314 2ab4 0317 9a00 0c13 0319 1303
    0x0000010: 1bb8 031e b1
  Stackmap Table:
    same_frame(@20)

        at net.preibisch.mvrecon.fiji.plugin.queryXML.GenericLoadParseQueryXML.queryXML(GenericLoadParseQueryXML.java:265)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:118)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:109)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:58)
        at net.preibisch.stitcher.plugin.Illumination_Selection.run(Illumination_Selection.java:40)
        at ij.IJ.runUserPlugIn(IJ.java:235)
        at ij.IJ.runPlugIn(IJ.java:198)
        at ij.Executer.runCommand(Executer.java:150)
        at ij.Executer.run(Executer.java:68)
        at ij.IJ.run(IJ.java:317)
        at ij.IJ.run(IJ.java:328)
        at ij.macro.Functions.doRun(Functions.java:685)
        at ij.macro.Functions.doFunction(Functions.java:98)
        at ij.macro.Interpreter.doStatement(Interpreter.java:278)
        at ij.macro.Interpreter.doStatements(Interpreter.java:264)
        at ij.macro.Interpreter.run(Interpreter.java:160)
        at ij.macro.Interpreter.run(Interpreter.java:93)
        at ij.macro.Interpreter.run(Interpreter.java:104)
        at ij.plugin.Macro_Runner.runMacro(Macro_Runner.java:161)
        at ij.IJ.runMacro(IJ.java:153)
        at ij.IJ.runMacro(IJ.java:142)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1148)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1144)
        at net.imagej.legacy.IJ1Helper.runMacroFriendly(IJ1Helper.java:1095)
        at net.imagej.legacy.IJ1Helper.runMacro(IJ1Helper.java:1144)
        at net.imagej.legacy.plugin.IJ1MacroEngine.eval(IJ1MacroEngine.java:145)
        at org.scijava.script.ScriptModule.run(ScriptModule.java:160)
        at org.scijava.module.ModuleRunner.run(ModuleRunner.java:168)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
        at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:228)
        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)

Using spimdata version: 0.9-revision
Using multiview-reconstruction version: 0.7.2
java.lang.VerifyError: Bad invokespecial instruction: current class isn't assignable to reference class.
Exception Details:
  Location:
    ij/gui/GenericDialog.show()V @1: invokespecial
  Reason:
    Error exists in the bytecode
  Bytecode:
    0x0000000: 2ab7 0314 2ab4 0317 9a00 0c13 0319 1303
    0x0000010: 1bb8 031e b1
  Stackmap Table:
    same_frame(@20)

        at net.preibisch.mvrecon.fiji.plugin.queryXML.GenericLoadParseQueryXML.queryXML(GenericLoadParseQueryXML.java:265)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:118)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:109)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:58)
        at net.preibisch.mvrecon.fiji.plugin.Image_Fusion.run(Image_Fusion.java:86)
        at ij.IJ.runUserPlugIn(IJ.java:235)
        at ij.IJ.runPlugIn(IJ.java:198)
        at ij.Executer.runCommand(Executer.java:150)
        at ij.Executer.run(Executer.java:68)
        at ij.IJ.run(IJ.java:317)
        at ij.IJ.run(IJ.java:328)
        at ij.macro.Functions.doRun(Functions.java:685)
        at ij.macro.Functions.doFunction(Functions.java:98)
        at ij.macro.Interpreter.doStatement(Interpreter.java:278)
        at ij.macro.Interpreter.doStatements(Interpreter.java:264)
        at ij.macro.Interpreter.run(Interpreter.java:160)
        at ij.macro.Interpreter.run(Interpreter.java:93)
        at ij.macro.Interpreter.run(Interpreter.java:104)
        at ij.plugin.Macro_Runner.runMacro(Macro_Runner.java:161)
        at ij.IJ.runMacro(IJ.java:153)
        at ij.IJ.runMacro(IJ.java:142)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1148)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1144)
        at net.imagej.legacy.IJ1Helper.runMacroFriendly(IJ1Helper.java:1095)
        at net.imagej.legacy.IJ1Helper.runMacro(IJ1Helper.java:1144)
        at net.imagej.legacy.plugin.IJ1MacroEngine.eval(IJ1MacroEngine.java:145)
        at org.scijava.script.ScriptModule.run(ScriptModule.java:160)
        at org.scijava.module.ModuleRunner.run(ModuleRunner.java:168)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
        at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:228)
        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)

0.001317 min

It seems like BigStitcher is trying to call a GUI element and that leads to the error. Do you have an idea of how this could be fixed?

Thank you very much for your help and this fantastic tool!

You can use a virtual frame buffer: https://imagej.net/Headless

We did this for the multiview reconstruction application: https://imagej.net/Automated_workflow_for_parallel_Multiview_Reconstruction

1 Like

HI @schmiedc,
thank you for your reply! If its really a GUI element that is called, then a virtual frame buffer like Xvfb could indeed solve the issue.
Unfortunately, my google search gave me the impression that Xvfb is only available on Linux, and I did not find an alternative that would work on e.g. Windows 10. Would you know about an alternative for Microsoft Windows?

For completeness, this issue might be related to a prviously reported issue: Problem in image fusion BigStitcher headless imageJ

Thank you for you input!

Ok a quick google search determined that this seems tricky on windows.
The last time this was fixed by the developer.

@hoerldavid could you have a look. Maybe it is like as in this thread: Problem in image fusion BigStitcher headless imageJ

1 Like

Try the ImageJ 1.53c49 daily build. It removes the show() method that was added to Generic Dialog in 1.52r so an error message could be displayed if a plugin called show() instead of showDialog().

2 Likes

thank you both for your replies!

@Wayne , I tested using the ImageJ 1.53c49 daily build. It still unfortunately fails, but the error message seems different to me now. It is now mentioning a java.awt.HeadlessException that seems to still refer to the GraphicsEnvironment and/or the GUI.

C:\Tools\Fiji.app-bigstitcher>ImageJ-win64 --ij2 --headless --console --run zeiss-lightsheet-bigstitcher.ijm "input_path='D:\Kai\LS-tests\E16_mcherry\E16_mcherry.czi'"

C:\Tools\Fiji.app-bigstitcher>Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
Jun 18, 2020 7:01:37 AM java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
java.awt.HeadlessException
        at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)
        at java.awt.Window.<init>(Window.java:536)
        at java.awt.Frame.<init>(Frame.java:420)
        at java.awt.Frame.<init>(Frame.java:385)
        at ij.gui.GUI.getParentFrame(GUI.java:266)
        at ij.gui.GenericDialog.getParentFrame(GenericDialog.java:95)
        at ij.gui.GenericDialog.<init>(GenericDialog.java:91)
        at fiji.util.gui.GenericDialogPlus.<init>(GenericDialogPlus.java:72)
        at net.preibisch.mvrecon.fiji.plugin.Define_Multi_View_Dataset.defineDataset(Define_Multi_View_Dataset.java:106)        at net.preibisch.mvrecon.fiji.plugin.Define_Multi_View_Dataset.run(Define_Multi_View_Dataset.java:80)
        at ij.IJ.runUserPlugIn(IJ.java:235)
        at ij.IJ.runPlugIn(IJ.java:198)
        at ij.Executer.runCommand(Executer.java:150)
        at ij.Executer.run(Executer.java:68)
        at ij.IJ.run(IJ.java:317)
        at ij.IJ.run(IJ.java:328)
        at ij.macro.Functions.doRun(Functions.java:686)
        at ij.macro.Functions.doFunction(Functions.java:98)
        at ij.macro.Interpreter.doStatement(Interpreter.java:278)
        at ij.macro.Interpreter.doStatements(Interpreter.java:264)
        at ij.macro.Interpreter.run(Interpreter.java:160)
        at ij.macro.Interpreter.run(Interpreter.java:93)
        at ij.macro.Interpreter.run(Interpreter.java:104)
        at ij.plugin.Macro_Runner.runMacro(Macro_Runner.java:161)
        at ij.IJ.runMacro(IJ.java:153)
        at ij.IJ.runMacro(IJ.java:142)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1148)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1144)
        at net.imagej.legacy.IJ1Helper.runMacroFriendly(IJ1Helper.java:1095)
        at net.imagej.legacy.IJ1Helper.runMacro(IJ1Helper.java:1144)
        at net.imagej.legacy.plugin.IJ1MacroEngine.eval(IJ1MacroEngine.java:145)
        at org.scijava.script.ScriptModule.run(ScriptModule.java:160)
        at org.scijava.module.ModuleRunner.run(ModuleRunner.java:168)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
        at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:228)
        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)

Using spimdata version: 0.9-revision
Using multiview-reconstruction version: 0.7.2
java.awt.HeadlessException
        at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)
        at java.awt.Window.<init>(Window.java:536)
        at java.awt.Frame.<init>(Frame.java:420)
        at java.awt.Frame.<init>(Frame.java:385)
        at ij.gui.GUI.getParentFrame(GUI.java:266)
        at ij.gui.GenericDialog.getParentFrame(GenericDialog.java:95)
        at ij.gui.GenericDialog.<init>(GenericDialog.java:91)
        at fiji.util.gui.GenericDialogPlus.<init>(GenericDialogPlus.java:72)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.GenericLoadParseQueryXML.queryXML(GenericLoadParseQueryXML.java:265)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:118)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:109)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:58)
        at net.preibisch.stitcher.plugin.Calculate_Pairwise_Shifts.run(Calculate_Pairwise_Shifts.java:90)
        at ij.IJ.runUserPlugIn(IJ.java:235)
        at ij.IJ.runPlugIn(IJ.java:198)
        at ij.Executer.runCommand(Executer.java:150)
        at ij.Executer.run(Executer.java:68)
        at ij.IJ.run(IJ.java:317)
        at ij.IJ.run(IJ.java:328)
        at ij.macro.Functions.doRun(Functions.java:686)
        at ij.macro.Functions.doFunction(Functions.java:98)
        at ij.macro.Interpreter.doStatement(Interpreter.java:278)
        at ij.macro.Interpreter.doStatements(Interpreter.java:264)
        at ij.macro.Interpreter.run(Interpreter.java:160)
        at ij.macro.Interpreter.run(Interpreter.java:93)
        at ij.macro.Interpreter.run(Interpreter.java:104)
        at ij.plugin.Macro_Runner.runMacro(Macro_Runner.java:161)
        at ij.IJ.runMacro(IJ.java:153)
        at ij.IJ.runMacro(IJ.java:142)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1148)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1144)
        at net.imagej.legacy.IJ1Helper.runMacroFriendly(IJ1Helper.java:1095)
        at net.imagej.legacy.IJ1Helper.runMacro(IJ1Helper.java:1144)
        at net.imagej.legacy.plugin.IJ1MacroEngine.eval(IJ1MacroEngine.java:145)
        at org.scijava.script.ScriptModule.run(ScriptModule.java:160)
        at org.scijava.module.ModuleRunner.run(ModuleRunner.java:168)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
        at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:228)
        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)

Using spimdata version: 0.9-revision
java.awt.HeadlessException
        at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)
        at java.awt.Window.<init>(Window.java:536)
        at java.awt.Frame.<init>(Frame.java:420)
        at java.awt.Frame.<init>(Frame.java:385)
        at ij.gui.GUI.getParentFrame(GUI.java:266)
        at ij.gui.GenericDialog.getParentFrame(GenericDialog.java:95)
        at ij.gui.GenericDialog.<init>(GenericDialog.java:91)
        at fiji.util.gui.GenericDialogPlus.<init>(GenericDialogPlus.java:72)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.GenericLoadParseQueryXML.queryXML(GenericLoadParseQueryXML.java:265)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:118)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:109)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:58)
        at net.preibisch.stitcher.plugin.Filter_Pairwise_Shifts.run(Filter_Pairwise_Shifts.java:36)
        at ij.IJ.runUserPlugIn(IJ.java:235)
        at ij.IJ.runPlugIn(IJ.java:198)
        at ij.Executer.runCommand(Executer.java:150)
        at ij.Executer.run(Executer.java:68)
        at ij.IJ.run(IJ.java:317)
        at ij.IJ.run(IJ.java:328)
        at ij.macro.Functions.doRun(Functions.java:686)
        at ij.macro.Functions.doFunction(Functions.java:98)
        at ij.macro.Interpreter.doStatement(Interpreter.java:278)
        at ij.macro.Interpreter.doStatements(Interpreter.java:264)
        at ij.macro.Interpreter.run(Interpreter.java:160)
        at ij.macro.Interpreter.run(Interpreter.java:93)
        at ij.macro.Interpreter.run(Interpreter.java:104)
        at ij.plugin.Macro_Runner.runMacro(Macro_Runner.java:161)
        at ij.IJ.runMacro(IJ.java:153)
        at ij.IJ.runMacro(IJ.java:142)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1148)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1144)
        at net.imagej.legacy.IJ1Helper.runMacroFriendly(IJ1Helper.java:1095)
        at net.imagej.legacy.IJ1Helper.runMacro(IJ1Helper.java:1144)
        at net.imagej.legacy.plugin.IJ1MacroEngine.eval(IJ1MacroEngine.java:145)
        at org.scijava.script.ScriptModule.run(ScriptModule.java:160)
        at org.scijava.module.ModuleRunner.run(ModuleRunner.java:168)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
        at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:228)
        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)

Using multiview-reconstruction version: 0.7.2
Using spimdata version: 0.9-revision
Using multiview-reconstruction version: 0.7.2
java.awt.HeadlessException
        at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)
        at java.awt.Window.<init>(Window.java:536)
        at java.awt.Frame.<init>(Frame.java:420)
        at java.awt.Frame.<init>(Frame.java:385)
        at ij.gui.GUI.getParentFrame(GUI.java:266)
        at ij.gui.GenericDialog.getParentFrame(GenericDialog.java:95)
        at ij.gui.GenericDialog.<init>(GenericDialog.java:91)
        at fiji.util.gui.GenericDialogPlus.<init>(GenericDialogPlus.java:72)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.GenericLoadParseQueryXML.queryXML(GenericLoadParseQueryXML.java:265)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:118)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:109)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:58)
        at net.preibisch.stitcher.plugin.Global_Optimization_Stitching.run(Global_Optimization_Stitching.java:50)
        at ij.IJ.runUserPlugIn(IJ.java:235)
        at ij.IJ.runPlugIn(IJ.java:198)
        at ij.Executer.runCommand(Executer.java:150)
        at ij.Executer.run(Executer.java:68)
        at ij.IJ.run(IJ.java:317)
        at ij.IJ.run(IJ.java:328)
        at ij.macro.Functions.doRun(Functions.java:686)
        at ij.macro.Functions.doFunction(Functions.java:98)
        at ij.macro.Interpreter.doStatement(Interpreter.java:278)
        at ij.macro.Interpreter.doStatements(Interpreter.java:264)
        at ij.macro.Interpreter.run(Interpreter.java:160)
        at ij.macro.Interpreter.run(Interpreter.java:93)
        at ij.macro.Interpreter.run(Interpreter.java:104)
        at ij.plugin.Macro_Runner.runMacro(Macro_Runner.java:161)
        at ij.IJ.runMacro(IJ.java:153)
        at ij.IJ.runMacro(IJ.java:142)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1148)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1144)
        at net.imagej.legacy.IJ1Helper.runMacroFriendly(IJ1Helper.java:1095)
        at net.imagej.legacy.IJ1Helper.runMacro(IJ1Helper.java:1144)
        at net.imagej.legacy.plugin.IJ1MacroEngine.eval(IJ1MacroEngine.java:145)
        at org.scijava.script.ScriptModule.run(ScriptModule.java:160)
        at org.scijava.module.ModuleRunner.run(ModuleRunner.java:168)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
        at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:228)
        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)

Using spimdata version: 0.9-revision
java.awt.HeadlessException
        at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)
        at java.awt.Window.<init>(Window.java:536)
        at java.awt.Frame.<init>(Frame.java:420)
        at java.awt.Frame.<init>(Frame.java:385)
        at ij.gui.GUI.getParentFrame(GUI.java:266)
        at ij.gui.GenericDialog.getParentFrame(GenericDialog.java:95)
        at ij.gui.GenericDialog.<init>(GenericDialog.java:91)
        at fiji.util.gui.GenericDialogPlus.<init>(GenericDialogPlus.java:72)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.GenericLoadParseQueryXML.queryXML(GenericLoadParseQueryXML.java:265)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:118)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:109)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:58)
        at net.preibisch.stitcher.plugin.Illumination_Selection.run(Illumination_Selection.java:40)
        at ij.IJ.runUserPlugIn(IJ.java:235)
        at ij.IJ.runPlugIn(IJ.java:198)
        at ij.Executer.runCommand(Executer.java:150)
        at ij.Executer.run(Executer.java:68)
        at ij.IJ.run(IJ.java:317)
        at ij.IJ.run(IJ.java:328)
        at ij.macro.Functions.doRun(Functions.java:686)
        at ij.macro.Functions.doFunction(Functions.java:98)
        at ij.macro.Interpreter.doStatement(Interpreter.java:278)
        at ij.macro.Interpreter.doStatements(Interpreter.java:264)
        at ij.macro.Interpreter.run(Interpreter.java:160)
        at ij.macro.Interpreter.run(Interpreter.java:93)
        at ij.macro.Interpreter.run(Interpreter.java:104)
        at ij.plugin.Macro_Runner.runMacro(Macro_Runner.java:161)
        at ij.IJ.runMacro(IJ.java:153)
        at ij.IJ.runMacro(IJ.java:142)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1148)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1144)
        at net.imagej.legacy.IJ1Helper.runMacroFriendly(IJ1Helper.java:1095)
        at net.imagej.legacy.IJ1Helper.runMacro(IJ1Helper.java:1144)
        at net.imagej.legacy.plugin.IJ1MacroEngine.eval(IJ1MacroEngine.java:145)
        at org.scijava.script.ScriptModule.run(ScriptModule.java:160)
        at org.scijava.module.ModuleRunner.run(ModuleRunner.java:168)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
        at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:228)
        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)

Using multiview-reconstruction version: 0.7.2
Using spimdata version: 0.9-revision
java.awt.HeadlessException
        at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)
        at java.awt.Window.<init>(Window.java:536)
        at java.awt.Frame.<init>(Frame.java:420)
        at java.awt.Frame.<init>(Frame.java:385)
        at ij.gui.GUI.getParentFrame(GUI.java:266)
        at ij.gui.GenericDialog.getParentFrame(GenericDialog.java:95)
        at ij.gui.GenericDialog.<init>(GenericDialog.java:91)
        at fiji.util.gui.GenericDialogPlus.<init>(GenericDialogPlus.java:72)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.GenericLoadParseQueryXML.queryXML(GenericLoadParseQueryXML.java:265)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:118)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:109)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:58)
        at net.preibisch.mvrecon.fiji.plugin.Image_Fusion.run(Image_Fusion.java:86)
        at ij.IJ.runUserPlugIn(IJ.java:235)
        at ij.IJ.runPlugIn(IJ.java:198)
        at ij.Executer.runCommand(Executer.java:150)
        at ij.Executer.run(Executer.java:68)
        at ij.IJ.run(IJ.java:317)
        at ij.IJ.run(IJ.java:328)
        at ij.macro.Functions.doRun(Functions.java:686)
        at ij.macro.Functions.doFunction(Functions.java:98)
        at ij.macro.Interpreter.doStatement(Interpreter.java:278)
        at ij.macro.Interpreter.doStatements(Interpreter.java:264)
        at ij.macro.Interpreter.run(Interpreter.java:160)
        at ij.macro.Interpreter.run(Interpreter.java:93)
        at ij.macro.Interpreter.run(Interpreter.java:104)
        at ij.plugin.Macro_Runner.runMacro(Macro_Runner.java:161)
        at ij.IJ.runMacro(IJ.java:153)
        at ij.IJ.runMacro(IJ.java:142)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1148)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1144)
        at net.imagej.legacy.IJ1Helper.runMacroFriendly(IJ1Helper.java:1095)
        at net.imagej.legacy.IJ1Helper.runMacro(IJ1Helper.java:1144)
        at net.imagej.legacy.plugin.IJ1MacroEngine.eval(IJ1MacroEngine.java:145)
        at org.scijava.script.ScriptModule.run(ScriptModule.java:160)
        at org.scijava.module.ModuleRunner.run(ModuleRunner.java:168)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
        at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:228)
        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)

Using multiview-reconstruction version: 0.7.2
0.001067 min

Thank you again for your help, I really appreciate it!

1 Like

Try the ImageJ 1.53c50 daily build. It prevents this particular exception, but I am confused. I thought Fiji did not use GenericDialogs in headless mode and instead substituted a version that was not a subclass of java.awt.Dialog. The Java documentation says that java.awt.Dialog constructors throw a HeadlessException in headless mode, so you may get this exception after you upgrade to 1.53c50.

2 Likes

thanks once again for the support @Wayne !

I updated to the ImageJ 1.53c50 daily build, but indeed it fails as you thought with java.awt.HeadlessException:

C:\Tools\Fiji.app-bigstitcher>Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
Jun 18, 2020 6:07:53 PM java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
java.awt.HeadlessException
        at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)
        at java.awt.Button.<init>(Button.java:152)
        at ij.gui.GenericDialog.<init>(GenericDialog.java:101)
        at ij.gui.GenericDialog.<init>(GenericDialog.java:91)
        at fiji.util.gui.GenericDialogPlus.<init>(GenericDialogPlus.java:72)
        at net.preibisch.mvrecon.fiji.plugin.Define_Multi_View_Dataset.defineDataset(Define_Multi_View_Dataset.java:106)
        at net.preibisch.mvrecon.fiji.plugin.Define_Multi_View_Dataset.run(Define_Multi_View_Dataset.java:80)
        at ij.IJ.runUserPlugIn(IJ.java:235)
        at ij.IJ.runPlugIn(IJ.java:198)
        at ij.Executer.runCommand(Executer.java:150)
        at ij.Executer.run(Executer.java:68)
        at ij.IJ.run(IJ.java:317)
        at ij.IJ.run(IJ.java:328)
        at ij.macro.Functions.doRun(Functions.java:686)
        at ij.macro.Functions.doFunction(Functions.java:98)
        at ij.macro.Interpreter.doStatement(Interpreter.java:278)
        at ij.macro.Interpreter.doStatements(Interpreter.java:264)
        at ij.macro.Interpreter.run(Interpreter.java:160)
        at ij.macro.Interpreter.run(Interpreter.java:93)
        at ij.macro.Interpreter.run(Interpreter.java:104)
        at ij.plugin.Macro_Runner.runMacro(Macro_Runner.java:161)
        at ij.IJ.runMacro(IJ.java:153)
        at ij.IJ.runMacro(IJ.java:142)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1148)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1144)
        at net.imagej.legacy.IJ1Helper.runMacroFriendly(IJ1Helper.java:1095)
        at net.imagej.legacy.IJ1Helper.runMacro(IJ1Helper.java:1144)
        at net.imagej.legacy.plugin.IJ1MacroEngine.eval(IJ1MacroEngine.java:145)
        at org.scijava.script.ScriptModule.run(ScriptModule.java:160)
        at org.scijava.module.ModuleRunner.run(ModuleRunner.java:168)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
        at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:228)
        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)

Using spimdata version: 0.9-revision
Using multiview-reconstruction version: 0.7.2
java.awt.HeadlessException
        at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)
        at java.awt.Button.<init>(Button.java:152)
        at ij.gui.GenericDialog.<init>(GenericDialog.java:101)
        at ij.gui.GenericDialog.<init>(GenericDialog.java:91)
        at fiji.util.gui.GenericDialogPlus.<init>(GenericDialogPlus.java:72)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.GenericLoadParseQueryXML.queryXML(GenericLoadParseQueryXML.java:265)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:118)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:109)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:58)
        at net.preibisch.stitcher.plugin.Calculate_Pairwise_Shifts.run(Calculate_Pairwise_Shifts.java:90)
        at ij.IJ.runUserPlugIn(IJ.java:235)
        at ij.IJ.runPlugIn(IJ.java:198)
        at ij.Executer.runCommand(Executer.java:150)
        at ij.Executer.run(Executer.java:68)
        at ij.IJ.run(IJ.java:317)
        at ij.IJ.run(IJ.java:328)
        at ij.macro.Functions.doRun(Functions.java:686)
        at ij.macro.Functions.doFunction(Functions.java:98)
        at ij.macro.Interpreter.doStatement(Interpreter.java:278)
        at ij.macro.Interpreter.doStatements(Interpreter.java:264)
        at ij.macro.Interpreter.run(Interpreter.java:160)
        at ij.macro.Interpreter.run(Interpreter.java:93)
        at ij.macro.Interpreter.run(Interpreter.java:104)
        at ij.plugin.Macro_Runner.runMacro(Macro_Runner.java:161)
        at ij.IJ.runMacro(IJ.java:153)
        at ij.IJ.runMacro(IJ.java:142)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1148)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1144)
        at net.imagej.legacy.IJ1Helper.runMacroFriendly(IJ1Helper.java:1095)
        at net.imagej.legacy.IJ1Helper.runMacro(IJ1Helper.java:1144)
        at net.imagej.legacy.plugin.IJ1MacroEngine.eval(IJ1MacroEngine.java:145)
        at org.scijava.script.ScriptModule.run(ScriptModule.java:160)
        at org.scijava.module.ModuleRunner.run(ModuleRunner.java:168)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
        at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:228)
        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)

Using spimdata version: 0.9-revision
java.awt.HeadlessException
        at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)
        at java.awt.Button.<init>(Button.java:152)
        at ij.gui.GenericDialog.<init>(GenericDialog.java:101)
        at ij.gui.GenericDialog.<init>(GenericDialog.java:91)
        at fiji.util.gui.GenericDialogPlus.<init>(GenericDialogPlus.java:72)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.GenericLoadParseQueryXML.queryXML(GenericLoadParseQueryXML.java:265)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:118)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:109)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:58)
        at net.preibisch.stitcher.plugin.Filter_Pairwise_Shifts.run(Filter_Pairwise_Shifts.java:36)
        at ij.IJ.runUserPlugIn(IJ.java:235)
        at ij.IJ.runPlugIn(IJ.java:198)
        at ij.Executer.runCommand(Executer.java:150)
        at ij.Executer.run(Executer.java:68)
        at ij.IJ.run(IJ.java:317)
        at ij.IJ.run(IJ.java:328)
        at ij.macro.Functions.doRun(Functions.java:686)
        at ij.macro.Functions.doFunction(Functions.java:98)
        at ij.macro.Interpreter.doStatement(Interpreter.java:278)
        at ij.macro.Interpreter.doStatements(Interpreter.java:264)
        at ij.macro.Interpreter.run(Interpreter.java:160)
        at ij.macro.Interpreter.run(Interpreter.java:93)
        at ij.macro.Interpreter.run(Interpreter.java:104)
        at ij.plugin.Macro_Runner.runMacro(Macro_Runner.java:161)
        at ij.IJ.runMacro(IJ.java:153)
        at ij.IJ.runMacro(IJ.java:142)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1148)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1144)
        at net.imagej.legacy.IJ1Helper.runMacroFriendly(IJ1Helper.java:1095)
        at net.imagej.legacy.IJ1Helper.runMacro(IJ1Helper.java:1144)
        at net.imagej.legacy.plugin.IJ1MacroEngine.eval(IJ1MacroEngine.java:145)
        at org.scijava.script.ScriptModule.run(ScriptModule.java:160)
        at org.scijava.module.ModuleRunner.run(ModuleRunner.java:168)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
        at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:228)
        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)

Using multiview-reconstruction version: 0.7.2
Using spimdata version: 0.9-revision
java.awt.HeadlessException
        at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)
        at java.awt.Button.<init>(Button.java:152)
        at ij.gui.GenericDialog.<init>(GenericDialog.java:101)
        at ij.gui.GenericDialog.<init>(GenericDialog.java:91)
        at fiji.util.gui.GenericDialogPlus.<init>(GenericDialogPlus.java:72)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.GenericLoadParseQueryXML.queryXML(GenericLoadParseQueryXML.java:265)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:118)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:109)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:58)
        at net.preibisch.stitcher.plugin.Global_Optimization_Stitching.run(Global_Optimization_Stitching.java:50)
        at ij.IJ.runUserPlugIn(IJ.java:235)
        at ij.IJ.runPlugIn(IJ.java:198)
        at ij.Executer.runCommand(Executer.java:150)
        at ij.Executer.run(Executer.java:68)
        at ij.IJ.run(IJ.java:317)
        at ij.IJ.run(IJ.java:328)
        at ij.macro.Functions.doRun(Functions.java:686)
        at ij.macro.Functions.doFunction(Functions.java:98)
        at ij.macro.Interpreter.doStatement(Interpreter.java:278)
        at ij.macro.Interpreter.doStatements(Interpreter.java:264)
        at ij.macro.Interpreter.run(Interpreter.java:160)
        at ij.macro.Interpreter.run(Interpreter.java:93)
        at ij.macro.Interpreter.run(Interpreter.java:104)
        at ij.plugin.Macro_Runner.runMacro(Macro_Runner.java:161)
        at ij.IJ.runMacro(IJ.java:153)
        at ij.IJ.runMacro(IJ.java:142)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1148)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1144)
        at net.imagej.legacy.IJ1Helper.runMacroFriendly(IJ1Helper.java:1095)
        at net.imagej.legacy.IJ1Helper.runMacro(IJ1Helper.java:1144)
        at net.imagej.legacy.plugin.IJ1MacroEngine.eval(IJ1MacroEngine.java:145)
        at org.scijava.script.ScriptModule.run(ScriptModule.java:160)
        at org.scijava.module.ModuleRunner.run(ModuleRunner.java:168)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
        at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:228)
        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)

Using multiview-reconstruction version: 0.7.2
Using spimdata version: 0.9-revision
Using multiview-reconstruction version: 0.7.2
java.awt.HeadlessException
        at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)
        at java.awt.Button.<init>(Button.java:152)
        at ij.gui.GenericDialog.<init>(GenericDialog.java:101)
        at ij.gui.GenericDialog.<init>(GenericDialog.java:91)
        at fiji.util.gui.GenericDialogPlus.<init>(GenericDialogPlus.java:72)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.GenericLoadParseQueryXML.queryXML(GenericLoadParseQueryXML.java:265)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:118)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:109)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:58)
        at net.preibisch.stitcher.plugin.Illumination_Selection.run(Illumination_Selection.java:40)
        at ij.IJ.runUserPlugIn(IJ.java:235)
        at ij.IJ.runPlugIn(IJ.java:198)
        at ij.Executer.runCommand(Executer.java:150)
        at ij.Executer.run(Executer.java:68)
        at ij.IJ.run(IJ.java:317)
        at ij.IJ.run(IJ.java:328)
        at ij.macro.Functions.doRun(Functions.java:686)
        at ij.macro.Functions.doFunction(Functions.java:98)
        at ij.macro.Interpreter.doStatement(Interpreter.java:278)
        at ij.macro.Interpreter.doStatements(Interpreter.java:264)
        at ij.macro.Interpreter.run(Interpreter.java:160)
        at ij.macro.Interpreter.run(Interpreter.java:93)
        at ij.macro.Interpreter.run(Interpreter.java:104)
        at ij.plugin.Macro_Runner.runMacro(Macro_Runner.java:161)
        at ij.IJ.runMacro(IJ.java:153)
        at ij.IJ.runMacro(IJ.java:142)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1148)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1144)
        at net.imagej.legacy.IJ1Helper.runMacroFriendly(IJ1Helper.java:1095)
        at net.imagej.legacy.IJ1Helper.runMacro(IJ1Helper.java:1144)
        at net.imagej.legacy.plugin.IJ1MacroEngine.eval(IJ1MacroEngine.java:145)
        at org.scijava.script.ScriptModule.run(ScriptModule.java:160)
        at org.scijava.module.ModuleRunner.run(ModuleRunner.java:168)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
        at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:228)
        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)

Using spimdata version: 0.9-revision
java.awt.HeadlessException
        at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)
        at java.awt.Button.<init>(Button.java:152)
        at ij.gui.GenericDialog.<init>(GenericDialog.java:101)
        at ij.gui.GenericDialog.<init>(GenericDialog.java:91)
        at fiji.util.gui.GenericDialogPlus.<init>(GenericDialogPlus.java:72)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.GenericLoadParseQueryXML.queryXML(GenericLoadParseQueryXML.java:265)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:118)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:109)
        at net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML.queryXML(LoadParseQueryXML.java:58)
        at net.preibisch.mvrecon.fiji.plugin.Image_Fusion.run(Image_Fusion.java:86)
        at ij.IJ.runUserPlugIn(IJ.java:235)
        at ij.IJ.runPlugIn(IJ.java:198)
        at ij.Executer.runCommand(Executer.java:150)
        at ij.Executer.run(Executer.java:68)
        at ij.IJ.run(IJ.java:317)
        at ij.IJ.run(IJ.java:328)
        at ij.macro.Functions.doRun(Functions.java:686)
        at ij.macro.Functions.doFunction(Functions.java:98)
        at ij.macro.Interpreter.doStatement(Interpreter.java:278)
        at ij.macro.Interpreter.doStatements(Interpreter.java:264)
        at ij.macro.Interpreter.run(Interpreter.java:160)
        at ij.macro.Interpreter.run(Interpreter.java:93)
        at ij.macro.Interpreter.run(Interpreter.java:104)
        at ij.plugin.Macro_Runner.runMacro(Macro_Runner.java:161)
        at ij.IJ.runMacro(IJ.java:153)
        at ij.IJ.runMacro(IJ.java:142)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1148)
        at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1144)
        at net.imagej.legacy.IJ1Helper.runMacroFriendly(IJ1Helper.java:1095)
        at net.imagej.legacy.IJ1Helper.runMacro(IJ1Helper.java:1144)
        at net.imagej.legacy.plugin.IJ1MacroEngine.eval(IJ1MacroEngine.java:145)
        at org.scijava.script.ScriptModule.run(ScriptModule.java:160)
        at org.scijava.module.ModuleRunner.run(ModuleRunner.java:168)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
        at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:228)
        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)

Using multiview-reconstruction version: 0.7.2
0.001033 min
1 Like

It looks like there is nothing more I can do. @ctrueden needs to look into this problem. Have you tried running BigSticher from the command line without the --headless option?

2 Likes

I actually did not think about that! I can confirm that it works and I can use it as a workaround for the time being :slight_smile:

Ultimately I think it would be beneficial to get the actual headless mode working, but already this workaround is very useful for me!

Thank you for the support!

TL;DR: @CellKai can you try running with ij.jar at version 1.51n and see if that works?


Some explanations:

Because GenericDialog extends java.awt.Dialog, it is incompatible with Java’s headless mode (no Java AWT class will work headless). Since most ImageJ 1.x plugins built on GenericDialog for user input (yes, even a modern project like #bigstitcher is built on ImageJ1 :exclamation: ), this makes those plugins not work headlessly in general.

It is one of the great achievements of Fiji that it makes stuff that was built on ImageJ 1.x “just work” in headless mode (thanks to all the work of Johannes Schindelin years ago).

The code that patches GenericDialog to stop extending a Java AWT class (by replacing its superclass and doing quite some other hacks) lives in the ij1-patcher repository:

It turns out that current versions of Fiji (still) ship ij1-patcher-0.12.9, which was built against ij.jar at version 1.51n.

Since then, some backwards-incompatible implementation changes were introduced into the ImageJ1.x code base, and accounting for these in the ij1-patcher project got out-of-sync for some months (or even years now?).

Just recently, we fixed a few issues that made the builds of ij1-patcher fail:

So with the next update of Fiji, you’ll hopefully see ij1-patcher-1.1.0, and with it full compatibility for ij.jar versions up to 1.53b.

In the meantime, please try if your command line call works with ij.jar-1.51n; or even better: replace jars/ij1-patcher-0.12.9.jar with ij1-patcher-1.1.0.jar and use ij-1.53b.jar.

In both cases, please report here how it is going for you :slight_smile:

1 Like

Hi @imagejan ,

thank you very much for the help and explanation!

In the meantime, I switched the ij-macro mentioned in the first post to python but I can confirm that its working fine without headless.
I then tried tried both,

  • just ij.jar-1.51n resulted in a couple of similar exceptions (sorry it was a long printout and I did not write it down, but I am pretty sure it was something along the lines of java.awt.Dialog , which mentioned the GUI again), but I think it ignored the errors and moved on

  • using ij1-patcher-1.1.0.jar and ij-1.53b.jar instead. did not raise any errors

  • ultimately though, both approaches failed at the last line eval("script", "System.exit(0);");

[ERROR] Traceback (most recent call last):
  File "zeiss-lightsheet-bigstitcher.py", line 53, in <module>
    eval("script", "System.exit(0);")
TypeError: globals must be a mapping

        at org.python.core.Py.TypeError(Py.java:265)
        at org.python.core.__builtin__.verify_mappings(__builtin__.java:478)
        at org.python.core.__builtin__.eval(__builtin__.java:486)
        at org.python.core.__builtin__.eval(__builtin__.java:501)
        at org.python.core.BuiltinFunctions.__call__(__builtin__.java:142)
        at org.python.core.PyObject.__call__(PyObject.java:501)
        at org.python.pycode._pyx0.f$0(zeiss-lightsheet-bigstitcher.py:92)
        at org.python.pycode._pyx0.call_function(zeiss-lightsheet-bigstitcher.py)
        at org.python.core.PyTableCode.call(PyTableCode.java:171)
        at org.python.core.PyCode.call(PyCode.java:18)
        at org.python.core.Py.runCode(Py.java:1614)
        at org.python.core.__builtin__.eval(__builtin__.java:497)
        at org.python.core.__builtin__.eval(__builtin__.java:501)
        at org.python.util.PythonInterpreter.eval(PythonInterpreter.java:259)
        at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:57)
        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:160)
        at org.scijava.module.ModuleRunner.run(ModuleRunner.java:168)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
        at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:228)
        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)
  • II also tried swapping it withIJ.run("Quit") instead, but I realized that this command is ignored in headless.

Still, I believe that I need to properly exit IJ after running the headless script. How can I do that?

Are you trying to run this as a Python command? eval is a macro function, as far as I can tell.

If you run a python script and use the --ij2 and --headless flags, I don’t think you’ll need to explicitly exit ImageJ. But I might be wrong. Did you test it?

I am using a python wrapper script to subsequently execute on the command prompt (Windows 10):

  1. a IJ-python script that drives BigStitcher to stitch an fuse a dataset, and then
  2. the imaris fileconverter.exe to convert the resulting file to *.ims

here is the wrapper script:

import os
import subprocess
import time

# get start time
execution_start_time = time.time()

# paramters for running BigStitcher
imagej_location = "C:/Tools/Fiji.app-bigstitcher/"
bigstitcher_script = "zeiss-lightsheet-bigstitcher.py"
input_path = "'D:/Kai/LS-tests/E16_mcherry/E16_mcherry.czi'"
downsampling = "'8'" # has to be an integer

# parameters fro imaris file converter
imaris_fileconverter_location = "C:/Program Files/Bitplane/Imaris x64 9.5.1/"
#TODO: check if its exist, if no, check if just the converter exists, if no, set conversion to False
convert_to_imaris = True
export_path_fused = "D:/Kai/LS-tests/E16_mcherry/E16_mcherry_fused.xml"

# run commands on command promt
os.chdir(imagej_location)
command = 'ImageJ-win64 --ij2 --headless --console --run "%s" "input_path=%s, downsampling=%s"' % (
    bigstitcher_script,
    input_path,
    downsampling
)
print("\n\n%s" % command)
subprocess.call(command, shell=True)

if convert_to_imaris == True:
    os.chdir(imaris_fileconverter_location)
    command = 'ImarisConvert.exe -if BigDataViewer -i "%s" -of Imaris5 -o "%s"' % (
        export_path_fused,
        export_path_fused.replace("xml","ims")
    )
    print("\n\n%s" % command)
    subprocess.call(command, shell=True)

# time the script
total_execution_time_min = (time.time() - execution_start_time) / 60.0
print("total time in min " + str(total_execution_time_min))
  • when I run the IJ script WITHOUT--headless and IJ.run("Quit") at the end of the 1) script, then both tasks are executed properly
  • when I run the IJ script WITH--headless and WITHOUT IJ.run("Quit") at the end of the 1) script, the 1) till task finishes properly and writes a fused image file, but the 2) task fails with an exception:
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: sun.java2d.HeadlessGraphicsEnvironment cannot be cast to sun.awt.Win32GraphicsEnvironment
        at sun.awt.windows.WToolkit$3.run(WToolkit.java:840)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
        at java.awt.EventQueue.access$500(EventQueue.java:97)
        at java.awt.EventQueue$3.run(EventQueue.java:709)
        at java.awt.EventQueue$3.run(EventQueue.java:703)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

I hope the way I report this problem is not too confusing and vague. I really appreciate everyone’s help and time!

Two follow-up questions:

  • Is what you pasted above the entire error message you get? Or is there some continuation such as caused by... further down? If yes, this would certainly be useful to figure out what’s wrong.
  • Does this exception occur only in the absence of IJ.run("Quit"), or independent of its presence or absence?

good catch!
I missed some part of the error message. It continued, mentioning a timeout:

Traceback (most recent call last):
  File "zeiss-lightsheet-processing-wrapper.py", line 28, in <module>
    subprocess.call(command, shell=True)
  File "C:\Program Files\Anaconda\lib\subprocess.py", line 269, in call
    return p.wait(timeout=timeout)
  File "C:\Program Files\Anaconda\lib\subprocess.py", line 1055, in wait
    timeout_millis)

Its independent of its presence or absence. I did a test putting IJ.run("Quit") in the middle of script one and it just ignored.

My hunch is that IJ is still running, and either subprocess is waiting for it to terminate but this never happens, or the problem is that it did not release the file handle on the stitched image. Hence the fileconverter in step 2) can not convert it to *.ims