• Home page
  • Login
  • Contact us
  • Repo
  1. Examples
  2. OME Zarr
  • Overview
    • TileDB-BioImaging
  • Examples
    • OME Tiff
    • OME Zarr
  • API Reference
    • Function reference

On this page

  • TileDB OME-Zarr Conversion
    • Convert OME-Zarr to TileDB Slide
    • Slide Group Contents
    • TileDB Slide Information
    • Reading Slide whole levels
    • Read a region of a level
    • Read level properties
  • Report an issue
  1. Examples
  2. OME Zarr

OME Zarr

Learn how to ingest and perform basic ML operations on the MNIST dense dataset.

TileDB OME-Zarr Conversion

import os
import cv2
import matplotlib.pylab as pylab
import tiledb


from tiledb.bioimg.converters.ome_zarr import OMEZarrConverter
from tiledb.bioimg.openslide import TileDBOpenSlide

Convert OME-Zarr to TileDB Slide

image_id = 0
src = f"../tests/data/CMU-1-Small-Region.ome.zarr/{image_id}"
dest = f"../tests/data/CMU-1-Small-Region.ome.zarr.{image_id}.tiledb"
if not os.path.exists(dest):
    OMEZarrConverter.to_tiledb(src, dest, level_min=0)

Slide Group Contents

a = tiledb.open(os.path.join(dest,"l_0.tdb"))
a.schema
Domain
Name Domain Tile Data Type Is Var-length Filters
C (0, 2) 3 uint32 False -
Y (0, 2966) 1024 uint32 False -
X (0, 2219) 1024 uint32 False -
Attributes
Name Data Type Is Var-Len Is Nullable Filters
intensity uint8 False False
Name Option Level
ZstdFilter level 0
Cell Order
row-major
Tile Order
row-major
Capacity
10000
Sparse
False

TileDB Slide Information

slide = TileDBOpenSlide(dest)
print("level_count:", slide.level_count)
print("dimensions:", slide.dimensions)
print("level_dimensions:", slide.level_dimensions)
print("level_downsamples:", slide.level_downsamples)
print("levels:", slide.levels)
print("group_properties:", slide.properties)
level_count: 2
dimensions: (2220, 2967)
level_dimensions: ((2220, 2967), (574, 768))
level_downsamples: (1.0, 3.865438534407666)
levels: (0, 1)
group_properties: {'axes': 'TCZYX', 'channels': '["Channel 0", "Channel 1", "Channel 2"]', 'dataset_type': 'BIOIMG', 'fmt_version': 1, 'json_zarrwriter_kwargs': '{"axes": [{"name": "t", "type": "time"}, {"name": "c", "type": "channel"}, {"name": "z", "type": "space"}, {"unit": "micrometer", "name": "y", "type": "space"}, {"unit": "micrometer", "name": "x", "type": "space"}], "coordinate_transformations": [[{"scale": [1.0, 1.0, 1.0, 0.499, 0.499], "type": "scale"}], [{"scale": [1.0, 1.0, 1.0, 0.998, 0.998], "type": "scale"}]], "name": "", "metadata": {"method": "loci.common.image.SimpleImageScaler", "version": "Bio-Formats 6.10.1"}, "omero": {"channels": [{"color": "FF0000", "coefficient": 1, "active": true, "label": "Channel 0", "window": {"min": 0.0, "max": 255.0, "start": 0.0, "end": 255.0}, "family": "linear", "inverted": false}, {"color": "00FF00", "coefficient": 1, "active": true, "label": "Channel 1", "window": {"min": 0.0, "max": 255.0, "start": 0.0, "end": 255.0}, "family": "linear", "inverted": false}, {"color": "0000FF", "coefficient": 1, "active": true, "label": "Channel 2", "window": {"min": 0.0, "max": 255.0, "start": 0.0, "end": 255.0}, "family": "linear", "inverted": false}], "rdefs": {"defaultT": 0, "model": "color", "defaultZ": 0}}}', 'levels': '[{"level": 0, "name": "l_0.tdb", "axes": "CYX", "shape": [3, 2967, 2220]}, {"level": 1, "name": "l_1.tdb", "axes": "CYX", "shape": [3, 768, 574]}]', 'pixel_depth': 1, 'pkg_version': '0.1.1.dev14+dirty'}

Reading Slide whole levels

img3d = slide.read_level(0)
norm_img3d = cv2.normalize(src=img3d, dst=None, alpha=0, beta=255, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_8U)
pylab.imshow(norm_img3d)

Read a region of a level

img3d = slide.read_region((200,200), 0, slide.dimensions)
norm_img3d = cv2.normalize(src=img3d, dst=None, alpha=0, beta=255, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_8U)
pylab.imshow(norm_img3d)

Read level properties

print(slide.level_properties(0))
{'json_zarray': '{"chunks": [1, 1, 1, 1024, 1024], "compressor": {"clevel": 5, "blocksize": 0, "shuffle": 1, "cname": "lz4", "id": "blosc"}, "dtype": "|u1", "fill_value": 0, "filters": null, "order": "C", "shape": [1, 3, 1, 2967, 2220], "dimension_separator": "/", "zarr_format": 2}', 'level': 0}
OME Tiff
Function reference
  • Report an issue