pycziutils package¶
Module contents¶
pycziutils
A tiny utility module to parse Zeiss CZI files in Python through python-bioformats. Parse tiled images, organize planes into pandas.DataFrame, get some hard-to-get metadata.
-
pycziutils.
get_tiled_omexml_metadata
(path=None, url=None, *, group_file=True)[source]¶ Read tiled czi image and get ZeissCZIReader without stitching
- Parameters
path (str, default None) – path to the czi file
url (str, default None) – url to the czi file (optional)
groupfiles (bool, default True) – utilize the groupfiles option to take the directory structure into account.
- Returns
xml – the OME-XML string
- Return type
str
Notes
Copied & modified from bioformats.get_omexml_metadata
-
pycziutils.
get_tiled_reader
(path)[source]¶ Read tiled czi image and get ZeissCZIReader without stitching
- Parameters
path (str) – path to the czi file
- Returns
reader – tiled reader
- Return type
ZeissCZIReader
-
pycziutils.
parse_binning
(ome_xml)[source]¶ parse OME-XML and get binning
- Parameters
ome_xml (str) – the input OME-XML string
- Returns
binning – the binning as [x,y]
- Return type
list
Note
uses ‘HardwareSetting|ParameterCollection|Binning’
-
pycziutils.
parse_camera_LUT
(ome_xml)[source]¶ parse OME-XML and get camera LUT
- Parameters
ome_xml (str) – the input OME-XML string
- Returns
lut – the LUT as [lut1,lut2]. If the key is not found, returns (np.nan,np.nan)
- Return type
list
Note
- uses ‘HardwareSetting|ParameterCollection|CameraLUT1’ and
‘HardwareSetting|ParameterCollection|CameraLUT2’
-
pycziutils.
parse_camera_bits
(ome_xml)[source]¶ parse OME-XML and get camera bits
- Parameters
ome_xml (str) – the input OME-XML string
- Returns
bit_depth – the camera valid bits
- Return type
int
Note
uses ‘HardwareSetting|ParameterCollection|ValidBits’
-
pycziutils.
parse_camera_roi
(ome_xml)[source]¶ parse OME-XML and get ROI
- Parameters
ome_xml (str) – the input OME-XML string
- Returns
roi – the camera ROI (x0,y0,x1,y1) as a list
- Return type
list
Note
uses ‘HardwareSetting|ParameterCollection|ImageFrame’
-
pycziutils.
parse_camera_roi_slice
(ome_xml)[source]¶ parse OME-XML and get ROI as slices
- Parameters
ome_xml (str) – the input OME-XML string
- Returns
roi – the camera ROI as slices; slice(x0,x0),slice(y0,y1)
- Return type
slice
Note
uses ‘HardwareSetting|ParameterCollection|ImageFrame’
-
pycziutils.
parse_channels
(ome_xml, assume_all_equal=True)[source]¶ parse OME-XML and get the channel list
- Parameters
ome_xml (str) – the input OME-XML string
assume_all_equal (bool, default True) – if True, assume the channels are the same for all the planes
- Returns
a list of channels if assume_all_equal==True, otherwise a list of lists of channels for each planes
- Return type
channels
-
pycziutils.
parse_pixel_size
(ome_xml, assume_all_equal=True)[source]¶ parse OME-XML and get the pixel sizes
- Parameters
ome_xml (str) – the input OME-XML string
assume_all_equal (bool, default True) – if True, assume the pixel sizes are the same for all the planes
- Returns
a list of pixel sizes if assume_all_equal==True, otherwise a list of lists of pixel sizes for each planes
- Return type
pixel sizes
-
pycziutils.
parse_planes
(ome_xml, acquisition_timezone=0)[source]¶ parse OME-XML and get pandas dataframe for each planes
- Parameters
ome_xml (str) – the input OME-XML string
acquisition_timezone (Union[datetime.timezone, int]) – timezone to use. if int is given, datetime.timezone(datetime.timedelta(timezone)) is used
- Returns
planes_df – dataframe for all planes, containing X,Y,Z positions and time
- Return type
pandas.DataFrame
Note
absolute_T is T + AcquisitionDate, not sure if it is absolutely correct for now
-
pycziutils.
parse_properties
(ome_xml, keys, domain='pixels')[source]¶ parse OME-XML and get properties of the specified domain
- Parameters
ome_xml (str) – the input OME-XML string
keys – the keys for the properties
domain (str) – the domain level to get properties, should be “image”, “pixels” or “plane”
- Returns
the properties as a list
- Return type
properties
-
pycziutils.
parse_structured_annotation_dict
(ome_xml)[source]¶ parse OME-XML and get structured annotation as a dict
- Parameters
ome_xml (str) – the input OME-XML string
- Returns
structured_annotation_dict – OriginalMetadata.key : OriginalMetadata.value pairs as a dict
- Return type
dict
-
pycziutils.
summarize_image_size
(reader, print_summary=True)[source]¶ get image size and summarize from reader
- Parameters
reader – the bioformat reader
print_summary (bool, default True) – wheather to print the size summary
- Returns
seriesCount (int) – the count for series
sizeT (int) – the count for time
sizeC (int) – the count for channels
sizeX (int) – the count for X
sizeY (int) – the count for Y
sizeZ (int) – the count for Z
-
pycziutils.
with_javabridge
(func)[source]¶ runs function with javabridge, with the loglevel error https://forum.image.sc/t/python-bioformats-and-javabridge-debug-messages/12578/11