We're Hiring!

reading metadata from python script

Historical discussions about the Bio-Formats library. Please look for and ask new questions at https://forum.image.sc/tags/bio-formats
Please note:
Historical discussions about the Bio-Formats library. Please look for and ask new questions at https://forum.image.sc/tags/bio-formats

If you are having trouble with image files, there is information about reporting bugs in the Bio-Formats documentation. Please send us the data and let us know what version of Bio-Formats you are using. For issues with your code, please provide a link to a public repository, ideally GitHub.

reading metadata from python script

Postby phm » Wed Mar 30, 2016 9:42 am

Hi,

Is there a way to read metada using bioformat api from python script ? Should I go through pyhton-bioformat library from cell profiler ???

Thanks

Philippe
phm
 
Posts: 185
Joined: Tue Mar 19, 2013 3:39 pm

Re: reading metadata from python script

Postby cblackburn » Thu Mar 31, 2016 10:54 am

Hi Philippe,

The python-bioformats library from CellProfiler is the way to go. Once installed you should be able to do something like this:

Code: Select all
>>> import javabridge as jv
>>> import bioformats as bf
>>> from xml.etree import ElementTree as et
>>> jv.start_vm(class_path=bf.JARS, max_heap_size='8G')
>>> md = bf.get_omexml_metadata('CFPNEAT01_R3D.dv')
>>> mdroot = et.fromstring(md.encode('utf-8'))
>>> len(mdroot)
3
>>> for a in mdroot[1]:
...     print((a.tag, a.attrib))
...
('{http://www.openmicroscopy.org/Schemas/OME/2013-06}AcquisitionDate', {})
('{http://www.openmicroscopy.org/Schemas/OME/2013-06}InstrumentRef', {'ID': 'Instrument:0'})
('{http://www.openmicroscopy.org/Schemas/OME/2013-06}ObjectiveSettings', {'ID': 'Objective:12404'})
('{http://www.openmicroscopy.org/Schemas/OME/2013-06}Pixels', {'SizeT': '1', 'DimensionOrder': 'XYZCT', 'PhysicalSizeY': '0.1269800066947937', 'PhysicalSizeX': '0.1269800066947937', 'PhysicalSizeZ': '0.20000000298023224', 'SizeX': '512', 'SizeY': '512', 'SizeZ': '29', 'BigEndian': 'false', 'Interleaved': 'false', 'SizeC': '2', 'Type': 'uint16', 'ID': 'Pixels:0', 'SignificantBits': '16'})
>>> jv.kill_vm()


As you'll no doubt know, but for the benefit of others, the library can be installed using pip:

Code: Select all
pip install python-bioformats


The source is at https://github.com/CellProfiler/python-bioformats and there is some documentation at http://pythonhosted.org/python-bioformats/

Cheers,

Colin
cblackburn
 
Posts: 85
Joined: Mon May 25, 2009 9:03 pm


Return to User Discussion [Legacy]

Who is online

Users browsing this forum: Google [Bot] and 1 guest