Bio-Formats Exporter strangeness

We have some scripts that export libraries of images to TIFF using Bio-Formats. There’s a strange behaviour of the Bio-Formats Exporter that I don’t understand. Essentially, hyperstacks have reduced dimensions on re-opening. It seems like the header of an OME.TIFF which is written using the exporter is not understood by the open command in Fiji. Bio-Formats Import of the same image works OK. Saving the same image or exporting with a .tif extension works OK. I can work around this, but it seems strange that OME.TIFF doesn’t work as expected.

Here is a mwe

run("Bio-Formats Macro Extensions");
dir = getDirectory("home") + File.separator + "Desktop";
print("\\Clear");

newImage("HyperStack", "8-bit composite-mode label", 500, 500, 4, 3, 1);
saveAs("Tiff", dir + File.separator + "theSaveAsHyperstack.tif");
close();

newImage("HyperStack", "8-bit composite-mode label", 500, 500, 4, 3, 1);
run("Bio-Formats Exporter", "save=[" + dir + File.separator + "bioFormatsExp.tif] export compression=Uncompressed");
close();

newImage("HyperStack", "8-bit composite-mode label", 500, 500, 4, 3, 1);
run("Bio-Formats Exporter", "save=[" + dir + File.separator + "bioFormatsExp.ome.tiff] export compression=Uncompressed");
close();

print("original hyperstack was: 500, 500, 4, 3, 1");
// open the save as version
open(dir + File.separator + "theSaveAsHyperstack.tif");
getDimensions(width, height, channels, slices, frames);
title = getTitle();
close();
print(title, width, height, channels, slices, frames);

// open bioformats export .tif version
open(dir + File.separator + "bioFormatsExp.tif");
getDimensions(width, height, channels, slices, frames);
title = getTitle();
close();
print(title, width, height, channels, slices, frames);

// open bioformats export ome.tiff version
open(dir + File.separator + "bioFormatsExp.ome.tiff");
getDimensions(width, height, channels, slices, frames);
title = getTitle();
close();
print(title, width, height, channels, slices, frames);

This gives (on my machine):

original hyperstack was: 500, 500, 4, 3, 1
theSaveAsHyperstack.tif 500 500 4 3 1
bioFormatsExp.tif 500 500 4 3 1
bioFormatsExp.ome.tiff 500 500 1 12 1

(Fiji Is Just) ImageJ 2.0.0-rc-69/1.52p; Java 1.8.0_231 [64-bit]; Mac OS X 10.15.3; 68MB of 13040MB (<1%)

Hi @quantixed, using your script I was unable to reproduce the issue with the latest Bio-Formats (6.3.1). Do you know what version you are using? (can be found in Help > About Plugins > Bio-Formats Plusins)

Hi @dgault, thanks for the reply. I just downloaded Fiji fresh and updated. It is running Bio-Formats 6.3.1. I get the same result. The final line of the log reads
bioFormatsExp.ome.tiff 500 500 1 12 1
Does yours read:
bioFormatsExp.ome.tiff 500 500 4 3 1 ?

Yeah the log Im seeing gives:

original hyperstack was: 500, 500, 4, 3, 1
theSaveAsHyperstack.tif 500 500 4 3 1
bioFormatsExp.tif 500 500 4 3 1
bioFormatsExp.ome.tiff 500 500 4 3 1

If you open the saved OME TIFF after does it appear to have 12 timepoints and only 1 Z and 1 channel?

Yes, if I open with Drag/Drop or File Open, I get 12 slices. The scaling is in cm also. With Bio-Formats Importer it opens correctly. It’s weird that you are not seeing the same thing.

I found this old comment which chimes with what I’m seeing:

Ok, that makes sense, the standard File > Open will not be reading the OME-XML and will try and interpret it as a standard TIFF image. The reason it worked for me is that I have the option set to open with SCIFIO (Edit > Options > ImageJ2 > Use SCIFIO when opening files). So either importing with Bio-Formats, using this option as above or simply exporting the hyperstack as TIFF should work.

1 Like

Thanks for confirming. Yes, I can definitely workaround it but I wonder why it doesn’t work out-of-the-box. If Bio-Formats and OME are part of the Fiji package, shouldn’t Fiji read the OME-XML natively?

It will use Bio-Formats to read most formats by default but will try to use built-in logic to open TIFF files. So for some TIFF based formats you may need to to use the Bio-Formats importer.