aicsimageio.metadata package
Submodules
aicsimageio.metadata.utils module
- aicsimageio.metadata.utils.bioformats_ome(path: Union[str, Path], original_meta: bool = False) OME [source]
Retrieve OME meta from any compatible file, using bioformats.
Note: this function requires the bioformats_jar package to be installed.
- Parameters
path (str or Path) – path to image
original_meta (bool, optional) – whether to also retrieve the proprietary metadata as structured annotations in the OME output, by default False
- Returns
OME – The parsed metadata object.
- Return type
ome_types.OME
- Raises
ImportError – if bioformats_jar is not installed.
ValidationError – if ome_types.cannot parse the xml in the file
- aicsimageio.metadata.utils.clean_ome_xml_for_known_issues(xml: str) str [source]
Clean an OME XML string for known issues created by AICS or MicroManager systems and tools.
Commonly this is used for cleaning a file produced by AICS prior to noticing the issue (2021), or for other users of aicsimageio as a whole prior to 4.x series of releases.
The result of this function should be an OME XML string that is relatively the same (no major pieces missing) but that validates against the reference OME XSD.
- Parameters
xml (str) – The OME XML string to clean for errors.
- Returns
cleaned_xml – The cleaned OME XML string.
- Return type
str
- Raises
ValueError – Provided XML does not contain a namespace.
- aicsimageio.metadata.utils.dtype_to_ome_type(npdtype: dtype) PixelType [source]
Convert numpy dtype to OME PixelType
- Parameters
npdtype (numpy.dtype) – A numpy datatype.
- Returns
ome_type – One of the supported OME Pixels types
- Return type
PixelType
- Raises
ValueError – No matching pixel type for provided numpy type.
- aicsimageio.metadata.utils.generate_ome_channel_id(image_id: str, channel_id: Union[str, int]) str [source]
Naively generates the standard OME channel ID using a provided ID.
- Parameters
image_id (str) – An image id to pull the image specific index from. See: generate_ome_image_id for more details.
channel_id (Union[str, int]) – A string or int representing the ID for a channel. In the context of the usage of this function, this is usually used with the index of the channel.
- Returns
ome_channel_id – The OME standard for channel IDs.
- Return type
str
Notes
ImageIds are usually: “Image:0”, “Image:1”, or “Image:N”, ChannelIds are usually the combination of image index + channel index – “Channel:0:0” for the first channel of the first image for example.
- aicsimageio.metadata.utils.generate_ome_detector_id(detector_id: Union[str, int]) str [source]
Naively generates the standard OME detector ID using a provided ID.
- Parameters
detector_id (Union[str, int]) – A string or int representing the ID for a detector.
- Returns
ome_detector_id – The OME standard for detector IDs.
- Return type
str
- aicsimageio.metadata.utils.generate_ome_image_id(image_id: Union[str, int]) str [source]
Naively generates the standard OME image ID using a provided ID.
- Parameters
image_id (Union[str, int]) – A string or int representing the ID for an image. In the context of the usage of this function, this is usually used with the index of the scene / image.
- Returns
ome_image_id – The OME standard for image IDs.
- Return type
str
- aicsimageio.metadata.utils.generate_ome_instrument_id(instrument_id: Union[str, int]) str [source]
Naively generates the standard OME instrument ID using a provided ID.
- Parameters
instrument_id (Union[str, int]) – A string or int representing the ID for an instrument.
- Returns
ome_instrument_id – The OME standard for instrument IDs.
- Return type
str
- aicsimageio.metadata.utils.get_coords_from_ome(ome: OME, scene_index: int) Dict[str, Union[List[Any], ndarray, Array, Any]] [source]
Process the OME metadata to retrieve the coordinate planes.
- Parameters
ome (OME) – A constructed OME object to retrieve data from.
scene_index (int) – The current operating scene index to pull metadata from.
- Returns
coords – The coordinate planes / data for each dimension.
- Return type
Dict[str, Union[List[Any], Union[types.ArrayLike, Any]]]
- aicsimageio.metadata.utils.get_dims_from_ome(ome: OME, scene_index: int) List[str] [source]
Process the OME metadata to retrieve the dimension names.
- Parameters
ome (OME) – A constructed OME object to retrieve data from.
scene_index (int) – The current operating scene index to pull metadata from.
- Returns
dims – The dimension names pulled from the OME metadata.
- Return type
List[str]
- aicsimageio.metadata.utils.ome_to_numpy_dtype(ome_type: PixelType) dtype [source]
Convert OME PixelType to numpy dtype
- Parameters
ome_type (PixelType) – One of the supported OME Pixels types
- Returns
npdtype – A numpy datatype.
- Return type
numpy.dtype
- Raises
ValueError – No matching numpy type for the provided pixel type.
- aicsimageio.metadata.utils.physical_pixel_sizes(ome: OME, scene: int = 0) PhysicalPixelSizes [source]
- Returns
sizes – Using available metadata, the floats representing physical pixel sizes for dimensions Z, Y, and X.
- Return type
Notes
We currently do not handle unit attachment to these values. Please see the file metadata for unit information.
- aicsimageio.metadata.utils.transform_metadata_with_xslt(tree: Element, xslt: Union[str, Path]) OME [source]
Given an in-memory metadata Element and a path to an XSLT file, convert metadata to OME.
- Parameters
tree (ET.Element) – The metadata tree to convert.
xslt (PathLike) – Path to the XSLT file.
- Returns
ome – The generated / translated OME metadata.
- Return type
OME
Notes
This function will briefly update your processes current working directory to the directory that stores the XSLT file.