Using Bio-Formats in Python

OME does not currently provide a Python implementation for Bio-Formats. However, there are several options you can use to read images from Python via Bio-Formats:

AICSImageIO

The AICSImageIO project includes support for Bio-Formats:

from aicsimageio import AICSImage
cells = AICSImage('/path/to/my/cells.ome.tif')

import napari
napari.view_image(cells.xarray_data)
napari.run()

PyImageJ

The PyImageJ project enables use of ImageJ2, which includes the SCIFIO library, which wraps Bio-Formats. In this way, you can open Bio-Formats-supported formats as NumPy arrays:

import imagej
ij = imagej.init('sc.fiji:fiji')
jcells = ij.io().open('/path/to/my/cells.ome.tif')
cells = ij.py.from_java(jcells)

import napari
napari.view_image(cells)
napari.run()

python-bioformats

The CellProfiler project has implemented a Python wrapper around Bio-Formats used by the CellProfiler software which can be installed using pip:

pip install python-bioformats

See also

https://pypi.org/project/python-bioformats

Source code of the CellProfiler Python wrapper for Bio-Formats