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