PYME.contrib.gohlke.czifile module

Read image and metadata from Carl Zeiss(r) ZISRAW (CZI) files.

CZI is the native image file format of the ZEN(r) software by the Carl Zeiss Microscopy GmbH. It stores multidimensional images and metadata from microscopy experiments.

Author:Christoph Gohlke
Organization:Laboratory for Fluorescence Dynamics, University of California, Irvine
Version:2013.12.04

Requirements

Revisions

2013.12.04
Decode JpegXrFile and JpgFile via _czifle extension module. Attempt to reconstruct tiled mosaic images.
2013.11.20
Initial release.

Notes

The API is not stable yet and might change between revisions.

The file format design specification [1] is confidential and the licence agreement does not permit to write data into CZI files.

Only a subset of the 2012 specification is implemented in the initial release. Specifically, multifile images are not yet supported.

Tested on Windows with a few example files only.

References

  1. ZISRAW (CZI) File Format Design specification Release Version 1.1 for ZEN 2012. DS_ZISRAW-FileFormat_Rel_ZEN2012.doc (Confidential) Documentation can be requested at <http://microscopy.zeiss.com/microscopy/en_us/downloads/zen.html>
  2. CZI The File Format for the Microscope | ZEISS International <http://microscopy.zeiss.com/microscopy/en_us/products/microscope-software/ zen-2012/czi.html>

Examples

>>> with CziFile('test.czi') as czi:
...     image = czi.asarray()
>>> image.shape
(3, 3, 3, 250, 200, 3)
>>> image[0, 0, 0, 0, 0]
array([10, 10, 10], dtype=uint8)
PYME.contrib.gohlke.czifile.imread(filename, *args, **kwargs)

Return image data from CZI file as numpy array.

‘args’ and ‘kwargs’ are arguments to CziFile.asarray().

Examples

>>> image = imread('test.czi')
>>> image.shape
(3, 3, 3, 250, 200, 3)
>>> image.dtype
dtype('uint8')
class PYME.contrib.gohlke.czifile.CziFile(arg, multifile=True, filesize=None, detectmosaic=True)

Bases: object

Carl Zeiss Image (CZI) file.

Attributes

header (FileHeaderSegment) Global file metadata such as file version and GUID.
metadata (etree.ElementTree.Element) Global image metadata in UTF-8 encoded XML format.
All attributes are read-only.  

Methods

asarray([bgr2rgb, resize, order]) Return image data from file(s) as numpy array.
attachments() Return iterator over all Attachment segments in file.
close()
save_attachments([directory]) Save all attachments to files.
segments([kind]) Return iterator over Segment data of specified kind.
subblocks() Return iterator over all SubBlock segments in file.

Open CZI file and read header.

Raise ValueError if file is not a ZISRAW file.

Parameters:

multifile : bool

If True (default), the master file of a multifile CZI file will be opened if applicable.

filesize : int

Size of file if arg is a file handle pointing to an embedded CZI file.

detectmosaic : bool

If True (default), mosaic images will be reconstructed from SubBlocks with a tile index.

Notes

CziFile instances created from file name must be closed using the ‘close’ method, which is automatically called when using the ‘with’ statement.

Methods

asarray([bgr2rgb, resize, order]) Return image data from file(s) as numpy array.
attachments() Return iterator over all Attachment segments in file.
close()
save_attachments([directory]) Save all attachments to files.
segments([kind]) Return iterator over Segment data of specified kind.
subblocks() Return iterator over all SubBlock segments in file.
asarray(bgr2rgb=False, resize=True, order=1)

Return image data from file(s) as numpy array.

Parameters:

bgr2rgb : bool

If True, exchange red and blue samples if applicable.

resize : bool

If True (default), resize sub/supersampled subblock data.

order : int

The order of spline interpolation used to resize sub/supersampled subblock data. Default is 1 (bilinear).

attachment_directory

Lazy object attribute whose value is computed on first access.

attachments()

Return iterator over all Attachment segments in file.

axes

Lazy object attribute whose value is computed on first access.

close()
dtype

Lazy object attribute whose value is computed on first access.

filtered_subblock_directory

Lazy object attribute whose value is computed on first access.

metadata

Lazy object attribute whose value is computed on first access.

save_attachments(directory=None)

Save all attachments to files.

segments(kind=None)

Return iterator over Segment data of specified kind.

Parameters:

kind : bytestring or sequence thereof

Segment id(s) as listed in SEGMENT_ID. If None (default), all segments are returned.

shape

Lazy object attribute whose value is computed on first access.

start

Lazy object attribute whose value is computed on first access.

subblock_directory

Lazy object attribute whose value is computed on first access.

subblocks()

Return iterator over all SubBlock segments in file.