ImageJ headless, bio-formats opening error

Sorry for reposting this as a new change but things changed since my last topic. In brief I am trying to pass a path of a tiff file from python to a 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
            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)
            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")
  "Close All")

Whilst the macro recieves the argument fine using the getArgument() function (as seen by accurate printing of the path), 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. Is this 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()
run("Bio-Formats Importer", "open=" +path+ " autoscale color_mode=Composite display_ome-xml rois_import=[ROI manager] view=Hyperstack stack_order=XYCZT");

Thanks in advance,


does you path have a bracket in the name “[” or “]” or other potential special characters? I’ve found a problem in imagej using bioformats where I am able to load an image through the GIU, but not via a script if there are brackets in the path. -John

Thanks for the reply. Only underscores ‘_’ and dashes ‘-’. Nothing apart from that so that doesn’t seem to be the issue. This is really perplexing me. Were you running bioformats headless? -Jack.

yes. under ubuntu linux. my python script looks like this:

from ij import IJ
imgPath = os.path.join(inputPath, fileName).replace("\","/")
print imgPath“Bio-Formats Importer”, “open=[”+imgPath+"] color_mode=Default rois_import=[ROI manager] view=Hyperstack stack_order=XYCZT series_3")

my images are pyramidal so here I’m picking the 3rd “series” or resolution to open. I see I have brackets in the run command (but none in my path!).

not sure if this is relevant, but I notice that this editor is not showing two back slashes in my .replace command. weird. I have to do a screenshot to show the two slashes:

Screen Shot 2020-03-10 at 10.19.49 AM

when I tried copying your command it has a mix of quotation symbol types.

replace("\", “/”)

Have you tried hardcoding the path to make sure it works and there’s no hidden funny business?
Try taking out the dashes as well. underscores should be ok.