Get metadata from WSI

I have a set of images from Aperio (svs) and Roche (bif) I would like to get all the metadata available.

Concretely I am mostly interested in the biopsy information that these WSI would bear. I am actually trying to deidentify them and I would check every possible field to be sure all the information has been removed.

For now, I am able to got the scanner information by doing something like:

import javabridge
import bioformats
import bioformats.formatreader as F
from bioformats import metadatatools

file = "LEICA/SVS/image1.svs"

ImageReader = F.make_image_reader_class()
reader = ImageReader()

omeMeta = bioformats.metadatatools.createOMEXMLMetadata()



If here I do reader.getMetadata(), it only prints something like <Java object at 0x4f656148>


@Joan_Gibert_Fernande I think the issue is that the getMetadata() API returns a java.util.HashTable object.

In order to consume it, you will need to convert it into a Python representation. Looking at the javabridge module which is used by python-bioformats for the Java-Python translation, I think the javabridge.jdictionary_to_string_dictionary utility method should achieve this. Can you try the following:

metadata = javabridge.jdictionary_to_string_dictionary(reader.getMetadata())

which should give you a Python dictionary that you can manipulate and introspect.

NB: The @CellProfilerTeam might want to complement my answer as they are the maintainers of the python-bioformats bridge.

1 Like