Tools to simplify reading CZI (Carl Zeiss Image) meta and pixel data
Project description
czitools
This repository provides a collection of tools to simplify reading CZI (Carl Zeiss Image) pixel and metadata in Python. In addition it also contains other useful utilities to visualize CZI images inside Napari (needs to be installed). It is also available as a Python Package on PyPi
Reading the metadata
Please check use_metadata_tools.py for some examples.
# get the metadata at once as one big class
mdata = czimd.CziMetadata(filepath)
# get only specific metadata
czi_dimensions = czimd.CziDimensions(filepath)
print("SizeS: ", czi_dimensions.SizeS)
print("SizeT: ", czi_dimensions.SizeT)
print("SizeZ: ", czi_dimensions.SizeZ)
print("SizeC: ", czi_dimensions.SizeC)
print("SizeY: ", czi_dimensions.SizeY)
print("SizeX: ", czi_dimensions.SizeX)
# try to write XML to file
xmlfile = czimd.writexml(filepath)
# get info about the channels
czi_channels = czimd.CziChannelInfo(filepath)
# get the complete metadata from the CZI as one big object
czimd_complete = czimd.get_metadata_as_object(filepath)
# get an object containing only the dimension information
czi_dimensions = czimd.CziDimensions(filepath)
# get an object containing only the dimension information
czi_scale = czimd.CziScaling(filepath)
# get an object containing information about the sample
czi_sample = czimd.CziSampleInfo(filepath)
# get info about the objective, the microscope and the detectors
czi_objectives = czimd.CziObjectives(filepath)
czi_detectors = czimd.CziDetector(filepath)
czi_microscope = czimd.CziMicroscope(filepath)
# get info about the sample carrier
czi_sample = czimd.CziSampleInfo(filepath)
# get additional metainformation
czi_addmd = czimd.CziAddMetaData(filepath)
# get the complete data about the bounding boxes
czi_bbox = czimd.CziBoundingBox(filepath)
Reading CZI pixel data
While the pylibCZIrw is focussing on reading individual planes it is also helpful to read CZI pixel data as a STCZYX(A) stack. Please check use_read_tools.py for some examples.
# return a dask or numpy array with dimension order STCZYX(A)
array6d, mdata = read_tools.read_6darray(filepath,
use_dask=True,
chunk_zyx=False,
# T=0,
# Z=0
# S=0
# C=0
)
if array6d is None:
print("Empty array6d. Nothing to display in Napari")
else:
# show array inside napari viewer
viewer = napari.Viewer()
layers = napari_tools.show(viewer, array6d, mdata,
blending="additive",
contrast='from_czi',
gamma=0.85,
show_metadata="tree",
name_sliders=True)
napari.run()
Colab Notebooks
Read CZI metadata
The basic usage can be inferred from this sample notebook:
Read CZI pixeldata
The basic usage can be inferred from this sample notebook:
Write OME-ZARR from 5D CZI image data
The basic usage can be inferred from this sample notebook:
Write CZI using ZSTD compression
The basic usage can be inferred from this sample notebook:
Show planetable of a CZI image as surface
The basic usage can be inferred from this sample notebook:
Read a CZI and segment using Voroni-Otsu provided by PyClesperanto GPU processing
The basic usage can be inferred from this sample notebook:
Remarks
The code to read multi-dimensional with delayed reading using Dask array was heavily inspired by input from: Pradeep Rajasekhar.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file czitools-0.6.0.tar.gz
.
File metadata
- Download URL: czitools-0.6.0.tar.gz
- Upload date:
- Size: 44.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6e82e7ad45ce1a32af386d875b2c8926cb4eb81585252bc384dd0dc71e61f0f |
|
MD5 | f1513f60b0a940e16e5bbdb6c2a746fe |
|
BLAKE2b-256 | 228781e0598f2f050b19b17c94f82ef3281b2eb668f5b6c0d15339ca96eb9ff2 |
File details
Details for the file czitools-0.6.0-py3-none-any.whl
.
File metadata
- Download URL: czitools-0.6.0-py3-none-any.whl
- Upload date:
- Size: 45.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d6d2a2909cc0c4d853080e74673924a0481de28f3d82f80cd5754efbd387a21 |
|
MD5 | e39328b5a36860618bb12cd76eabcb81 |
|
BLAKE2b-256 | e4feecd00373f0b05b9c0c203d0085cff4aef5753b7121d2d4b5654b98f71993 |