OmeXml¶
- final class tifffile.OmeXml(**metadata)¶
Create OME-TIFF XML metadata.
- Parameters:
**metadata (Any) –
Additional OME-XML attributes or elements to be stored.
- Creator:
Name of creating application. The default is ‘tifffile’.
- UUID:
Unique identifier.
Examples
>>> omexml = OmeXml() >>> omexml.addimage( ... dtype='uint16', ... shape=(32, 256, 256), ... storedshape=(32, 1, 1, 256, 256, 1), ... axes='CYX', ... Name='First Image', ... PhysicalSizeX=2.0, ... MapAnnotation={'key': 'value'}, ... Dataset={'Name': 'FirstDataset'}, ... ) >>> xml = omexml.tostring() >>> xml '<OME ...<Image ID="Image:0" Name="First Image">...</Image>...</OME>' >>> OmeXml.validate(xml) True
- images: list[str]¶
OME-XML Image elements.
- annotations: list[str]¶
OME-XML Annotation elements.
- datasets: list[str]¶
OME-XML Dataset elements.
- addimage(dtype, shape, storedshape, *, axes=None, **metadata)¶
Add image to OME-XML.
The OME model can handle up to 9 dimensional images for selected axes orders. Refer to the OME-XML specification for details. Non-TZCYXS (modulo) dimensions must be after a TZC dimension or require an unused TZC dimension.
- Parameters:
dtype (DTypeLike) – Data type of image array.
shape (Sequence[int]) – Shape of image array.
storedshape (tuple[int, int, int, int, int, int]) – Normalized shape describing how image array is stored in TIFF file as (pages, separate_samples, depth, length, width, contig_samples).
axes (str | None) – Character codes for dimensions in shape. By default, axes is determined from the DimensionOrder metadata attribute or matched to the shape in reverse order of TZC(S)YX(S) based on storedshape. The following codes are supported: ‘S’ sample, ‘X’ width, ‘Y’ length, ‘Z’ depth, ‘C’ channel, ‘T’ time, ‘A’ angle, ‘P’ phase, ‘R’ tile, ‘H’ lifetime, ‘E’ lambda, ‘Q’ other.
**metadata (Any) –
Additional OME-XML attributes or elements to be stored.
- Image/Pixels:
Name, Description, DimensionOrder, TypeDescription, PhysicalSizeX, PhysicalSizeXUnit, PhysicalSizeY, PhysicalSizeYUnit, PhysicalSizeZ, PhysicalSizeZUnit, TimeIncrement, TimeIncrementUnit, StructuredAnnotations, BooleanAnnotation, DoubleAnnotation, LongAnnotation, CommentAnnotation, MapAnnotation, Dataset
- Per Plane:
DeltaT, DeltaTUnit, ExposureTime, ExposureTimeUnit, PositionX, PositionXUnit, PositionY, PositionYUnit, PositionZ, PositionZUnit.
- Per Channel:
Name, AcquisitionMode, Color, ContrastMethod, EmissionWavelength, EmissionWavelengthUnit, ExcitationWavelength, ExcitationWavelengthUnit, Fluor, IlluminationType, NDFilter, PinholeSize, PinholeSizeUnit, PockelCellSetting.
- Raises:
OmeXmlError – Image format not supported.
- Return type:
None
- tostring(*, declaration=False)¶
Return OME-XML string.
- Parameters:
declaration (bool) – Include XML declaration.
- Return type:
str
- static validate(omexml, /, omexsd=None, assert_=True, *, _schema=[])¶
Return if OME-XML is valid according to XMLSchema.
- Parameters:
omexml (str) – OME-XML string to validate.
omexsd (bytes | None) – Content of OME-XSD schema to validate against. By default, the 2016-06 OME XMLSchema is downloaded on first run.
assert_ (bool) – Raise AssertionError if validation fails.
_schema (list[Any]) – Internal use.
- Raises:
AssertionError – Validation failed and assert_ is True.
- Return type:
bool | None