ImageJ headless runmacrofile 'there are no images open' error

I am using jython to batch process some OME tiffs that I open with bio-formats in headless mode using the following code:

from loci.plugins import BF
            file = fin_fus
            imp = BF.openImagePlus(file)
            IJ.saveAs("tiff", sav_dir_fu)
            IJ.open(sav_dir_fu)
            IJ.runMacroFile(lord_s_path + "\FinalMacro.ijm")
            IJ.saveAs(imp, "tiff", sav_dir_pro)
            print("Processing successful")
            IJ.run("Close All")

For whatever reason I get the following from powershell:

Populating metadata
Checking comment style
Populating OME metadata
There are no images open.

The opening process clearly seems to work but then the following attempt to run the macrofile on this opened tiff does not work. Can anybody explain why?

Thanks in advance.

What is it you are trying to do in your macro? I suggest checking each of the operations in the macro to make sure they can run in headless mode. I know it isn’t the same but I have had issues with some plugins not being compatible with batchmode. I am guessing the same may be true for headless mode as well.

Thanks for the reply. I saw a few issues in this code and might repost as a new topic as I am trying another strategy now. In brief I am now trying to pass a path to a tiff file from python to the macro with the following code:

    for file in os.listdir(aurox_dir_path):
        if file.endswith('used.tiff'):
            lord_s = "\lord-stitchener"
            lord_s_path = root_dir_path + lord_s
            print(lord_s_path)
            prefix = os.path.basename(aurox_dir_path)
            fu_tiffs_file, pro_tiffs_file = create_directory(aurox_dir_path)
            sav_dir_pro = os.path.join(pro_tiffs_file, prefix)
            fin_fus = os.path.join(aurox_dir_path, file)
            print(fin_fus)
            fin_fus_two = fin_fus.replace("\\", "/")
            IJ.runMacroFile(lord_s_path + "\FinalMacro.ijm", fin_fus_two)
            IJ.saveAs("tiff", sav_dir_pro)
            print("Processing successful")
            IJ.run("Close All")

Whilst the macro recieves the argument fine using the getArgument() function, it doesn’t seem to be able to open the path with bioformats using headless mode. When I run the macro and simply type the path variable within the macro it works fine. You might be right then that this is just an issue with running in headless mode. Is there a way around this?
For more info here is the relevant part of the macro:

path = getArgument()
print(path)
run("Bio-Formats Importer", "open=" +path+ " autoscale color_mode=Composite display_ome-xml rois_import=[ROI manager] view=Hyperstack stack_order=XYCZT");

From the output you posted below it would seem that the Bio-Formats Importer has at least received the file path correctly and begun reading the file OK.

Populating metadata
Checking comment style
Populating OME metadata
There are no images open.

It may be worth attempting to do the import and export step similar to the headless code in Strange Issue with using BioFormats from python script in headless mode only, but that probably depends on what all is included in the macro taht you are running. Are you able to share the macro at all?

Thanks for the reply.
Sure here is the macro:

path = getArgument()
print(path)
run("Bio-Formats Importer", "open=" +path+ " autoscale color_mode=Composite display_ome-xml rois_import=[ROI manager] view=Hyperstack stack_order=XYCZT");

getDimensions(width, height, channels, slices, frames)
s_no = slices 
ch_no = channels

if (ch_no == 4) {
print("performing 4ch macro");
Stack.setDisplayMode("color");
Stack.setChannel(1);
run("Red");
Stack.setChannel(2);
run("Green");
Stack.setChannel(3);
run("Magenta");
Stack.setChannel(4);
run("Cyan");
//run("Brightness/Contrast...");
//run("Channels Tool...");
Stack.setChannel(1);
run("Enhance Contrast", "saturated=0.35");
Stack.setChannel(2);
run("Enhance Contrast", "saturated=0.35");
Stack.setChannel(3);
run("Enhance Contrast", "saturated=0.35");
Stack.setChannel(4);
run("Enhance Contrast", "saturated=0.35");
run("Rotate 90 Degrees Right");
run("Properties...", "channels=4 slices="+s_no+" frames=1 unit=um pixel_width=0.3250000 pixel_height=0.3250000 voxel_depth=3.4000000");
}

