imagej / pyimagej

Use ImageJ from Python
https://pyimagej.readthedocs.io/
Other
474 stars 83 forks source link

Open OME tiff hyperstacks with the bioformats plugin #249

Closed anntzer closed 1 year ago

anntzer commented 1 year ago

Currently, trying to open an ome tiff hyperstack with ij.io().open(...) incorrectly opens them as plain stacks. I guess this is essentially the same bug as the one reported at https://forum.image.sc/t/micromanager-ome-tiff-hyperstacks-opening-as-stacks-in-imagej/62145, but is it possible to configure pyimagej to use the bioformats opener plugin in that case? Thanks for your help.

ctrueden commented 1 year ago

@anntzer Are you using PyImageJ with Fiji? E.g. imagej.init('sc.fiji:fiji:2.9.0')? If so, then it should use Bio-Formats. With plain ImageJ2 (e.g. imagej.init() or imagej.init('2.9.0')), Bio-Formats will not be present in the environment.

anntzer commented 1 year ago

Thank you for pointing this out. To be honest I haven't actually managed to make imagej.init("sc.fiji:fiji") work (perhaps due to crossed openjdks) but imagej.init("/Applications/Fiji.app") does work (with an up to date fiji), so I hope the following is still valid. A next issue is that trying to open a multi-scene OME tiff, such as the plate reader data at https://docs.openmicroscopy.org/ome-model/6.0.0/ome-tiff/data.html#plate or the dataset at https://open.quiltdata.com/b/aics-modeling-packages-test-resources/tree/aicsimageio/test_resources/resources/variable_scene_shape_first_scene_pyramid.ome.tiff (initially from https://github.com/tlambert03/ome-types/issues/71) only returns the first scene; is there a way to get the following ones too?

ctrueden commented 1 year ago

@anntzer wrote:

only returns the first scene; is there a way to get the following ones too?

What command are you using to open the data? Using ij.io().open(...) or ij.scifio().datasetIO().open(...) is currently limited to the first dataset, but there is also ij.scifio().datasetIO().openAll(...) which returns datasets present. Another option is to record an invocation of the Bio-Formats Importer command in Fiji by using the macro recorder in JavaScript mode, then use that same API call in your Python program.

anntzer commented 1 year ago

Thanks for getting back to this. I was using open(). I've now given a quick try to openAll(), but that returns an ArrayList of length 1 despite the presence of multiple datasets. In any case I've moved to using tifffile+ome_types to open ome tiffs, so I don't really have an interest in this issue anymore; feel free to close it.

ctrueden commented 1 year ago

OK, thanks for the reply, @anntzer. I'm glad you found a solution! :+1: