Searching or Changing OME data

If I ingest OME TIFF images into tiledb, is there a way to search the OME metadata directly? Or would I have to copy parts to “attributes” of the image in order to search it?

Similar question with changing the metadata… writing a new value to the OME metadata stored with the image… would I have to read out the image, change the metadata on my own, then write it back… or is there a more direct way to do it?

Hi Tim,
Great question! When you ingest OME-TIFF images into TileDB, the OME metadata is automatically captured and stored. We preserve this valuable information as a JSON string within the TileDB image group metadata, making it readily accessible for your needs. This means you can access and modify the metadata directly without needing to re-ingest the image.
Here’s a code snippet demonstrating how to access the metadata:

import tiledb
import json
from tiledb.bioimg.converters.ome_tiff import OMETiffConverter
from tiledb.bioimg.openslide import TileDBOpenSlide

src = "[your-ome-tiff-file.ome.tiff]"
dest = "[your-destination-file-path-for-tdb-image]"

OMETiffConverter.to_tiledb(src, dest, level_min=0)

# Access metadata using TileDB
with tiledb.Group(dest, 'r') as image_grp:
    original_meta = json.loads(image_grp.meta['original_metadata'])
    ome_meta = original_meta['ome_metadata']

# Or access metadata using TileDBOpenSlide
slide = TileDBOpenSlide(dest)
slide.properties
slide.properties['original_metadata']

# Modify metadata
with tiledb.Group(dest, 'w') as image_grp:
    image_grp.meta["original_metadata"] = 'modified_ome_metadata_value'

Feel free to adapt this code to your specific needs. If you have any further questions or a particular use case in mind, please don’t hesitate to share more details! I’m happy to help.

In your example, the src = line is pointing to the file on the hard drive? i.e. full file path to the file
And the dest is where it is being written into tiledb?

We are using another library called BFIO which lets us read the ome tiff and have it in memory. Would I just pass that variable as src or does the OMETiffCOnverter always read src from the hard drive.

I’m sure your OMETIffConverter works fine but we are integrating tiledb into an existing set of tools that uses our own file image reader and converter.

Currently, we support ingesting OME-TIFF files from the following sources:

  • Local files: Provide the path to your OME-TIFF file directly.
  • File-like objects: If your OME-TIFF data is accessible as a file-like object, you can also pass that directly to our ingestion function.

If you need to ingest OME-TIFF files from other sources, please get in touch at help@tiledb.com.

@ktsitsi Can you give me an example of passing a file-like object?