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?
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
In your code sample, you do not show how you set the tiledb_image_path.
I already have a local tiledb database and have figured out how to create stores with specific schemas and read and write from them. Trying to ingest/write some tiff images, store pre-made ids and names for each image, then read them back out…
Hi @Tim_Turner,
tiledb_image_path
in my example is just a path to a local image represented as a TileDB Group (containing arrays) written to disk. This could be something like tiledb_image_path = 'tiledb_images/my_local_bioimage'
or a AWS S3 URI. This is the constructor you would use once you have converted your tiff images into a TileDB arrays and want to interact with them.
Stepping back a step, if you’d like to convert your TIFF images into TileDB arrays see these examples.
Generally the flow for our tiledb-bioimg
API is first convert your raw images via one of our converters and then direct the TileDBOpenSlide
constructor to the URIs where those images were ingested. From there you can call various methods to query regions etc.
Let me know if this sparks any additional questions,
Spencer
TileDB Team
Thanks I will be digging into this this evening and rest of the week…will let you know if I have questions.