if (ch_no == 3){

Stack.setDisplayMode("color");
Stack.setChannel(1);
run("Red");
Stack.setChannel(2);
run("Green");
Stack.setChannel(3);
run("Cyan");
//run("Brightness/Contrast...");
//run("Channels Tool...");
Stack.setChannel(1);
run("Enhance Contrast", "saturated=0.35");
Stack.setChannel(2);
run("Enhance Contrast", "saturated=0.35");
Stack.setChannel(3);
run("Enhance Contrast", "saturated=0.35");
run("Rotate 90 Degrees Right");
run("Properties...", "channels=3 slices="+s_no+" frames=1 unit=um pixel_width=0.3250000 pixel_height=0.3250000 voxel_depth=3.4000000");
}
if (ch_no == 2) {
print("performing 2ch macro");

Stack.setDisplayMode("color");
Stack.setChannel(1);
run("Red");
Stack.setChannel(2);
run("Green");
//run("Brightness/Contrast...");
//run("Channels Tool...");
Stack.setChannel(1);
run("Enhance Contrast", "saturated=0.35");
Stack.setChannel(2);
run("Enhance Contrast", "saturated=0.35");
run("Rotate 90 Degrees Right");
run("Properties...", "channels=2 slices="+s_no+" frames=1 unit=um pixel_width=0.3250000 pixel_height=0.3250000 voxel_depth=3.4000000");
}
if (ch_no == 1){
print("performing 1ch macro");

Stack.setDisplayMode("color");
Stack.setChannel(1);
run("Red");
//run("Brightness/Contrast...");
//run("Channels Tool...");
Stack.setChannel(1);
run("Enhance Contrast", "saturated=0.35");
run("Rotate 90 Degrees Right");
run("Properties...", "channels=1 slices="+s_no+" frames=1 unit=um pixel_width=0.3250000 pixel_height=0.3250000 voxel_depth=3.4000000");
}

print("macro process completed");

It finds the path fine and prints it but then it simply says there are no images open. I wonder if it has something to do with this?:

openImage

public static ImagePlus openImage(java.lang.String path)

Opens the specified file as a tiff, bmp, dicom, fits, pgm, gif, jpeg or text image and returns an ImagePlus object if successful. Calls HandleExtraFileTypes plugin if the file type is not recognised. Displays a file open dialog if ‘path’ is null or an empty string. Note that ‘path’ can also be a URL. Some reader plugins, including the Bio-Formats plugin, display the image and return null. Use IJ.open() to display a file open dialog box.

I tried to find something of a workaround. I used the macro extensions for the bio-formats plugin as follows:

path = getArgument()
run("Bio-Formats Macro Extensions");
Ext.openImagePlus(path)
iddy = getImageID()
Ext.setId(iddy)

It’s not pretty as it still gives exceptions as follows:

