aicsimageio.vendor package

Submodules

aicsimageio.vendor.omexml module

omexml.py read and write OME xml

aicsimageio.vendor.omexml.DO_XYTZC = 'XYTZC'

IFD # 254

aicsimageio.vendor.omexml.MPI_CMYK = 'CMYK'

IFD # 263

class aicsimageio.vendor.omexml.OMEXML(xml=None, rootnode=None)[source]

Bases: object

Reads and writes OME-XML with methods to get and set it.

The OMEXML class has four main purposes: to parse OME-XML, to output OME-XML, to provide a structured mechanism for inspecting OME-XML and to let the caller create and modify OME-XML.

There are two ways to invoke the constructor. If you supply XML as a string or unicode string, the constructor will parse it and will use it as the base for any inspection and modification. If you don’t supply XML, you’ll get a bland OME-XML object which has a one-channel image. You can modify it programatically and get the modified OME-XML back out by calling to_xml.

There are two ways to get at the XML. The arduous way is to get the root_node of the DOM and explore it yourself using the DOM API (http://docs.python.org/library/xml.dom.html#module-xml.dom). The easy way, where it’s supported is to use properties on OMEXML and on some of its derived objects. For instance:

>>> o = OMEXML()
>>> print o.image().AcquisitionDate

will get you the date that image # 0 was acquired.

>>> o = OMEXML()
>>> o.image().Name = "MyImage"

will set the image name to “MyImage”.

You can add and remove objects using the “count” properties. Each of these handles hooking up and removing orphaned elements for you and should be less error prone than creating orphaned elements and attaching them. For instance, to create a three-color image:

>>> o = OMEXML()
>>> o.image().Pixels.channel_count = 3
>>> o.image().Pixels.Channel(0).Name = "Red"
>>> o.image().Pixels.Channel(1).Name = "Green"
>>> o.image().Pixels.Channel(2).Name = "Blue"

See the OME-XML schema documentation <http://git.openmicroscopy.org/src/develop/components/specification/Documentation/Generated/OME-2011-06/ome.html>.

class Channel(node)[source]

Bases: object

The OME/Image/Pixels/Channel element

property Color
property ID
property Name
property SamplesPerPixel
get_Color()[source]
get_ID()[source]
get_Name()[source]
get_SamplesPerPixel()[source]
set_Color(value)[source]
set_ID(value)[source]
set_Name(value)[source]
set_SamplesPerPixel(value)[source]
class Image(node)[source]

Bases: object

Representation of the OME/Image element

Initialize with the DOM Image node

property AcquisitionDate

The date in ISO-8601 format

property ID
property Name
property Pixels

The OME/Image/Pixels element.

Example: >>> md = bioformats.omexml.OMEXML(xml) >>> pixels = omemetadata.image(i).Pixels >>> channel_count = pixels.SizeC >>> stack_count = pixels.SizeZ >>> timepoint_count = pixels.SizeT

get_AcquisitionDate()[source]

The date in ISO-8601 format

get_ID()[source]
get_Name()[source]
set_AcquisitionDate(date)[source]
set_ID(value)[source]
set_Name(value)[source]
class OriginalMetadata(sa)[source]

Bases: dict

View original metadata as a dictionary

Original metadata holds “vendor-specific” metadata including TIFF tag values.

Initialized with the structured_annotations class instance

has_key(key)[source]
iteritems()[source]
keys() → a set-like object providing a view on D's keys[source]
class Pixels(node)[source]

Bases: object

The OME/Image/Pixels element

The Pixels element represents the pixels in an OME image and, for an OME-XML encoded image, will actually contain the base-64 encoded pixel data. It has the X, Y, Z, C, and T extents of the image and it specifies the channel interleaving and channel depth.

Channel(index=0)[source]

Get the indexed channel from the Pixels element

property DimensionOrder

The ordering of image planes in the file

A 5-letter code indicating the ordering of pixels, from the most rapidly varying to least. Use the DO_* constants (for instance DO_XYZCT) to compare and set this.

property ID
property PhysicalSizeX

The dimensions of the image in the X direction in physical units

property PhysicalSizeY

The dimensions of the image in the Y direction in physical units

property PhysicalSizeZ

The dimensions of the image in the Z direction in physical units

property PixelType

The pixel bit type, for instance PT_UINT8

The pixel type specifies the datatype used to encode pixels in the image data. You can use the PT_* constants to compare and set the pixel type.

Plane(index=0)[source]

Get the indexed plane from the Pixels element

property SizeC

The dimensions of the image in the C direction in pixels

property SizeT

The dimensions of the image in the T direction in pixels

property SizeX

The dimensions of the image in the X direction in pixels

property SizeY

The dimensions of the image in the Y direction in pixels

property SizeZ

The dimensions of the image in the Z direction in pixels

TiffData(index=0)[source]

Get the indexed TiffData from the Pixels element

append_channel(index, name)[source]
property channel_count

The number of channels in the image

You can change the number of channels in the image by setting the channel_count:

pixels.channel_count = 3 pixels.Channel(0).Name = “Red” …

get_DimensionOrder()[source]

The ordering of image planes in the file

A 5-letter code indicating the ordering of pixels, from the most rapidly varying to least. Use the DO_* constants (for instance DO_XYZCT) to compare and set this.

get_ID()[source]
get_PhysicalSizeX()[source]

The dimensions of the image in the X direction in physical units

get_PhysicalSizeY()[source]

The dimensions of the image in the Y direction in physical units

get_PhysicalSizeZ()[source]

The dimensions of the image in the Z direction in physical units

get_PixelType()[source]

The pixel bit type, for instance PT_UINT8

The pixel type specifies the datatype used to encode pixels in the image data. You can use the PT_* constants to compare and set the pixel type.

get_SizeC()[source]

The dimensions of the image in the C direction in pixels

get_SizeT()[source]

The dimensions of the image in the T direction in pixels

get_SizeX()[source]

The dimensions of the image in the X direction in pixels

get_SizeY()[source]

The dimensions of the image in the Y direction in pixels

get_SizeZ()[source]

The dimensions of the image in the Z direction in pixels

get_channel_count()[source]

The number of channels in the image

You can change the number of channels in the image by setting the channel_count:

pixels.channel_count = 3 pixels.Channel(0).Name = “Red” …

get_channel_names()[source]
get_plane_count()[source]

The number of planes in the image

An image with only one plane or an interleaved color plane will often not have any planes.

You can change the number of planes in the image by setting the plane_count:

pixels.plane_count = 3 pixels.Plane(0).TheZ=pixels.Plane(0).TheC=pixels.Plane(0).TheT=0 …

get_planes_of_channel(index)[source]
property plane_count

The number of planes in the image

An image with only one plane or an interleaved color plane will often not have any planes.

You can change the number of planes in the image by setting the plane_count:

pixels.plane_count = 3 pixels.Plane(0).TheZ=pixels.Plane(0).TheC=pixels.Plane(0).TheT=0 …

populate_TiffData()[source]

assuming Pixels has its sizes, set up tiffdata elements

remove_channel(index)[source]
set_DimensionOrder(value)[source]
set_ID(value)[source]
set_PhysicalSizeX(value)[source]
set_PhysicalSizeY(value)[source]
set_PhysicalSizeZ(value)[source]
set_PixelType(value)[source]
set_SizeC(value)[source]
set_SizeT(value)[source]
set_SizeX(value)[source]
set_SizeY(value)[source]
set_SizeZ(value)[source]
set_channel_count(value)[source]
set_plane_count(value)[source]
class Plane(node)[source]

Bases: object

The OME/Image/Pixels/Plane element

The Plane element represents one 2-dimensional image plane. It has the Z, C and T indices of the plane and optionally has the X, Y, Z, exposure time and a relative time delta.

property DeltaT

# of seconds since the beginning of the experiment

property ExposureTime

Units are seconds. Duration of acquisition????

property PositionX

X position of stage

property PositionY

Y position of stage

property PositionZ

Z position of stage

property TheC

The channel index of the plane

property TheT

The T index of the plane

property TheZ

The Z index of the plane

get_DeltaT()[source]

# of seconds since the beginning of the experiment

get_PositionX()[source]

X position of stage

get_PositionY()[source]

Y position of stage

get_PositionZ()[source]

Z position of stage

get_TheC()[source]

The channel index of the plane

get_TheT()[source]

The T index of the plane

get_TheZ()[source]

The Z index of the plane

set_DeltaT(value)[source]
set_PositionX(value)[source]
set_PositionY(value)[source]
set_PositionZ(value)[source]
set_TheC(value)[source]
set_TheT(value)[source]
set_TheZ(value)[source]
class Plate(node)[source]

Bases: object

The SPW:Plate element

This represents the plate element of the SPW schema: http://www.openmicroscopy.org/Schemas/SPW/2007-06/

property ColumnNamingConvention
property Columns
property Description
property ExternalIdentifier
property ID
property Name
property RowNamingConvention
property Rows
property Status
property Well

The well dictionary / list

property WellOriginX
property WellOriginY
get_ColumnNamingConvention()[source]
get_Columns()[source]
get_Description()[source]
get_ExternalIdentifier()[source]
get_ID()[source]
get_Name()[source]
get_RowNamingConvention()[source]
get_Rows()[source]
get_Status()[source]
get_Well()[source]

The well dictionary / list

get_WellOriginX()[source]
get_WellOriginY()[source]
get_well_name(well)[source]

Get a well’s name, using the row and column convention

set_ColumnNamingConvention(value)[source]
set_Columns(value)[source]
set_Description(text)[source]
set_ExternalIdentifier(value)[source]
set_ID(value)[source]
set_Name(value)[source]
set_RowNamingConvention(value)[source]
set_Rows(value)[source]
set_Status(value)[source]
set_WellOriginX(value)[source]
set_WellOriginY(value)[source]
class PlatesDucktype(root)[source]

Bases: object

It looks like a list of plates

newPlate(name, plate_id='ce25d2a3-3142-441a-aa3e-09ecd7fade1c')[source]
class StructuredAnnotations(node)[source]

Bases: dict

The OME/StructuredAnnotations element

Structured annotations let OME-XML represent metadata from other file formats, for example the tag metadata in TIFF files. The StructuredAnnotations element is a container for the structured annotations.

Images can have structured annotation references. These match to the IDs of structured annotations in the StructuredAnnotations element. You can get the structured annotations in an OME-XML document using a dictionary interface to StructuredAnnotations.

Pragmatically, TIFF tag metadata is stored as key/value pairs in OriginalMetadata annotations - in the context of CellProfiler, callers will be using these to read tag data that’s not represented in OME-XML such as the bits per sample and min and max sample values.

property OriginalMetadata
add_original_metadata(key, value)[source]

Create an original data key/value pair

key - the original metadata’s key name, for instance OM_PHOTOMETRIC_INTERPRETATION

value - the value, for instance, “RGB”

returns the ID for the structured annotation.

get_original_metadata_refs(ids)[source]

For a given ID, get the matching original metadata references

ids - collection of IDs to match

returns a dictionary of key to value

get_original_metadata_value(key, default=None)[source]

Return the value for a particular original metadata key

key - key to search for default - default value to return if not found

has_key(key)[source]
has_original_metadata(key)[source]

True if there is an original metadata item with the given key

iter_original_metadata()[source]

An iterator over the original metadata in structured annotations

returns (<annotation ID>, (<key, value>))

where <annotation ID> is the ID attribute of the annotation (which can be used to tie an annotation to an image)

<key> is the original metadata key, typically one of the OM_* names of a TIFF tag <value> is the value for the metadata

keys() → a set-like object providing a view on D's keys[source]
class TiffData(node)[source]

Bases: object

The OME/Image/Pixels/TiffData element

<TiffData FirstC=”0” FirstT=”0” FirstZ=”0” IFD=”0” PlaneCount=”1”>

<UUID FileName=”img40_1.ome.tif”>urn:uuid:ef8af211-b6c1-44d4-97de-daca46f16346</UUID>

</TiffData> For our purposes, there will be one TiffData per 2-dimensional image plane.

property FirstC

The channel index of the plane

property FirstT

The T index of the plane

property FirstZ

The Z index of the plane

property IFD

plane index within tiff file

property PlaneCount

How many planes in this TiffData. Should always be 1

get_FirstC()[source]

The channel index of the plane

get_FirstT()[source]

The T index of the plane

get_FirstZ()[source]

The Z index of the plane

get_IFD()[source]

plane index within tiff file

get_PlaneCount()[source]

How many planes in this TiffData. Should always be 1

set_FirstC(value)[source]
set_FirstT(value)[source]
set_FirstZ(value)[source]
set_IFD(value)[source]
set_PlaneCount(value)[source]
class Well(node)[source]

Bases: object

property Column
property ExternalDescription
property ExternalIdentifier
property ID
property Row
property Sample
get_Color()[source]
get_Column()[source]
get_ExternalDescription()[source]
get_ExternalIdentifier()[source]
get_ID()[source]
get_Row()[source]
get_Sample()[source]
set_Color(value)[source]
set_Column(value)[source]
set_ExternalDescription(value)[source]
set_ExternalIdentifier(value)[source]
set_ID(value)[source]
set_Row(value)[source]
class WellSample(node)[source]

Bases: object

The WellSample is a location within a well

property ID
property ImageRef

Get the ID of the image of this site

property Index
property PositionX
property PositionY
property Timepoint
get_ID()[source]
get_ImageRef()[source]

Get the ID of the image of this site

get_Index()[source]
get_PositionX()[source]
get_PositionY()[source]
get_Timepoint()[source]
set_ID(value)[source]
set_ImageRef(value)[source]

Add a reference to the image of this site

set_Index(value)[source]
set_PositionX(value)[source]
set_PositionY(value)[source]
set_Timepoint(value)[source]
class WellSampleDucktype(well_node)[source]

Bases: list

The WellSample elements in a well

This is made to look like an indexable list so that you can do things like: wellsamples[0:2]

new(wellsample_id='96f0d8d9-80a9-4bcf-8127-3df6861a237b', index=None)[source]

Create a new well sample

class WellsDucktype(plate)[source]

Bases: dict

The WellsDucktype lets you retrieve and create wells

The WellsDucktype looks like a dictionary but lets you reference the wells in a plate using indexing. Types of indexes:

list indexing: e.g. plate.Well[14] gets the 14th well as it appears

in the XML

dictionary_indexing:

by well name - e.g. plate.Well[“A08”] by row and column - e.g. plate.Well[1,3] (B03) by ID - e.g. plate.Well[“Well:0:0:0”]

If the ducktype is unable to parse a well name, it assumes you’re using an ID.

new(row, column, well_id='58a73c45-0d7d-424d-b053-49b9588499b9')[source]

Create a new well at the given row and column

row - index of well’s row column - index of well’s column well_id - the ID attribute for the well

get_image_count()[source]

The number of images (= series) specified by the XML

get_ns(key)[source]
image(index=0)[source]

Return an image node by index

property image_count

The number of images (= series) specified by the XML

property plates
property root_node
set_image_count(value)[source]

Add or remove image nodes as needed

property structured_annotations

Return the structured annotations container

returns a wrapping of OME/StructuredAnnotations. It creates the element if it doesn’t exist.

to_xml(indent='\t', newline='\n', encoding='utf-8')[source]
aicsimageio.vendor.omexml.OM_ARTIST = 'Artist'

IFD # 316

aicsimageio.vendor.omexml.OM_BITS_PER_SAMPLE = 'BitsPerSample'

IFD # 262

aicsimageio.vendor.omexml.OM_CELL_LENGTH = 'CellLength'

IFD # 266

aicsimageio.vendor.omexml.OM_CELL_WIDTH = 'CellWidth'

IFD # 265

aicsimageio.vendor.omexml.OM_DATE_TIME = 'DateTime'

IFD # 315

aicsimageio.vendor.omexml.OM_DOCUMENT_NAME = 'Document Name'

IFD # 271

aicsimageio.vendor.omexml.OM_FILL_ORDER = 'FillOrder'

IFD # 279

aicsimageio.vendor.omexml.OM_FREE_BYTECOUNTS = 'FreeByteCounts'

IFD # 290

aicsimageio.vendor.omexml.OM_FREE_OFFSETS = 'FreeOffsets'

IFD # 289

aicsimageio.vendor.omexml.OM_GRAY_RESPONSE_CURVE = 'GrayResponseCurve'

IFD # 292

aicsimageio.vendor.omexml.OM_GRAY_RESPONSE_UNIT = 'GrayResponseUnit'

IFD # 291

aicsimageio.vendor.omexml.OM_HOST_COMPUTER = 'HostComputer'

IFD # 317

aicsimageio.vendor.omexml.OM_IMAGE_LENGTH = 'ImageLength'

IFD # 258

aicsimageio.vendor.omexml.OM_IMAGE_WIDTH = 'ImageWidth'

IFD # 257

aicsimageio.vendor.omexml.OM_INK_SET = 'InkSet'

IFD # 33432

aicsimageio.vendor.omexml.OM_MAKE = 'Make'

IFD # 272

aicsimageio.vendor.omexml.OM_MAX_SAMPLE_VALUE = 'MaxSampleValue'

IFD # 282

aicsimageio.vendor.omexml.OM_MIN_SAMPLE_VALUE = 'MinSampleValue'

IFD # 281

aicsimageio.vendor.omexml.OM_MODEL = 'Model'

IFD # 274

aicsimageio.vendor.omexml.OM_NEW_SUBFILE_TYPE = 'NewSubfileType'

IFD # 256

aicsimageio.vendor.omexml.OM_ORIENTATION = 'Orientation'

IFD # 277

aicsimageio.vendor.omexml.OM_PAGE_NUMBER = 'PageNumber'

IFD # 301

aicsimageio.vendor.omexml.OM_PREDICTOR = 'Predictor'

IFD # 318

aicsimageio.vendor.omexml.OM_RESOLUTION_UNIT = 'ResolutionUnit'

IFD # 297

aicsimageio.vendor.omexml.OM_SAMPLES_PER_PIXEL = 'SamplesPerPixel'

IFD # 280

aicsimageio.vendor.omexml.OM_SOFTWARE = 'Software'

IFD # 306

aicsimageio.vendor.omexml.OM_T4_OPTIONS = 'T4Options'

IFD # 293

aicsimageio.vendor.omexml.OM_T6_OPTIONS = 'T6Options'

IFD # 296

aicsimageio.vendor.omexml.OM_THRESHHOLDING = 'Threshholding'

IFD # 264 (but can be 265 if the orientation = 8)

aicsimageio.vendor.omexml.OM_TILE_BYTE_COUNT = 'TileByteCount'

IFD # 332

aicsimageio.vendor.omexml.OM_TILE_LENGTH = 'TileLength'

IFD # 324

aicsimageio.vendor.omexml.OM_TILE_OFFSETS = 'TileOffsets'

IFD # 325

aicsimageio.vendor.omexml.OM_TILE_WIDTH = 'TileWidth'

IFD # 323

aicsimageio.vendor.omexml.OM_TRANSFER_FUNCTION = 'TransferFunction'

IFD # 305

aicsimageio.vendor.omexml.OM_WHITE_POINT = 'WhitePoint'

IFD # 322

aicsimageio.vendor.omexml.OM_X_POSITION = 'XPosition'

IFD # 287

aicsimageio.vendor.omexml.OM_X_RESOLUTION = 'XResolution'

IFD # 283

aicsimageio.vendor.omexml.OM_Y_POSITION = 'YPosition'

IFD # 288

aicsimageio.vendor.omexml.OM_Y_RESOLUTION = 'YResolution'

IFD # 284

aicsimageio.vendor.omexml.PC_PLANAR = 'Planar'

IFD # 286

aicsimageio.vendor.omexml.PI_CFA_ARRAY = 'Color Filter Array'

BioFormats infers the image type from the photometric interpretation

aicsimageio.vendor.omexml.get_float_attr(node, attribute, default=None)[source]

Cast an element attribute to a float or return None if not present

aicsimageio.vendor.omexml.get_int_attr(node, attribute)[source]

Cast an element attribute to an int or return None if not present

aicsimageio.vendor.omexml.get_namespaces(node)[source]

Get top-level XML namespaces from a node.

aicsimageio.vendor.omexml.get_pixel_type(npdtype)[source]
aicsimageio.vendor.omexml.get_text(node)[source]

Get the contents of text nodes in a parent node

aicsimageio.vendor.omexml.make_text_node(parent, namespace, tag_name, text)[source]

Either make a new node and add the given text or replace the text

parent - the parent node to the node to be created or found namespace - the namespace of the node’s qualified name tag_name - the tag name of the node’s qualified name text - the text to be inserted

aicsimageio.vendor.omexml.page_name_original_metadata(index)[source]

Get the key name for the page name metadata data for the indexed tiff page

These are TIFF IFD #’s 285+

index - zero-based index of the page

aicsimageio.vendor.omexml.qn(namespace, tag_name)[source]

Return the qualified name for a given namespace and tag name

This is the ElementTree representation of a qualified name

aicsimageio.vendor.omexml.set_text(node, text)[source]

Set the text of a parent

aicsimageio.vendor.omexml.split_qn(qn)[source]

Split a qualified tag name or return None if namespace not present

aicsimageio.vendor.omexml.xsd_now()[source]

Return the current time in xsd:dateTime format

Module contents