PYME.contrib.gohlke.tifffile module¶
Read and write image data from and to TIFF files.
Image and meta-data can be read from TIFF, BigTIFF, OME-TIFF, STK, LSM, NIH, and FluoView files. Only a subset of the TIFF specification is supported, mainly uncompressed and losslessly compressed 2**(0 to 6) bit integer, 16, 32 and 64-bit float, grayscale and RGB(A) images, which are commonly used in bio-scientific imaging. Specifically, reading JPEG or CCITT compressed image data is not implemented. Only primary info records are read for STK, FluoView, and NIH image formats.
TIFF, the Tagged Image File Format, is under the control of Adobe Systems. BigTIFF allows for files greater than 4 GB. STK, LSM, FluoView, and OME-TIFF are custom extensions defined by MetaMorph, Carl Zeiss MicroImaging, Olympus, and the Open Microscopy Environment consortium respectively.
The API is not stable yet and might change between revisions. Tested on little-endian platforms only.
For command line usage run python tifffile.py --help
- Authors
Christoph Gohlke, Laboratory for Fluorescence Dynamics, University of California, Irvine
- Version
2012.04.21
Requirements¶
Matplotlib 1.1 (optional for plotting)
tifffile.c 2012.01.01 (optional for faster decoding of PackBits and LZW encoded strings)
Acknowledgements¶
Egor Zindy, University of Manchester, for cz_lsm_scan_info specifics.
Wim Lewis, for a bug fix and some read_cz_lsm functions.
References¶
TIFF 6.0 Specification and Supplements. Adobe Systems Incorporated. http://partners.adobe.com/public/developer/tiff/
TIFF File Format FAQ. http://www.awaresystems.be/imaging/tiff/faq.html
MetaMorph Stack (STK) Image File Format. http://support.meta.moleculardevices.com/docs/t10243.pdf
File Format Description - LSM 5xx Release 2.0. http://ibb.gsf.de/homepage/karsten.rodenacker/IDL/Lsmfile.doc
BioFormats. http://www.loci.wisc.edu/ome/formats.html
The OME-TIFF format. http://www.openmicroscopy.org/site/support/file-formats/ome-tiff
Examples¶
>>> data = numpy.random.rand(301, 219)
>>> imsave('temp.tif', data)
>>> image = imread('temp.tif')
>>> assert numpy.all(image == data)
>>> tif = TIFFfile('test.tif')
>>> images = tif.asarray()
>>> image0 = tif[0].asarray()
>>> for page in tif:
... for tag in page.tags.values():
... t = tag.name, tag.value
... image = page.asarray()
... if page.is_rgb: pass
... if page.is_palette:
... t = page.color_map
... if page.is_stk:
... t = page.mm_uic_tags.number_planes
... if page.is_lsm:
... t = page.cz_lsm_info
>>> tif.close()
- class PYME.contrib.gohlke.tifffile.TIFFfile(filename)¶
Bases:
object
Read image and meta-data from TIFF, STK, LSM, and FluoView files.
TIFFfile instances must be closed using the close method.
- Attributes
- pageslist
All TIFFpages in file.
- serieslist of Records(shape, dtype, axes, TIFFpages)
TIFF pages with compatible shapes and types.
- All attributes are read-only.
Initialize instance from file.
- asarray(key=None, series=None)¶
Return image data of multiple TIFF pages as numpy array.
By default the first image series is returned.
- close()¶
Close open file handle(s).
- fstat¶
Lazy object attribute whose value is computed on first access.
- is_bigtiff¶
Lazy object attribute whose value is computed on first access.
- is_fluoview¶
Lazy object attribute whose value is computed on first access.
- is_lsm¶
Lazy object attribute whose value is computed on first access.
- is_nih¶
Lazy object attribute whose value is computed on first access.
- is_ome¶
Lazy object attribute whose value is computed on first access.
- is_palette¶
Lazy object attribute whose value is computed on first access.
- is_rgb¶
Lazy object attribute whose value is computed on first access.
- is_stk¶
Lazy object attribute whose value is computed on first access.
- series¶
Lazy object attribute whose value is computed on first access.
- PYME.contrib.gohlke.tifffile.imread(filename, *args, **kwargs)¶
Return image data from TIFF file as numpy array.
The first image series is returned if no arguments are provided.
- PYME.contrib.gohlke.tifffile.imsave(filename, data, photometric=None, planarconfig=None, resolution=None, description=None, software='tifffile.py', byteorder=None, bigtiff=False)¶
Write image data to TIFF file.
Image data are written uncompressed in one stripe per plane. Dimensions larger than 2 or 3 (depending on photometric mode and planar configuration) are flattened and saved as separate pages.
- PYME.contrib.gohlke.tifffile.imshow(data, title=None, vmin=0, vmax=None, cmap=None, bitspersample=None, photometric='rgb', interpolation='nearest', dpi=96, figure=None, subplot=111, maxdim=4096, **kwargs)¶
Plot n-dimensional images using matplotlib.pyplot.
Return figure, subplot and plot axis. Requires pyplot already imported
from matplotlib import pyplot
.