D://TEST//EAA_2019-12-04_143359//Fused.tiff
Reading IFDs
Populating metadata
Checking comment style
Populating OME metadata
java.lang.reflect.InvocationTargetException
        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 loci.plugins.macro.MacroFunctions.handleExtension(MacroFunctions.java:82)
        at ij.macro.ExtensionDescriptor.dispatch(ExtensionDescriptor.java:288)
        at ij.macro.Functions.doExt(Functions.java:4684)
        at ij.macro.Functions.getStringFunction(Functions.java:275)
        at ij.macro.Interpreter.getStringTerm(Interpreter.java:1335)
        at ij.macro.Interpreter.getString(Interpreter.java:1314)
        at ij.macro.Interpreter.doStatement(Interpreter.java:299)
        at ij.macro.Interpreter.doStatements(Interpreter.java:234)
        at ij.macro.Interpreter.run(Interpreter.java:117)
        at ij.macro.Interpreter.run(Interpreter.java:88)
        at ij.macro.Interpreter.run(Interpreter.java:99)
        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:152)
        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 org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:188)
        at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:206)
        at org.python.core.PyObject.__call__(PyObject.java:497)
        at org.python.core.PyObject.__call__(PyObject.java:501)
        at org.python.pycode._pyx0.move_fused_tiffs$9(D:\TEST\lord-stitchener\v4-lord-s.py:168)
        at org.python.pycode._pyx0.call_function(D:\TEST\lord-stitchener\v4-lord-s.py)
        at org.python.core.PyTableCode.call(PyTableCode.java:171)
        at org.python.core.PyBaseCode.call(PyBaseCode.java:154)
        at org.python.core.PyFunction.__call__(PyFunction.java:423)
        at org.python.pycode._pyx0.process_aurox_image$12(D:\TEST\lord-stitchener\v4-lord-s.py:264)
        at org.python.pycode._pyx0.call_function(D:\TEST\lord-stitchener\v4-lord-s.py)
        at org.python.core.PyTableCode.call(PyTableCode.java:171)
        at org.python.core.PyBaseCode.call(PyBaseCode.java:171)
        at org.python.core.PyFunction.__call__(PyFunction.java:434)
        at org.python.pycode._pyx0.main$13(D:\TEST\lord-stitchener\v4-lord-s.py:271)
        at org.python.pycode._pyx0.call_function(D:\TEST\lord-stitchener\v4-lord-s.py)
        at org.python.core.PyTableCode.call(PyTableCode.java:171)
        at org.python.core.PyBaseCode.call(PyBaseCode.java:139)
        at org.python.core.PyFunction.__call__(PyFunction.java:413)
        at org.python.pycode._pyx0.f$0(D:\TEST\lord-stitchener\v4-lord-s.py:283)
        at org.python.pycode._pyx0.call_function(D:\TEST\lord-stitchener\v4-lord-s.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)
Caused by: java.io.FileNotFoundException: -3 (The system cannot find the file specified)
        at java.io.RandomAccessFile.open0(Native Method)
        at java.io.RandomAccessFile.open(RandomAccessFile.java:316)
        at java.io.RandomAccessFile.<init>(RandomAccessFile.java:243)
        at loci.common.NIOFileHandle.<init>(NIOFileHandle.java:130)
        at loci.common.NIOFileHandle.<init>(NIOFileHandle.java:151)
        at loci.common.NIOFileHandle.<init>(NIOFileHandle.java:165)
        at loci.common.Location.getHandle(Location.java:522)
        at loci.common.Location.getHandle(Location.java:462)
        at loci.common.Location.getHandle(Location.java:443)
        at loci.common.Location.getHandle(Location.java:426)
        at loci.common.Location.checkValidId(Location.java:551)
        at loci.formats.ImageReader.getReader(ImageReader.java:178)
        at loci.formats.ImageReader.setId(ImageReader.java:840)
        at loci.formats.ReaderWrapper.setId(ReaderWrapper.java:650)
        at loci.formats.ChannelSeparator.setId(ChannelSeparator.java:293)
        at loci.formats.ReaderWrapper.setId(ReaderWrapper.java:650)
        at loci.plugins.macro.LociFunctions.setId(LociFunctions.java:427)
        ... 61 more
Macro error
performing 4ch macro
macro process completed
Processing successful

But ultimately it somehow manages to get around the issue and selects the bio-formats opened image and runs the rest of the macro on it with expected outcome. However, then when it tries to move onto the next file it fails. It would be nice if there were some neater way around this that anybody happens to know?

Cheers for the input.

From the most recent stack trace it seems from the below error that it was unable to locate the file, if the file paths are hard coded do you still see the same issues?:

FileNotFoundException: -3 (The system cannot find the file specified)

Looking back on previous posts, is it possible this is just an issue with escaped characters? What OS are you using?

Good question, when I hard code the path it gives this for a single image:

