CZI manager module
This module takes care of the CZI file management. We used to use the bftool kit (https://www.openmicroscopy.org/) which is a set of Java tools, but we opted to use a pure python library that can handle CZI files. https://github.com/AllenCellModeling/aicspylibczi
- class library.image_manipulation.czi_manager.CZIManager(czi_file)
Bases:
object
Methods to extract meta-data from czi files using AICSImage module (Allen Institute)
- extract_metadata_from_czi_file(czi_file, czi_file_path, debug: bool = False)
This will parse the xml metadata and return the relevant data.
- Parameters:
czi_file – string of the CZI file name
czi_file_path – string of the CZI path
- Returns:
dictionary of the metadata
- get_scene(scene_index, channel, scale=1.0)
Gets the correct scene from the slide
- Parameters:
scene_index – integer of the scene index
channel – integer of the channel
scale – integer of the scale. Usually either 1 or 16 (full or downsampled)
- Returns:
the scene
- get_scene_dimension(scene_index)
Gets the bounding box size of the scene
- Parameters:
scene_index – integer of the scene index
- Returns:
x,y,width and height of the bounding box
- library.image_manipulation.czi_manager.extract_png_from_czi(file_key: tuple, normalize: bool = True)
This method creates a PNG file from the TIFF file. This is used for viewing on a web page.
- Parameters:
file_key – tuple of _, infile, outfile, scene_index, scale
normalize – a boolean that determines if we should normalize the TIFF
- library.image_manipulation.czi_manager.extract_tiff_from_czi(file_key: tuple[str, str, int, bool, str]) None
Extracts a TIFF image from a CZI file based on the provided parameters. :param file_key (tuple[str, str, int, bool, str]): A tuple containing the following elements: - czi_file (str): Path to the input CZI file. - outfile (str): Path to the output TIFF file. - scenei (int): Index of the scene to extract. - channel (int): Channel number to extract. - scale (bool): Scaling factor for the image. :return None :raise IOError: If there is an error writing the output TIFF file.
- library.image_manipulation.czi_manager.extract_tiff_from_cziORIG(file_key: tuple[str, str, int, bool, str]) None
Gets the TIFF file out of the CZI and writes it to the filesystem :param file_key: a tuple of: czi_file, output_path, checksum_filepath, scenei, channel, scale, debug