Importing images in czi file extension

Hi All,
May I know how to import image files in czi file format generated from Zeiss microscope into Slicer,
for performing segmentation?


Probably the easiest is to load it using a Python package (e.g., czifile) then set the Python array into a volume node.

If you need to load this kind of images often, then you can write a short Python scripted module that makes loading available in “Add data” dialog the same way as for other formats.


Thank you.
I tried the following in python

import czifile
from skimage import io

img = czifile.imread('file.czi')

The output is
(1, 1, 3, 1, 48, 1024, 1024, 1)
I couldn’t completely understand what each value in the output refers to

Does 3 denote the number of channels?

From what I understand 48 refers to the number of slices in the z-stack. I would like to save the z-stack corresponding to channel 1 in tiff format and load this in Slicer. Could you please offer some advice on how this can be done?

You can use numpy.squeeze() to remove singular dimensions of an array. Probably there is a reason for czifile to return these many extra dimensions, so I would recommend to read its documentation.

Hi @lassoan
I could do the following


from aicsimageio import AICSImage
from aicsimageio.writers import OmeTiffWriter

img = AICSImage('input.czi')  # returns 6D STCZYX numpy array
print(img.dims)  # returns string "STCZYX"
print(img.shape)  # returns tuple of dimension sizes in STCZYX order

first_channel_data = img.get_image_data("ZYX", C=1, S=0, T=0)

 with OmeTiffWriter("file.ome.tiff") as writer:

The output tiff file has 3 channels. One of the channels has stained cells. But from the other two channels, I am not sure how to find out which channel can be used for 3D reconstruction of vessels
in Slicer.

Could you please offer some advice?

Why don’t you simple use squeeze as I suggested above to remove the singular dimensions set the array in a volume node by calling slicer.util.updateVolumeFromArray?

It depends on the color of the feature that you want to extract and color of background noise that you want to suppress. Try all combinations in “Vector To Scalar Volume” module (Luminance, Average, and each single component) and use whichever works the best.