Browsing the Open Microscopy Image Data Resource with Python#

Robert Haase, June 6th 2021; Marcelo Zoccoler, updated on December 10th 2021

The Image Data Resource (IDR) is an online database of microscopy research image data where scientist can publish their data if it is part of a scientific publication. It is a fantastic resource not just for biologists searching for images of samples they are interested in. It is also a fantastic source of data for image data scientists who develop new algorithms. For automated access of the underlying data base, an application programming interface (API) is accessible via python allowing you to programmatically browse the database, search for images with certain properties and download them for dedicated image analysis. For downloading images from the IDR, you only need a link, e.g. for requesting the data in tif format. You can then use scikit-image to open the image. In this blog post we show how to browse the IDR programmatically in Python. The procedures shown here will also work with your local Omero installation if you have one.

Some of the code examples shown below were adapted from the IDR API website licensed by the University of Dundee & Open Microscopy Environment under the Creative Commons Attribution 4.0 International License.

In the following example, we download image data from Stojic et al shared under the CC BY 4.0 license available from the IDR. See also the related publication.

Downloading a single image#

On the IDR website, we can navigate inside the screen dataset and click on images. After selecting an image, there will be download link in the top right corner. img_1.png

You can copy this link, change it a little and use it in your python code to download and show the image.

from skimage.io import imread, imshow

original_link = 'https://idr.openmicroscopy.org/webclient/render_image_download/9629351/?format=tif'
edited_link = 'https://idr.openmicroscopy.org/webclient/render_image/9629351/'

image = imread(edited_link)

imshow(image)

img_1.png

This also works from Google Colab.

img_2.png

Furthermore, you can assemble the link from a generic link if you know the image identifier of the image you want to download. You can see the identifier of the image on the bottom of your browser when hovering with the mouse over the download link:

img_3.png

Using pythons string format function, we can assemble a generic unified resource locator (URL) with the specific image identifier to a specific link:

generic_image_url = "https://idr.openmicroscopy.org/webclient/render_image/{image_id}/"
image_id = 9629351

# combine generic url with image ID
image_url = generic_image_url.format(**{"image_id":image_id})

# download and show image
image = imread(image_url)
imshow(image)