java.lang.reflect.InvocationTargetException
        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 loci.plugins.macro.MacroFunctions.handleExtension(MacroFunctions.java:82)
        at ij.macro.ExtensionDescriptor.dispatch(ExtensionDescriptor.java:288)
        at ij.macro.Functions.doExt(Functions.java:4684)
        at ij.macro.Functions.getStringFunction(Functions.java:275)
        at ij.macro.Interpreter.getStringTerm(Interpreter.java:1335)
        at ij.macro.Interpreter.getString(Interpreter.java:1314)
        at ij.macro.Interpreter.doStatement(Interpreter.java:299)
        at ij.macro.Interpreter.doStatements(Interpreter.java:234)
        at ij.macro.Interpreter.run(Interpreter.java:117)
        at ij.macro.Interpreter.run(Interpreter.java:88)
        at ij.macro.Interpreter.run(Interpreter.java:99)
        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:152)
        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 org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:188)
        at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:206)
        at org.python.core.PyObject.__call__(PyObject.java:497)
        at org.python.core.PyObject.__call__(PyObject.java:501)
        at org.python.pycode._pyx0.move_fused_tiffs$9(D:\301019\lord-stitchener\v4-lord-s.py:168)
        at org.python.pycode._pyx0.call_function(D:\301019\lord-stitchener\v4-lord-s.py)
        at org.python.core.PyTableCode.call(PyTableCode.java:171)
        at org.python.core.PyBaseCode.call(PyBaseCode.java:154)
        at org.python.core.PyFunction.__call__(PyFunction.java:423)
        at org.python.pycode._pyx0.process_aurox_image$12(D:\301019\lord-stitchener\v4-lord-s.py:266)
        at org.python.pycode._pyx0.call_function(D:\301019\lord-stitchener\v4-lord-s.py)
        at org.python.core.PyTableCode.call(PyTableCode.java:171)
        at org.python.core.PyBaseCode.call(PyBaseCode.java:171)
        at org.python.core.PyFunction.__call__(PyFunction.java:434)
        at org.python.pycode._pyx0.main$13(D:\301019\lord-stitchener\v4-lord-s.py:273)
        at org.python.pycode._pyx0.call_function(D:\301019\lord-stitchener\v4-lord-s.py)
        at org.python.core.PyTableCode.call(PyTableCode.java:171)
        at org.python.core.PyBaseCode.call(PyBaseCode.java:139)
        at org.python.core.PyFunction.__call__(PyFunction.java:413)
        at org.python.pycode._pyx0.f$0(D:\301019\lord-stitchener\v4-lord-s.py:285)
        at org.python.pycode._pyx0.call_function(D:\301019\lord-stitchener\v4-lord-s.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)
Caused by: java.io.FileNotFoundException: -2 (The system cannot find the file specified)
        at java.io.RandomAccessFile.open0(Native Method)
        at java.io.RandomAccessFile.open(RandomAccessFile.java:316)
        at java.io.RandomAccessFile.<init>(RandomAccessFile.java:243)
        at loci.common.NIOFileHandle.<init>(NIOFileHandle.java:130)
        at loci.common.NIOFileHandle.<init>(NIOFileHandle.java:151)
        at loci.common.NIOFileHandle.<init>(NIOFileHandle.java:165)
        at loci.common.Location.getHandle(Location.java:522)
        at loci.common.Location.getHandle(Location.java:462)
        at loci.common.Location.getHandle(Location.java:443)
        at loci.common.Location.getHandle(Location.java:426)
        at loci.common.Location.checkValidId(Location.java:551)
        at loci.formats.ImageReader.getReader(ImageReader.java:178)
        at loci.formats.ImageReader.setId(ImageReader.java:840)
        at loci.formats.ReaderWrapper.setId(ReaderWrapper.java:650)
        at loci.formats.ChannelSeparator.setId(ChannelSeparator.java:293)
        at loci.formats.ReaderWrapper.setId(ReaderWrapper.java:650)
        at loci.plugins.macro.LociFunctions.setId(LociFunctions.java:427)
        ... 61 more
