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
¶
-
property
-
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
-
property
-
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
-
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.
-
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.
-
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
-
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_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_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_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 …
-
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 …
-
property
-
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
-
property
-
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
¶
-
property
-
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
-
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
-
property
-
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
-
class
Well
(node)[source]¶ Bases:
object
-
property
Column
¶
-
property
ExternalDescription
¶
-
property
ExternalIdentifier
¶
-
property
ID
¶
-
property
Row
¶
-
property
Sample
¶
-
property
-
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
¶
-
property
-
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]
-
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.
-
property
image_count
¶ The number of images (= series) specified by the XML
-
property
plates
¶
-
property
root_node
¶
-
property
structured_annotations
¶ Return the structured annotations container
returns a wrapping of OME/StructuredAnnotations. It creates the element if it doesn’t exist.
-
class
-
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.
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