from tiledb.bioimg import Converters, from_bioimg
Biomedical Imaging Quickstart
This quickstart gives you a rapid introduction to TileDB-BioImaging and its capabilities. After completing this tutorial, you will learn how to do the following:
- Ingest a whole-slide image into TileDB.
- Read image data by slicing its slides.
- Visualize the images and their slides.
- Export the images back into other formats.
Prerequisites
Familiarize yourself with Jupyter notebooks to run data exploration and analysis efficiently. You can review Jupyter’s documentation on installing and running notebooks.
If running this tutorial locally, you’ll need to install the TileDB-BioImaging package and its dependencies. You can install them using pip
:
pip install 'tiledb-bioimg[full]'
If you’re running this tutorial through a TileDB workspace, you can skip the installation step as the packages you need are already installed as part of the Genomics image.
Setup
First, create a directory to store the files for this tutorial.
Ingestion
To get started with bio-images on TileDB, import the TileDB-BioImaging package. You will then have two alternative APIs to ingest your images into TileDB.
The first option is using Converters
:
from tiledb.bioimg.converters.ome_tiff import OMETiffConverter
The second option is using Wrappers
:
Both of these APIs offer similar functionality, with the latter being a wrapper of the former. The package supports converters for multiple source formats, and the TileDB team is continuously adding more. The following formats are currently supported:
- OpenSlide supported formats
- OME-TIFF
- OME-Zarr
- PNG
The Converters
enumeration gives a list of all the supported converters you can use for ingesting images. Each converter offers a function taking a source path and storage destination for the converted TileDB multi-resolution image group. To import and use each of the supported converters, you can choose between using each converter’s API directly like the following:
=0) OMETiffConverter.to_tiledb(src, dest, level_min
=0) OpenSlideConverter.to_tiledb(src, dest, level_min
=0) OMEZarrConverter.to_tiledb(src, dest, level_min
=0) PNGConverter.to_tiledb(src, dest, level_min
You can also use the wrappers’ API for a more concise view:
=0, converter=Converters.OMETIFF) from_bioimg(src, dest, level_min
=0, converter=Converters.OSD) from_tiledb(src, dest, level_min
=0, converter=Converters.OMEZARR) OMEZarrConverter.to_tiledb(src, dest, level_min
=0, Converters.PNG) PNGConverter.to_tiledb(src, dest, level_min
Use the Wrappers
API to ingest a sample image into TileDB. For this quickstart, you’ll use the OMETIFF
converter to ingest an OME-TIFF image.
Check out the tutorials section to learn about advanced ingestion configurations like Batch Ingestion and Chunked Ingestion.
Read data
You may read image data with the TileDB-Py API directly, or by using the OpenSlide Python-compatible API.
TileDB-Py API
For a more in-depth tutorial on using the TileDB-Py API to read TileDB-BioImaging data, check out the Read Biomedical Images with TileDB-Py tutorial.
OpenSlide Python API
Visit the OpenSlide Python API documentation for all available commands. For a more in-depth tutorial on using the OpenSlide Python API to read TileDB-BioImaging data, check out the Read Biomedical Images with OpenSlide tutorial.
Visualization
If you want to take advantage of TileDB’s built-in viewer, you can preview bioimaging assets within in the TileDB UI after registering them. You can always use other visualization tools like Pillow:
You can also use TileDB’s other integrations with famous rendering tools like napari, as shown in the napari tutorial.
Export to OME formats
The TileDB-BioImaging library offers a utility function to export a TileDB stored image to different OME formats.
Cleanup
Clean up in the end by removing the tutorial data.