Macro error
performing 1ch macro
java.awt.HeadlessException
        at sun.awt.HeadlessToolkit.getSystemClipboard(HeadlessToolkit.java:309)
        at ij.macro.Interpreter.error(Interpreter.java:1212)
        at ij.macro.Functions.setDisplayMode(Functions.java:4945)
        at ij.macro.Functions.doStack(Functions.java:4835)
        at ij.macro.Functions.getFunctionValue(Functions.java:235)
        at ij.macro.Interpreter.getFactor(Interpreter.java:1427)
        at ij.macro.Interpreter.getTerm(Interpreter.java:1398)
        at ij.macro.Interpreter.getStringExpression(Interpreter.java:1538)
        at ij.macro.Interpreter.getStringTerm(Interpreter.java:1357)
        at ij.macro.Interpreter.getString(Interpreter.java:1314)
        at ij.macro.Interpreter.doStatement(Interpreter.java:299)
        at ij.macro.Interpreter.doBlock(Interpreter.java:631)
        at ij.macro.Interpreter.doStatement(Interpreter.java:290)
        at ij.macro.Interpreter.doIf(Interpreter.java:989)
        at ij.macro.Interpreter.doStatement(Interpreter.java:266)
        at ij.macro.Interpreter.doStatements(Interpreter.java:234)
        at ij.macro.Interpreter.run(Interpreter.java:117)
        at ij.macro.Interpreter.run(Interpreter.java:88)
        at ij.macro.Interpreter.run(Interpreter.java:99)
        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:152)
        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 org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:188)
        at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:206)
        at org.python.core.PyObject.__call__(PyObject.java:497)
        at org.python.core.PyObject.__call__(PyObject.java:501)
        at org.python.pycode._pyx0.move_fused_tiffs$9(D:\301019\lord-stitchener\v4-lord-s.py:168)
        at org.python.pycode._pyx0.call_function(D:\301019\lord-stitchener\v4-lord-s.py)
        at org.python.core.PyTableCode.call(PyTableCode.java:171)
        at org.python.core.PyBaseCode.call(PyBaseCode.java:154)
        at org.python.core.PyFunction.__call__(PyFunction.java:423)
        at org.python.pycode._pyx0.process_aurox_image$12(D:\301019\lord-stitchener\v4-lord-s.py:266)
        at org.python.pycode._pyx0.call_function(D:\301019\lord-stitchener\v4-lord-s.py)
        at org.python.core.PyTableCode.call(PyTableCode.java:171)
        at org.python.core.PyBaseCode.call(PyBaseCode.java:171)
        at org.python.core.PyFunction.__call__(PyFunction.java:434)
        at org.python.pycode._pyx0.main$13(D:\301019\lord-stitchener\v4-lord-s.py:273)
        at org.python.pycode._pyx0.call_function(D:\301019\lord-stitchener\v4-lord-s.py)
        at org.python.core.PyTableCode.call(PyTableCode.java:171)
        at org.python.core.PyBaseCode.call(PyBaseCode.java:139)
        at org.python.core.PyFunction.__call__(PyFunction.java:413)
        at org.python.pycode._pyx0.f$0(D:\301019\lord-stitchener\v4-lord-s.py:285)
        at org.python.pycode._pyx0.call_function(D:\301019\lord-stitchener\v4-lord-s.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)

There are no images open.

So it once again gives the 'There are no images open" error.

This was my first thought too so I did a replace of any backslashes for forward slash in the path:

fin_fus_two = fin_fus.replace("\\", "/")

This sadly doesn’t fix the issue. Windows 10 :grimacing:

Actually, I was thinking more of there not being enough backslashes rather then having to replace them with forward slashes. Last I checked, there are some functions in the macro language that reparse strings even if they are passed via a variable. However, taking another look at your error message, it doesn’t seem like this is the problem.

In case it wasn’t clear, I am talking about situations like the following.
Macro1

List.setList(getArguments());
print(List.get("hi"));
print(List.get("bye"));

Macro2

runMacro("Macro1", "hi=C:\\Users\\andrew\\Desktop\nbye=C:\\\\Users\\\\andrew\\\\Desktop");

Result of Macro2

C:UsersandrewDesktop
C:\Users\andrew\Desktop