impro.libs package¶
Submodules¶
impro.libs.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 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: | 2017.09.12 |
Requirements¶
- CPython 3.6 64-bit
- Numpy 1.13
- Scipy 0.19
- Tifffile.py 2017.09.12
- Czifle.pyx 2017.07.20 (for decoding JpegXrFile and JpgFile images)
Revisions¶
- 2017.09.12
- Require tifffile.py 2017.09.12
- 2017.07.21
- Use multi-threading in CziFile.asarray to decode and copy segment data. Always convert BGR to RGB. Remove bgr2rgb options. Decode JpegXR directly from byte arrays.
- 2017.07.13
- Add function to convert CZI file to memory-mappable TIFF file.
- 2017.07.11
- Add ‘out’ parameter to CziFile.asarray. Remove memmap option from CziFile.asarray (backwards incompatible). Change spline interpolation order to 0 (backwards incompatible). Make axes return a string. Require tifffile 2017.07.11.
- 2015.08.17
- Require tifffile 2015.08.17.
- 2014.10.10
- Read data into a memory mapped array (optional).
- 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
- ZISRAW (CZI) File Format Design specification Release Version 1.2.2. CZI 07-2016/CZI-DOC ZEN 2.3/DS_ZISRAW-FileFormat.pdf (confidential). Documentation can be requested at <http://microscopy.zeiss.com/microscopy/en_us/downloads/zen.html>
- 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)
-
impro.libs.czifile.
imread
(filename, *args, **kwargs)¶ Return image data from CZI file as numpy array.
‘args’ and ‘kwargs’ are arguments to the CziFile.asarray function.
Examples
>>> image = imread('test.czi') >>> image.shape (3, 3, 3, 250, 200, 3) >>> image.dtype dtype('uint8')
-
class
impro.libs.czifile.
CziFile
(arg, multifile=True, filesize=None, detectmosaic=True)¶ Bases:
object
Carl Zeiss Image (CZI) file.
-
header
¶ Global file metadata such as file version and GUID.
Type: FileHeaderSegment
-
metadata
¶ Global image metadata in UTF-8 encoded XML format.
Type: etree.ElementTree.Element
-
All attributes are read-only.
-
asarray
(resize=True, order=0, out=None, max_workers=None)¶ Return image data from file(s) as numpy array.
Parameters: - 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 0 (nearest neighbor).
- out (numpy.ndarray, str, or file-like object; optional) – Buffer where image data will be saved. If numpy.ndarray, a writable array of compatible dtype and shape. If str or open file, the file name or file object used to create a memory-map to an array stored in a binary file on disk.
- max_workers (int) – Maximum number of threads to read and decode subblock data. By default up to half the CPU cores are used.
-
attachment_directory
¶ Attribute whose value is computed on first access.
-
attachments
()¶ Return iterator over all Attachment segments in file.
-
axes
¶ Attribute whose value is computed on first access.
-
close
()¶
-
dtype
¶ Attribute whose value is computed on first access.
-
filtered_subblock_directory
¶ Attribute whose value is computed on first access.
-
metadata
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
¶ Attribute whose value is computed on first access.
-
start
¶ Attribute whose value is computed on first access.
-
subblock_directory
¶ Attribute whose value is computed on first access.
-
subblocks
()¶ Return iterator over all SubBlock segments in file.
-