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
Installation
To install the basic functionality (will not install Napari und plotting functionality) use:
pip install czitools
To install the package with all optional dependencies use:
pip install czitools[all]
Reading the metadata
Please check use_metadata_tools.py for some examples.
from czitools.metadata_tools.czi_metadata import CziMetadata, writexml
from czitools.metadata_tools.dimension import CziDimensions
from czitools.metadata_tools.boundingbox import CziBoundingBox
from czitools.metadata_tools.channel import CziChannelInfo
from czitools.metadata_tools.scaling import CziScaling
from czitools.metadata_tools.sample import CziSampleInfo
from czitools.metadata_tools.objective import CziObjectives
from czitools.metadata_tools.microscope import CziMicroscope
from czitools.metadata_tools.add_metadata import CziAddMetaData
from czitools.metadata_tools.detector import CziDetector
from czitools.read_tools import read_tools
from czitools.napari_tools import napari_tools
import napari
# get the metadata_tools at once as one big class
mdata = CziMetadata(filepath)
# get only specific metadata_tools
czi_dimensions = 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 = writexml(filepath)
# get info about the channels
czi_channels = CziChannelInfo(filepath)
# get the complete metadata_tools from the CZI as one big object
czimd_complete = get_metadata_as_object(filepath)
# get an object containing only the dimension information
czi_dimensions = CziDimensions(filepath)
# get an object containing only the dimension information
czi_scale = CziScaling(filepath)
# get an object containing information about the sample
czi_sample = CziSampleInfo(filepath)
# get info about the objective, the microscope and the detectors
czi_objectives = CziObjectives(filepath)
czi_detectors = CziDetector(filepath)
czi_microscope = CziMicroscope(filepath)
# get info about the sample carrier
czi_sample = CziSampleInfo(filepath)
# get additional metainformation
czi_addmd = CziAddMetaData(filepath)
# get the complete data about the bounding boxes
czi_bbox = 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.
Local installation (base functionality only):
pip install -e .
Local Installation
Local installation (full functionality):
pip install -e ".[all]"
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.7.1.tar.gz
.
File metadata
- Download URL: czitools-0.7.1.tar.gz
- Upload date:
- Size: 50.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f01d70a05fecaaf482b347722b3bb6655523fe2794191c8e615321b9e024d631 |
|
MD5 | f7c6fce910124de5895e1cb8291d9695 |
|
BLAKE2b-256 | 5aafc7410a68e8ee728a24934934e1705a1fded7afd1451b59fb076236b9eb4e |
File details
Details for the file czitools-0.7.1-py3-none-any.whl
.
File metadata
- Download URL: czitools-0.7.1-py3-none-any.whl
- Upload date:
- Size: 57.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d39eb23ea339b43eaea2b458a4adaf4f9b41e305c69f9514f32623dcc0cef1ee |
|
MD5 | 9bbada76f3c6c13afd978ac6878df835 |
|
BLAKE2b-256 | 877f88690d85a49a7d762e79c444c6a09ce837186b8d9bed6569340d5892d6eb |