dvpio.read.image.read_czi#
- dvpio.read.image.read_czi(path, chunk_size=(10000, 10000), channels=None, scene=None, timepoint=0, z_stack=0, **kwargs)#
Read .czi to Image2DModel
Uses the CZI API to read .czi Carl Zeiss image format to spatialdata image format.
- Parameters:
path (
str) – Path to filechunk_size (
tuple[int,int] (default:(10000, 10000))) – Size of the individual regions that are read into memory during the process.channels (
Union[int,list[int],None] (default:None)) – Defaults toNonewhich automatically selects all available channels. Passing the numeric index of a single or multiple channels subsets the data to the specified channels.scene (
Optional[int] (default:None)) – Index of the scene to read. IfNone(default), all scenes will be considered. If specified, only subblocks of the specified scene contribute to the parsed image.timepoint (
int(default:0)) – If timeseries, select the given index (defaults to 0 [first])z_stack (
int(default:0)) – If z_stack, selects the given z-plane (defaults to 0 [first])kwargs (
Mapping[str,Any]) – Keyword arguments passed tospatialdata.models.Image2DModel.parse()
- Return type:
- Returns:
Example
We can read czi images with a very simple API
from dvpio.read.image import read_czi czi_path = ... read_czi(czi_path) # > <xarray.DataArray 'image' (c: 2, y: 1440, x: 21718)> Size: 125MB
Note that you can also select subsets of the data that you would like to read. Currently, the function supports reading specific channel indices, scenes (regions of interest), timepoint indices, or z-stack indices. This might significantly reduce the storage demands of your data
czi_path_multi_scene = ... # Only read the first scene read_czi(czi_path_multi_scene, scene=0) # > <xarray.DataArray 'image' (c: 2, y: 1416, x: 1960)> Size: 11MB
You can pass additional keyword arguments to
spatialdata.models.Image2DModel.parse(). For example, to generate a pyramidal image for overall faster data access, pass thescale_factorsargument# Create a pyramidal data representation read_czi(czi_path_multi_scene, scale_factors=[2, 2, 2]) # > <xarray.DataTree> # Group: / # |-- Group: /scale0 # |-- Group: /scale1 # `-- Group: /scale2