OME-Zarr Creation¶
This is a minimal example of how to create an OME-Zarr image using ngio
.
This example is just a simple demonstration but for more complex conversion tasks please refer to the converter tooling library ome-zarr-converters-tools.
Let's start by converting a sample image from skimage
to OME-Zarr format.
In [1]:
Copied!
import skimage
from matplotlib import pyplot as plt
plt.imshow(skimage.data.human_mitosis(), cmap="gray")
plt.axis("off")
plt.show()
import skimage
from matplotlib import pyplot as plt
plt.imshow(skimage.data.human_mitosis(), cmap="gray")
plt.axis("off")
plt.show()
Downloading file 'data/mitosis.tif' from 'https://gitlab.com/scikit-image/data/-/raw/2cdc5ce89b334d28f06a58c9f0ca21aa6992a5ba/AS_09125_050116030001_D03f00d0.tif' to '/home/runner/.cache/scikit-image/0.25.2'.
In [2]:
Copied!
from ngio import create_ome_zarr_from_array
ome_zarr = create_ome_zarr_from_array(
store="./data/human_mitosis.zarr",
array=skimage.data.human_mitosis(),
xy_pixelsize=0.1, # Just a guess
)
ome_zarr
from ngio import create_ome_zarr_from_array
ome_zarr = create_ome_zarr_from_array(
store="./data/human_mitosis.zarr",
array=skimage.data.human_mitosis(),
xy_pixelsize=0.1, # Just a guess
)
ome_zarr
Out[2]:
OmeZarrContainer(levels=5)
Adding Rois to OME-Zarr¶
Often, is useful to add ROIs to OME-Zarr images to be able to retrieve them later.
This can be done using the ngio
library as follows.
In [3]:
Copied!
# create a roi for the whole image
roi_table = ome_zarr.build_image_roi_table(name="image_roi")
ome_zarr.add_table("image_roi_table", roi_table)
# create a roi for the whole image
roi_table = ome_zarr.build_image_roi_table(name="image_roi")
ome_zarr.add_table("image_roi_table", roi_table)