Getting index to retrieve image

I am trying to understand what is returned when I write/ingest image into tiledb. The docs say an index is not returned.

In this tiledb cloud ingestion example it also doesn’t return anything. How do I retrieve it later?

Hey @Tim_Turner,

Thank you for the question!

Across TileDB language and domain-specific APIs (such as tiledb.bioimg), TileDB asset creations write to a specified URI. That URI is environment agnostic, so the URI could point to your local, a cloud object store, or your TileDB Cloud account. The return is usually NoneType and the contents exist on disk at the requested destination.

To subsequently view the contents of the TileDB array(s) you just ingested, you would open up that array and view it. In Python, you can do this via tiledb or tiledb.bioimg. You can also view the contents in TileDB Cloud if you have signed up for an account there.

Think of the writing as an ingestion into a database on disk. That is a process of its own and in many cases a separate task from the actual viewing/analysis.

In your particular case, assuming you’ve written your image into a TileDB array on your local, retrieve it via:

from tiledb.bioimg.openslide import TileDBOpenSlide

# Construct OpenSlide API wrapper
img = TileDBOpenSlide(tiledb_image_path)

# Read image data at `level`
#   from starting `(x0,y0)` location to
#   `(x + size_x, y + size_y)`
# Returns NumPy array
data = img.read_level((x0, y0), level, (size_x, size_y))

# when done
img.close()

Because these assets are TileDB arrays and TileDB groups, you can alse use the open-source tiledb API to view particular arrays that constitute your ingested image!
https://docs.tiledb.com/main/how-to/arrays/reading-arrays/reading-the-array-schema

Let me know if you have any other questions!
Spencer

1 Like