
;c]c           @  s  d  Z  d d l m Z m Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l	 Z	 d d l
 Z
 d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d Z d Z d d d d	 d
 d d d d d d d d d d d d f Z d   Z e e e d d d d d  Z e e e d d d  Z  d e! f d     YZ" d e! f d      YZ# d
 e! f d!     YZ$ d" e! f d#     YZ% d$ e! f d%     YZ& d& e! f d'     YZ' d( e! f d)     YZ( d* e! f d+     YZ) d e! f d,     YZ* d e! f d-     YZ+ d. e! f d/     YZ, d0 e! f d1     YZ- d2 e! f d3     YZ. e. d4 e! f d5     Y Z/ e e d6  Z0 d7   Z1 d8   Z2 d9   Z3 d:   Z4 d;   Z5 d<   Z6 d=   Z7 d>   Z8 d?   Z9 d@   Z: e dA  Z; dB   Z< dC   Z= dD   Z> dE   Z? dF   Z@ dG   ZA dH   ZB dI   ZC dJ   ZD dK   ZE dL   ZF dM   ZG dN   ZH dO   ZI dP   ZJ dQ   ZK dR   ZL dS   ZM dT   ZN dU   ZO dV   ZP dW   ZQ e eR dX e e e dY  ZS e dZ  ZT d[   ZU d\   ZV e d]  ZW d^   ZX d_   ZY d`   ZZ da   Z[ db   Z\ dc   Z] e^ e dd de  Z_ df   Z` e_ dg  dh    Za e_ di  dj    Zb e_ dk  d dl   Zc dm dn do dn f ed dp  Ze e_ dq  dr    Zf ed ds  Zg dt   Zh du   Zi dv   Zj dw dx  Zk dy dz  Zl d{ d|  Zm e d} d~  Zn d   Zo d d d  Zp d d d  Zq d   Zr d d  Zs d   Zt d d f d d f d  Zu e d  Zv d d  Zw d   Zx d   Zy d   Zz d   Z{ d   Z| e j j} d  d  Z~ d d  Z d   Z d   Z ed e d  Z d d d d d d  Z d   Z eR d  Z d   Z d d ed d  Z d d d d  Z d   Z d   Z d   Z d d f d  Z e d d f ed d  Z e d e e e d e d e d d d  Z d   Z d   Z e d  Z e j d d k re e f Z d   Z e e d  Z e d  Z d   Z d e f d     YZ e& Z' nB e Z e e f Z e Z e Z e d d  Z d d  Z d   Z e d k re j e    n  d S(   s8  Read image and meta data from (bio) TIFF(R) files. Save numpy arrays as TIFF.

Image and metadata can be read from TIFF, BigTIFF, OME-TIFF, STK, LSM, NIH,
SGI, ImageJ, MicroManager, FluoView, ScanImage, SEQ, GEL, and GeoTIFF files.

Tifffile is not a general-purpose TIFF library.
Only a subset of the TIFF specification is supported, mainly uncompressed and
losslessly compressed 1, 8, 16, 32 and 64 bit integer, 16, 32 and 64-bit float,
grayscale and RGB(A) images, which are commonly used in scientific imaging.
Specifically, reading slices of image data, image trees defined via SubIFDs,
CCITT and OJPEG compression, chroma subsampling without JPEG compression,
or IPTC and XMP metadata are not implemented.

TIFF(R), the tagged Image File Format, is a trademark and under control of
Adobe Systems Incorporated. BigTIFF allows for files greater than 4 GB.
STK, LSM, FluoView, SGI, SEQ, GEL, and OME-TIFF, are custom extensions
defined by Molecular Devices (Universal Imaging Corporation), Carl Zeiss
MicroImaging, Olympus, Silicon Graphics International, Media Cybernetics,
Molecular Dynamics, and the Open Microscopy Environment consortium
respectively.

For command line usage run C{python -m tifffile --help}

:Author:
  `Christoph Gohlke <https://www.lfd.uci.edu/~gohlke/>`_

:Organization:
  Laboratory for Fluorescence Dynamics, University of California, Irvine

:Version: 2018.06.15

Requirements
------------
* `CPython 3.6 64-bit <https://www.python.org>`_
* `Numpy 1.14 <http://www.numpy.org>`_
* `Matplotlib 2.2 <https://www.matplotlib.org>`_ (optional for plotting)
* `Tifffile.c 2018.02.10 <https://www.lfd.uci.edu/~gohlke/>`_
  (recommended for faster decoding of PackBits and LZW encoded strings)
* `Tifffile_geodb.py 2018.02.10 <https://www.lfd.uci.edu/~gohlke/>`_
  (optional enums for GeoTIFF metadata)
* Python 2 requires 'futures', 'enum34', 'pathlib'.

Revisions
---------
2018.06.15
    Pass 2680 tests.
    Towards reading JPEG and other compressions via imagecodecs package (WIP).
    Add function to validate TIFF using 'jhove -m TIFF-hul'.
    Save bool arrays as bilevel TIFF.
    Accept pathlib.Path as filenames.
    Move 'software' argument from TiffWriter __init__ to save.
    Raise DOS limit to 16 TB.
    Lazy load lzma and zstd compressors and decompressors.
    Add option to save IJMetadata tags.
    Return correct number of pages for truncated series (bug fix).
    Move EXIF tags to TIFF.TAG as per TIFF/EP standard.
2018.02.18
    Pass 2293 tests.
    Always save RowsPerStrip and Resolution tags as required by TIFF standard.
    Do not use badly typed ImageDescription.
    Coherce bad ASCII string tags to bytes.
    Tuning of __str__ functions.
    Fix reading 'undefined' tag values (bug fix).
    Read and write ZSTD compressed data.
    Use hexdump to print byte strings.
    Determine TIFF byte order from data dtype in imsave.
    Add option to specify RowsPerStrip for compressed strips.
    Allow memory map of arrays with non-native byte order.
    Attempt to handle ScanImage <= 5.1 files.
    Restore TiffPageSeries.pages sequence interface.
    Use numpy.frombuffer instead of fromstring to read from binary data.
    Parse GeoTIFF metadata.
    Add option to apply horizontal differencing before compression.
    Towards reading PerkinElmer QPTIFF (no test files).
    Do not index out of bounds data in tifffile.c unpackbits and decodelzw.
2017.09.29 (tentative)
    Many backwards incompatible changes improving speed and resource usage:
    Pass 2268 tests.
    Add detail argument to __str__ function. Remove info functions.
    Fix potential issue correcting offsets of large LSM files with positions.
    Remove TiffFile sequence interface; use TiffFile.pages instead.
    Do not make tag values available as TiffPage attributes.
    Use str (not bytes) type for tag and metadata strings (WIP).
    Use documented standard tag and value names (WIP).
    Use enums for some documented TIFF tag values.
    Remove 'memmap' and 'tmpfile' options; use out='memmap' instead.
    Add option to specify output in asarray functions.
    Add option to concurrently decode image strips or tiles using threads.
    Add TiffPage.asrgb function (WIP).
    Do not apply colormap in asarray.
    Remove 'colormapped', 'rgbonly', and 'scale_mdgel' options from asarray.
    Consolidate metadata in TiffFile _metadata functions.
    Remove non-tag metadata properties from TiffPage.
    Add function to convert LSM to tiled BIN files.
    Align image data in file.
    Make TiffPage.dtype a numpy.dtype.
    Add 'ndim' and 'size' properties to TiffPage and TiffPageSeries.
    Allow imsave to write non-BigTIFF files up to ~4 GB.
    Only read one page for shaped series if possible.
    Add memmap function to create memory-mapped array stored in TIFF file.
    Add option to save empty arrays to TIFF files.
    Add option to save truncated TIFF files.
    Allow single tile images to be saved contiguously.
    Add optional movie mode for files with uniform pages.
    Lazy load pages.
    Use lightweight TiffFrame for IFDs sharing properties with key TiffPage.
    Move module constants to 'TIFF' namespace (speed up module import).
    Remove 'fastij' option from TiffFile.
    Remove 'pages' parameter from TiffFile.
    Remove TIFFfile alias.
    Deprecate Python 2.
    Require enum34 and futures packages on Python 2.7.
    Remove Record class and return all metadata as dict instead.
    Add functions to parse STK, MetaSeries, ScanImage, SVS, Pilatus metadata.
    Read tags from EXIF and GPS IFDs.
    Use pformat for tag and metadata values.
    Fix reading some UIC tags (bug fix).
    Do not modify input array in imshow (bug fix).
    Fix Python implementation of unpack_ints.
2017.05.23
    Pass 1961 tests.
    Write correct number of SampleFormat values (bug fix).
    Use Adobe deflate code to write ZIP compressed files.
    Add option to pass tag values as packed binary data for writing.
    Defer tag validation to attribute access.
    Use property instead of lazyattr decorator for simple expressions.
2017.03.17
    Write IFDs and tag values on word boundaries.
    Read ScanImage metadata.
    Remove is_rgb and is_indexed attributes from TiffFile.
    Create files used by doctests.
2017.01.12
    Read Zeiss SEM metadata.
    Read OME-TIFF with invalid references to external files.
    Rewrite C LZW decoder (5x faster).
    Read corrupted LSM files missing EOI code in LZW stream.
2017.01.01
    Add option to append images to existing TIFF files.
    Read files without pages.
    Read S-FEG and Helios NanoLab tags created by FEI software.
    Allow saving Color Filter Array (CFA) images.
    Add info functions returning more information about TiffFile and TiffPage.
    Add option to read specific pages only.
    Remove maxpages argument (backwards incompatible).
    Remove test_tifffile function.
2016.10.28
    Pass 1944 tests.
    Improve detection of ImageJ hyperstacks.
    Read TVIPS metadata created by EM-MENU (by Marco Oster).
    Add option to disable using OME-XML metadata.
    Allow non-integer range attributes in modulo tags (by Stuart Berg).
2016.06.21
    Do not always memmap contiguous data in page series.
2016.05.13
    Add option to specify resolution unit.
    Write grayscale images with extra samples when planarconfig is specified.
    Do not write RGB color images with 2 samples.
    Reorder TiffWriter.save keyword arguments (backwards incompatible).
2016.04.18
    Pass 1932 tests.
    TiffWriter, imread, and imsave accept open binary file streams.
2016.04.13
    Correctly handle reversed fill order in 2 and 4 bps images (bug fix).
    Implement reverse_bitorder in C.
2016.03.18
    Fix saving additional ImageJ metadata.
2016.02.22
    Pass 1920 tests.
    Write 8 bytes double tag values using offset if necessary (bug fix).
    Add option to disable writing second image description tag.
    Detect tags with incorrect counts.
    Disable color mapping for LSM.
2015.11.13
    Read LSM 6 mosaics.
    Add option to specify directory of memory-mapped files.
    Add command line options to specify vmin and vmax values for colormapping.
2015.10.06
    New helper function to apply colormaps.
    Renamed is_palette attributes to is_indexed (backwards incompatible).
    Color-mapped samples are now contiguous (backwards incompatible).
    Do not color-map ImageJ hyperstacks (backwards incompatible).
    Towards reading Leica SCN.
2015.09.25
    Read images with reversed bit order (FillOrder is LSB2MSB).
2015.09.21
    Read RGB OME-TIFF.
    Warn about malformed OME-XML.
2015.09.16
    Detect some corrupted ImageJ metadata.
    Better axes labels for 'shaped' files.
    Do not create TiffTag for default values.
    Chroma subsampling is not supported.
    Memory-map data in TiffPageSeries if possible (optional).
2015.08.17
    Pass 1906 tests.
    Write ImageJ hyperstacks (optional).
    Read and write LZMA compressed data.
    Specify datetime when saving (optional).
    Save tiled and color-mapped images (optional).
    Ignore void bytecounts and offsets if possible.
    Ignore bogus image_depth tag created by ISS Vista software.
    Decode floating point horizontal differencing (not tiled).
    Save image data contiguously if possible.
    Only read first IFD from ImageJ files if possible.
    Read ImageJ 'raw' format (files larger than 4 GB).
    TiffPageSeries class for pages with compatible shape and data type.
    Try to read incomplete tiles.
    Open file dialog if no filename is passed on command line.
    Ignore errors when decoding OME-XML.
    Rename decoder functions (backwards incompatible).
2014.08.24
    TiffWriter class for incremental writing images.
    Simplify examples.
2014.08.19
    Add memmap function to FileHandle.
    Add function to determine if image data in TiffPage is memory-mappable.
    Do not close files if multifile_close parameter is False.
2014.08.10
    Pass 1730 tests.
    Return all extrasamples by default (backwards incompatible).
    Read data from series of pages into memory-mapped array (optional).
    Squeeze OME dimensions (backwards incompatible).
    Workaround missing EOI code in strips.
    Support image and tile depth tags (SGI extension).
    Better handling of STK/UIC tags (backwards incompatible).
    Disable color mapping for STK.
    Julian to datetime converter.
    TIFF ASCII type may be NULL separated.
    Unwrap strip offsets for LSM files greater than 4 GB.
    Correct strip byte counts in compressed LSM files.
    Skip missing files in OME series.
    Read embedded TIFF files.
2014.02.05
    Save rational numbers as type 5 (bug fix).
2013.12.20
    Keep other files in OME multi-file series closed.
    FileHandle class to abstract binary file handle.
    Disable color mapping for bad OME-TIFF produced by bio-formats.
    Read bad OME-XML produced by ImageJ when cropping.
2013.11.03
    Allow zlib compress data in imsave function (optional).
    Memory-map contiguous image data (optional).
2013.10.28
    Read MicroManager metadata and little-endian ImageJ tag.
    Save extra tags in imsave function.
    Save tags in ascending order by code (bug fix).
2012.10.18
    Accept file like objects (read from OIB files).
2012.08.21
    Rename TIFFfile to TiffFile and TIFFpage to TiffPage.
    TiffSequence class for reading sequence of TIFF files.
    Read UltraQuant tags.
    Allow float numbers as resolution in imsave function.
2012.08.03
    Read MD GEL tags and NIH Image header.
2012.07.25
    Read ImageJ tags.
    ...

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

Tested on little-endian platforms only.

Other Python packages and modules for reading (bio) scientific TIFF files:

*  `python-bioformats <https://github.com/CellProfiler/python-bioformats>`_
*  `Imread <https://github.com/luispedro/imread>`_
*  `PyLibTiff <https://github.com/pearu/pylibtiff>`_
*  `ITK <https://www.itk.org>`_
*  `PyLSM <https://launchpad.net/pylsm>`_
*  `PyMca.TiffIO.py <https://github.com/vasole/pymca>`_ (same as fabio.TiffIO)
*  `BioImageXD.Readers <http://www.bioimagexd.net/>`_
*  `Cellcognition.io <http://cellcognition.org/>`_
*  `pymimage <https://github.com/ardoi/pymimage>`_
*  `pytiff <https://github.com/FZJ-INM1-BDA/pytiff>`_

Acknowledgements
----------------
*   Egor Zindy, University of Manchester, for lsm_scan_info specifics.
*   Wim Lewis for a bug fix and some LSM functions.
*   Hadrien Mary for help on reading MicroManager files.
*   Christian Kliche for help writing tiled and color-mapped files.

References
----------
1)  TIFF 6.0 Specification and Supplements. Adobe Systems Incorporated.
    http://partners.adobe.com/public/developer/tiff/
2)  TIFF File Format FAQ. http://www.awaresystems.be/imaging/tiff/faq.html
3)  MetaMorph Stack (STK) Image File Format.
    http://support.meta.moleculardevices.com/docs/t10243.pdf
4)  Image File Format Description LSM 5/7 Release 6.0 (ZEN 2010).
    Carl Zeiss MicroImaging GmbH. BioSciences. May 10, 2011
5)  The OME-TIFF format.
    http://www.openmicroscopy.org/site/support/file-formats/ome-tiff
6)  UltraQuant(r) Version 6.0 for Windows Start-Up Guide.
    http://www.ultralum.com/images%20ultralum/pdf/UQStart%20Up%20Guide.pdf
7)  Micro-Manager File Formats.
    http://www.micro-manager.org/wiki/Micro-Manager_File_Formats
8)  Tags for TIFF and Related Specifications. Digital Preservation.
    http://www.digitalpreservation.gov/formats/content/tiff_tags.shtml
9)  ScanImage BigTiff Specification - ScanImage 2016.
    http://scanimage.vidriotechnologies.com/display/SI2016/
    ScanImage+BigTiff+Specification
10) CIPA DC-008-2016: Exchangeable image file format for digital still cameras:
    Exif Version 2.31.
    http://www.cipa.jp/std/documents/e/DC-008-Translation-2016-E.pdf

Examples
--------
>>> # write numpy array to TIFF file
>>> data = numpy.random.rand(4, 301, 219)
>>> imsave('temp.tif', data, photometric='minisblack')

>>> # read numpy array from TIFF file
>>> image = imread('temp.tif')
>>> numpy.testing.assert_array_equal(image, data)

>>> # iterate over pages and tags in TIFF file
>>> with TiffFile('temp.tif') as tif:
...     images = tif.asarray()
...     for page in tif.pages:
...         for tag in page.tags.values():
...             _ = tag.name, tag.value
...         image = page.asarray()

i(   t   divisiont   print_functionNs
   2018.06.15s   restructuredtext ent   imsavet   imreadt   imshowt   memmapt   TiffFilet
   TiffWritert   TiffSequencet
   FileHandlet   lazyattrt   natural_sortedt
   decode_lzwt	   stripnullt   create_outputt	   repeat_ndt   format_sizet   productt   xml2dictc           s  t  | d d  } t  | d  } t   t  r^ t   f d   d D  r^ t j      n    ss t d   n  t   d  r t    d k r   d	   n  t   t  s t   d  r t   |   } | j	 |   SWd
 QXn% t
   |   } | j	 |   SWd
 QXd
 S(   s  Return image data from TIFF file(s) as numpy array.

    Refer to the TiffFile class and member functions for documentation.

    Parameters
    ----------
    files : str, binary stream, or sequence
        File name, seekable binary stream, glob pattern, or sequence of
        file names.
    kwargs : dict
        Parameters 'multifile' and 'is_ome' are passed to the TiffFile class.
        The 'pattern' parameter is passed to the TiffSequence class.
        Other parameters are passed to the asarray functions.
        The first image series is returned if no arguments are provided.

    Examples
    --------
    >>> # get image from first page
    >>> imsave('temp.tif', numpy.random.rand(3, 4, 301, 219))
    >>> im = imread('temp.tif', key=0)
    >>> im.shape
    (4, 301, 219)

    >>> # get images from sequence of files
    >>> ims = imread(['temp.tif', 'temp.tif'])
    >>> ims.shape
    (2, 3, 4, 301, 219)

    t	   multifilet   is_omet   patternc         3  s   |  ] } |   k Vq d  S(   N(    (   t   .0t   i(   t   files(    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>  s    s   ?*s   no files foundt   seeki   i    N(   t   parse_kwargst
   isinstancet
   basestringt   anyt   globt
   ValueErrort   hasattrt   lenR   t   asarrayR   (   R   t   kwargst   kwargs_filet
   kwargs_seqt   tift   imseq(    (   R   s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR     s    +"i   i    i   c   
   	   K  s#  t  | d d d d  } | d k rU t |  t j |  j } t j |  j } n9 y | j } | j j } Wn t k
 r d } d } n X| | k r d | k r | j	 d t
  p | j	 d t
  r t | d <n  d | k r | | d <n  t |  |   }	 |	 j | | | |  SWd QXd S(   s
  Write numpy array to TIFF file.

    Refer to the TiffWriter class and member functions for documentation.

    Parameters
    ----------
    file : str or binary stream
        File name or writable binary stream, such as an open file or BytesIO.
    data : array_like
        Input image. The last dimensions are assumed to be image depth,
        height, width, and samples.
        If None, an empty array of the specified shape and dtype is
        saved to file.
        Unless 'byteorder' is specified in 'kwargs', the TIFF file byte order
        is determined from the data's dtype or the dtype argument.
    shape : tuple
        If 'data' is None, shape of an empty array to save to the file.
    dtype : numpy.dtype
        If 'data' is None, data-type of an empty array to save to the file.
    bigsize : int
        Create a BigTIFF file if the size of data in bytes is larger than
        this threshold and 'imagej' or 'truncate' are not enabled.
        By default, the threshold is 4 GB minus 32 MB reserved for metadata.
        Use the 'bigtiff' parameter to explicitly specify the type of
        file created.
    kwargs : dict
        Parameters 'append', 'byteorder', 'bigtiff', and 'imagej', are passed
        to TiffWriter(). Other parameters are passed to TiffWriter.save().

    Returns
    -------
    If the image data are written contiguously, return offset and bytecount
    of image data in the file.

    Examples
    --------
    >>> # save a RGB image
    >>> data = numpy.random.randint(0, 255, (256, 256, 3), 'uint8')
    >>> imsave('temp.tif', data, photometric='rgb')

    >>> # save a random array and metadata, using compression
    >>> data = numpy.random.rand(2, 5, 3, 301, 219)
    >>> imsave('temp.tif', data, compress=6, metadata={'axes': 'TZCYX'})

    t   appendt   bigtifft	   byteordert   imageji    t   truncateN(   R   t   NoneR   t   numpyt   dtypet   itemsizeR*   t   nbytest	   Exceptiont   gett   Falset   TrueR   t   save(
   t   filet   datat   shapeR/   t   bigsizeR#   t   tifargst   sizeR*   R&   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR     s"    /	
%i    s   r+c         K  sY  | d k	 rz | d k	 rz | j d d d | d | d t d t j  t |  |  } | d k rm t d   n  | d } n t |  |   }	 | d k	 r |	 j | } | j	 s t d   n  | j
 \ } }
 | j } | j } nF |	 j | } | j d k rt d   n  | j } | j } | j } |	 j | j } Wd QXt j |  | | | | d	  S(
   sT  Return memory-mapped numpy array stored in TIFF file.

    Memory-mapping requires data stored in native byte order, without tiling,
    compression, predictors, etc.
    If 'shape' and 'dtype' are provided, existing files will be overwritten or
    appended to depending on the 'append' parameter.
    Otherwise the image data of a specified page or series in an existing
    file will be memory-mapped. By default, the image data of the first page
    series is memory-mapped.
    Call flush() to write any changes in the array to the file.
    Raise ValueError if the image data in the file is not memory-mappable.

    Parameters
    ----------
    filename : str
        Name of the TIFF file which stores the array.
    shape : tuple
        Shape of the empty array.
    dtype : numpy.dtype
        Data-type of the empty array.
    page : int
        Index of the page which image data to memory-map.
    series : int
        Index of the page series which image data to memory-map.
    mode : {'r+', 'r', 'c'}, optional
        The file open mode. Default is to open existing file for reading and
        writing ('r+').
    kwargs : dict
        Additional parameters passed to imsave() or TiffFile().

    Examples
    --------
    >>> # create an empty TIFF file and write to memory-mapped image
    >>> im = memmap('temp.tif', shape=(256, 256), dtype='float32')
    >>> im[255, 255] = 1.0
    >>> im.flush()
    >>> im.shape, im.dtype
    ((256, 256), dtype('float32'))
    >>> del im

    >>> # memory-map image data in a TIFF file
    >>> im = memmap('temp.tif', page=0)
    >>> im[255, 255]
    1.0

    R8   R9   R/   t   returnoffsett   aligns"   image data are not memory-mappablei    Nt   C(   R-   t   updateR5   t   TIFFt   ALLOCATIONGRANULARITYR   R   R   t   pagest   is_memmappablet   is_contiguousR9   R/   t   seriest   offsetR*   t   charR.   R   (   t   filenameR9   R/   t   pageRF   t   modeR#   t   resultRG   R&   t   _(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR     s.    0!
					c           B  s&   e  Z d  Z d Z d   Z d   Z RS(   s2   Attribute whose value is computed on first access.t   funcc         C  s   | |  _  d  S(   N(   RN   (   t   selfRN   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   __init__Z  s    c         C  s   | d  k r |  Sy |  j |  } Wn t k
 rD } t |   n X| t k rm t t | |  |  j j  St | |  j j |  | S(   N(	   R-   RN   t   AttributeErrort   RuntimeErrort   NotImplementedt   getattrt   supert   __name__t   setattr(   RO   t   instancet   ownert   valuet   e(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   __get__`  s    (   RN   (   RV   t
   __module__t   __doc__t	   __slots__RP   R\   (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR
   U  s   	c           B  s   e  Z d  Z e e e e d  Z e e e e e e e e d e d e e e e e e d i  e f  d  Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z RS(   s  Write numpy arrays to TIFF file.

    TiffWriter instances must be closed using the 'close' method, which is
    automatically called when using the 'with' context manager.

    TiffWriter's main purpose is saving nD numpy array's as TIFF,
    not to create any possible TIFF format. Specifically, JPEG compression,
    SubIFDs, ExifIFD, or GPSIFD tags are not supported.

    Examples
    --------
    >>> # successively append images to BigTIFF file
    >>> data = numpy.random.rand(2, 5, 3, 301, 219)
    >>> with TiffWriter('temp.tif', bigtiff=True) as tif:
    ...     for i in range(data.shape[0]):
    ...         tif.save(data[i], compress=6, photometric='minisblack')

    c   	        so  | ry t  | d d d d  } | j   } z yq t |  _   | d k r| t   f d   d( D  r| t d   n    j }   j }   j j |  _	 Wd QXWn) t
 k
 r } t d t |    n XWd | j |  XWd QXWqt t f k
 rt } qXn  | d) k r6t j d k r-d n d } n | d* k rUt d |   n  | rq| rqt j d  n  | |  _ t |  |  _ t |  _ d |  _ d |  _ d |  _ d |  _ d |  _ d |  _ d |  _ d |  _ d |  _  d |  _! d |  _" d |  _# | r=t$ |  _% d |  _& d |  _' d |  _( d |  _) d |  _* n6 t |  _% d |  _& d |  _' d |  _( d |  _) d |  _* | rt  | d d  d d |  _+ |  j+ j d d!  n t  | d d" d d |  _+ |  j+ j, i d# d 6d$ d 6|  | r|  j+ j, t- j. | d% d& d d   n  |  j+ j, t- j. | d d'   |  j+ j   |  _	 |  j+ j, t- j. | |  j) d   d S(+   s  Open a TIFF file for writing.

        An empty TIFF file is created if the file does not exist, else the
        file is overwritten with an empty TIFF file unless 'append'
        is true. Use bigtiff=True when creating files larger than 4 GB.

        Parameters
        ----------
        file : str, binary stream, or FileHandle
            File name or writable binary stream, such as an open file
            or BytesIO.
        bigtiff : bool
            If True, the BigTIFF format is used.
        byteorder : {'<', '>', '=', '|'}
            The endianness of the data in the file.
            By default, this is the system's native byte order.
        append : bool
            If True and 'file' is an existing standard TIFF file, image data
            and tags are appended to the file.
            Appending data may corrupt specifically formatted TIFF files
            such as LSM, STK, ImageJ, NIH, or FluoView.
        imagej : bool
            If True, write an ImageJ hyperstack compatible file.
            This format can handle data types uint8, uint16, or float32 and
            data shapes up to 6 dimensions in TZCYXS order.
            RGB images (S=3 or S=4) must be uint8.
            ImageJ's default byte order is big-endian but this implementation
            uses the system's native byte order by default.
            ImageJ does not support BigTIFF format or LZMA compression.
            The ImageJ file format is undocumented.

        RK   t   rbR<   i    t   forcec         3  s"   |  ] } t    d  |  Vq d S(   t   is_N(   RT   (   R   t   a(   R&   (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>  s    t   lsmt   stkR+   t   niht   fluoviewt   micromanagers   file contains metadataNs   cannot append to file: %st   =t   |t   littlet   <t   >s   invalid byteorder %ss#   writing incompatible BigTIFF ImageJi   i   t   Qt   8si   i   t   Ht   It   4ss   r+bi   t   wbt   IIt   MMt   HHHi+   i*   (   Rd   Re   R+   Rf   Rg   Rh   (   NRi   Rj   (   Rl   Rm   (/   R	   t   tellR   R   R   R*   t
   is_bigtiffRC   t   next_page_offsett
   _ifdoffsetR2   t   strR   t   IOErrort   FileNotFoundErrorR4   R-   t   syst   warningst   warnt
   _byteordert   boolt   _imagejt	   _truncatet	   _metadatat	   _colormapt   _descriptionoffsett   _descriptionlent   _descriptionlenoffsett   _tagst   _shapet
   _datashapet
   _datadtypet   _dataoffsett   _databytecountst   _tagoffsetsR5   t   _bigtifft   _offsetsizet   _tagsizet   _tagnoformatt   _offsetformatt   _valueformatt   _fht   writet   structt   pack(	   RO   R7   R)   R*   R(   R+   t   fht   posR[   (    (   R&   s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRP     s    "  																											") i   i    s   tifffile.pyc   T        sV  |  j  } |  j   | d k r] | r3 t d   n  | } t j |  j    } | j } n[ t j |   | j j d  } | j	 d k r t d   n  | j
 } | j } | j j } | o | j } | d k } | rA| d d k r d n d } t | |   } | | d	 r,| | | d	 d 9} qT| | | d	 9} n t |  | j } t |
  |  _ |  j r| s|  j d | k s|  j | k s| r|  j s| st j | |  j  r|  j   |  j   t |  _ d |  _ d |  _ d |  _ d |  _ |  j rt d
   qq|  j d d f | |  _ | s| j   } | d k re| j |  n | j |  | r| | f Sd Sn  | } |  j } |  j  |  j   |  j!  |  j" }  t# j$ j% }! t# j$ j& }" t# j$ j' }# t# j$ j( }$ t# j) j* }% t# j) j+ }& | d k	 r%t, t# j$ |  } n  | r@t, t# j) |  } n  | s[t } d }' t } n t- | t. t/ f  r| \ } }( nZ t- | t0  rd t0 |  } }( d |( k od k n st d |   qn d }( | j1   } t, t# j2 |  }' |  j r| do k rt d   n  | r7t3 j4 d  d } n  t }) | d k r\t d |   n  | rn| |" k n d }* | d k rt }* n  t5 | |*  }+ |+ d dp k r|" } | d k rt d |   qn | d k r|! } d } n  | |& k rt d   q|* r|% n d } n  | r|( d k rCt# j6 |' \  }( n t# j6 |' \  }, t0 |(  }( | r| j7 d k rt d |   n  |(  f d  } q|(  f d  } n  | d k	 r/| d k rt d   n  t j | d    d! } | j
 d d" | j d	 f k r#t d#   n  | |  _ n  | rt. d$   | d  D  } t8 |  d k }) t8 |  d" k  s| d d% s| d d% st9 d&   | D  rt d'   qn dq } t }) t: | | |" k rd n d"  } | } t8 |  }- d }. d }/ |) r|- d k  rt }) n  | d k	 r8|$ } d } n  | d k r||! } | r_t# j$ j; } q|| |% k r|- d" k ry| d dr k ry|" } qyq|| |& k r|) r|- d k r| d( ds k r|" } qy|- d" k ry| d) dt k ry|" } qyq||- d" k r| d du k r|" } q||  j r)|! } q||) rT|- d k rT| d( dv k rT|" } q||- d" k r|| d) dw k r||" } q|n  | rt8 |  |) rd n d" k rd } |! } n  | |" k r	t8 |  d k  rt d*   n  t8 |  d k  rt }) n  | d k rs	| d dx k r	|% } qs	| |) r+	d( n d) dy k rA	|& } qs	| d | |) rW	d( n d) k rj	|& } qs	|% } n  | |% k r	dz | |) r	d( n d) } | d }. n( d{ | |) r	d( n d) d| } | d }. |. d k r[|. d }/ q[nq| |# k r]
t8 |  d" k r
t d+   n  t }) d } d} | d d~ } d, d-   | D k r[t d.   q[n | r
t8 |  |) rx
d n d" k r
| |% k r
d | |) r
d( n d) } | d }. n( d | |) r
d( n d) d } | d }. |. d }/ nr d } x0 t8 |  d" k r!| d d k r!| d  } q
Wt8 |  d k  r=t }) n  d | |) rOd) n d d } t8 |  d k sst<  t8 |  d/ k r| d"  d | d" } n  | d d k rt |  t | d  }0 |0 f | d } n  | } | d k	 r | j= |  } n  | r'|) r'd | d | d f } n  | |$ k rw|. d k se|/ se| d d k se| d d k rwt d1   qwn  | |" k r|. d" k rt d2   n  | r| rt d3   n  | rt d4   n  | d k rt d5 t> |    n  t/ |  } | d d	 r&| d d	 d | d <n | d d	 | d <t. |  } | t |  k s\t<  | d k	 rt j? | d6 d } | d | j
 d k st<  qn  t@ jA d d7 k rtB n d8    g   | rd9 n d: }1 t# jC |1 d; }2 t# jC |1 d< }3 |3 |  _D   f d=    t       f d>  }4 d? d@  }5 | rc|4 dA dB d | dC tE n  | soi  n	 | jF   |  _G |  j rtH | | d d k |  j d k	 |  jG  } nL | s| i  k r|  j r|  jG jI dD tE  n  tJ | |  jG  } n d } | rOtK | dE  } | dF dG 7} t8 |  |  _L |4 dA dB d | dC tE n  | rq|4 dH dB d | dC tE n  | d k r|  jM   } n  |4 dI dB d | jN dJ  dC tE |4 dK d! d |'  | r|4 dL d! d d"  n  |4 dM dN d | d  |4 dO dN d | d)  | r|4 dP dN d | d  |4 dQ dN d | d  | d d k r|4 dR dN d | d(  |4 dS dN d | d  qn  |4 dT dN d d  | si d dU 6d" dV 6d dW 6d0 dX 6| j7 }6 |4 dY d! |. |6 f |.  n  |4 dZ d! d | jO  | d k	 r|4 d[ d! | j	 |  n  |4 d\ d! d |.  | r9nf | r|. d k r|4 d] d! d | jO  |4 d^ d! |. | j d	 f |.  n |4 d^ d! d | j d	  |/ r| |" k r|/ d k r|4 d_ d! d d  q|4 d_ d! |/ d |/  n  | d k	 r|4 d` da d |5 | d   |4 db da d |5 | d   t8 |  d" k rv| d" }7 |7 d k rad n t, t# jP |7  }7 n |  j rd }7 n d" }7 |4 dc d! d |7  nE |  j s|4 d` da d d  |4 db da d d  |4 dc d! d d  n  | rx$ tQ |    D] }8 |4 |8   qWn  | } | r!| d" | d d | d | d | d d | d | d | d" d | d" f }9 t |9  | d }: t |  | d | j g |: }; |4 |2  |: |;  |4 |3  |: d g |:  | ot |9  d k } | st jR | | d f d  | }< qny| r| rKt | d"  g | d }; n" t | d"  | j g | d }; |4 |2  | d |;  |4 |3  | d d g | d  |4 dd dN d | d)  n t | d  | j }= | d k rde |= } n  | d k  rd } n | | d) k r"| d) } n  |4 dd dN d |  | d) | d | }> |> | d 9}> d g |> }; |4 |2  |> d g |>  |4 |3  |> d g |>  | d k r| rt df   n  x | D] }8 |4 |8   qWtS  dg dh    |  jT p|  j r$| j   | d k r$t dj   n  xtU | r6d n | d  D]}? | j   }@ |@ d" rw| jV dF  |@ d 7}@ n  | jW |  jX  | jV   |@   | jW |@  | jV  | t8     | j   }A | jV dk jY dl    D   | j   |  _X | jV   d   xtZ   D]\ }B }C |C d" r$| j   }@ |@ d" rj| jV dF  |@ d 7}@ n  | jW |A |B |   d  | jV   |@   | jW |@  |C d |3 k r|@ }D n] |C d |2 k r|@ }E nD |C d dm k r |C d" j[ dn  r |@ |  _ |A |B |  d |  _ n  | jV |C d"  q$q$W| j   }F |	 |F |	 }G | jW |G d  |F |G 7}F | r| d k r| j |  qW| j |  n| r| d k r| j |: |; d  qWd }H x| |? D]}I xtU |9 d  D]}J xtU |9 d  D]}K xytU |9 d"  D]g}L t\ | d | d" |J | d  }M t\ | d | d |K | d  }N t\ | d" | d |L | d"  }O d |< |M d  |N d  |O d  f <|I |J | d |J | d |M  |K | d |K | d |N  |L | d" |L | d" |O  f |< d |M  d |N  d |O  f <| rn| |<  }8 | jV |8  t8 |8  |; |H <|H d 7}H q| j |<  | j]   qWqWqWqWn | rW| j
 d" d k st<  | d) | d | }> d }H x | |? D]r }I xi tU |>  D][ }P |I d |P | |P d |  f }Q | |Q  }Q | jV |Q  t8 |Q  |; |H <|H d 7}H qWqWn  | j   }@ xFtZ   D]8\ }B }C |C d |3 k r|C d" r| jW |D  |F }R xd |; D]& }S | jV   |R   |R |S 7}R qWq| jW |A |B |   d  | jV   |F   qp|C d |2 k rp| r|C d" rj| jW |E  x^ |; D] }S | jV   |S   qGWq| jW |A |B |   d  | jV   |; d   n  PqpqpW| jW |@  | j]   |? d k rAg   D] }C |C d s|C ^ q qAqAW| |  _^ d | |  _ | |  _ |F |  __ |; |  _` | rR |  _ | rR|F ta |;  f Sn  d S(   s  Write numpy array and tags to TIFF file.

        The data shape's last dimensions are assumed to be image depth,
        height (length), width, and samples.
        If a colormap is provided, the data's dtype must be uint8 or uint16
        and the data values are indices into the last dimension of the
        colormap.
        If 'shape' and 'dtype' are specified, an empty array is saved.
        This option cannot be used with compression or multiple tiles.
        Image data are written uncompressed in one strip per plane by default.
        Dimensions larger than 2 to 4 (depending on photometric mode, planar
        configuration, and SGI mode) are flattened and saved as separate pages.
        The SampleFormat and BitsPerSample tags are derived from the data type.

        Parameters
        ----------
        data : numpy.ndarray or None
            Input image array.
        shape : tuple or None
            Shape of the empty array to save. Used only if 'data' is None.
        dtype : numpy.dtype or None
            Data-type of the empty array to save. Used only if 'data' is None.
        returnoffset : bool
            If True and the image data in the file is memory-mappable, return
            the offset and number of bytes of the image data in the file.
        photometric : {'MINISBLACK', 'MINISWHITE', 'RGB', 'PALETTE', 'CFA'}
            The color space of the image data.
            By default, this setting is inferred from the data shape and the
            value of colormap.
            For CFA images, DNG tags must be specified in 'extratags'.
        planarconfig : {'CONTIG', 'SEPARATE'}
            Specifies if samples are stored contiguous or in separate planes.
            By default, this setting is inferred from the data shape.
            If this parameter is set, extra samples are used to store grayscale
            images.
            'CONTIG': last dimension contains samples.
            'SEPARATE': third last dimension contains samples.
        tile : tuple of int
            The shape (depth, length, width) of image tiles to write.
            If None (default), image data are written in strips.
            The tile length and width must be a multiple of 16.
            If the tile depth is provided, the SGI ImageDepth and TileDepth
            tags are used to save volume data.
            Unless a single tile is used, tiles cannot be used to write
            contiguous files.
            Few software can read the SGI format, e.g. MeVisLab.
        contiguous : bool
            If True (default) and the data and parameters are compatible with
            previous ones, if any, the image data are stored contiguously after
            the previous one. Parameters 'photometric' and 'planarconfig'
            are ignored. Parameters 'description', datetime', and 'extratags'
            are written to the first page of a contiguous series only.
        align : int
            Byte boundary on which to align the image data in the file.
            Default 16. Use mmap.ALLOCATIONGRANULARITY for memory-mapped data.
            Following contiguous writes are not aligned.
        truncate : bool
            If True, only write the first page including shape metadata if
            possible (uncompressed, contiguous, not tiled).
            Other TIFF readers will only be able to read part of the data.
        compress : int or 'LZMA', 'ZSTD'
            Values from 0 to 9 controlling the level of zlib compression.
            If 0 (default), data are written uncompressed.
            Compression cannot be used to write contiguous files.
            If 'LZMA' or 'ZSTD', LZMA or ZSTD compression is used, which is
            not available on all platforms.
        rowsperstrip : int
            The number of rows per strip used for compression.
            Uncompressed data are written in one strip per plane.
        predictor : bool
            If True, apply horizontal differencing to integer type images
            before compression.
        colormap : numpy.ndarray
            RGB color values for the corresponding data value.
            Must be of shape (3, 2**(data.itemsize*8)) and dtype uint16.
        description : str
            The subject of the image. Must be 7-bit ASCII. Cannot be used with
            the ImageJ format. Saved with the first page only.
        datetime : datetime
            Date and time of image creation in '%Y:%m:%d %H:%M:%S' format.
            If None (default), the current date and time is used.
            Saved with the first page only.
        resolution : (float, float[, str]) or ((int, int), (int, int)[, str])
            X and Y resolutions in pixels per resolution unit as float or
            rational numbers. A third, optional parameter specifies the
            resolution unit, which must be None (default for ImageJ),
            'INCH' (default), or 'CENTIMETER'.
        software : str
            Name of the software used to create the file. Must be 7-bit ASCII.
            Saved with the first page only.
        metadata : dict
            Additional meta data to be saved along with shape information
            in JSON or ImageJ formats in an ImageDescription tag.
            If None, do not write a second ImageDescription tag.
            Strings must be 7-bit ASCII. Saved with the first page only.
        ijmetadata : dict
            Additional meta data to be saved in application specific
            IJMetadata and IJMetadataByteCounts tags. Refer to the
            imagej_metadata_tags function for valid keys and values.
            Saved with the first page only.
        extratags : sequence of tuples
            Additional tags as [(code, dtype, count, value, writeonce)].

            code : int
                The TIFF tag Id.
            dtype : str
                Data type of items in 'value' in Python struct format.
                One of B, s, H, I, 2I, b, h, i, 2i, f, d, Q, or q.
            count : int
                Number of data values. Not used for string or byte string
                values.
            value : sequence
                'Count' values compatible with 'dtype'.
                Byte strings must contain count values of dtype packed as
                binary data.
            writeonce : bool
                If True, the tag is written to the first page only.

        s!   cannot save compressed empty fileR?   i    s   cannot save empty arrayt   ?ii   ii   s+   ImageJ does not support non-contiguous dataNt   ADOBE_DEFLATEi	   s   invalid compression level %st   LZMAt   ZSTDs-   ImageJ cannot handle LZMA or ZSTD compressions&   not writing description to ImageJ filet   BHhfs$   ImageJ does not support data type %st   Bi   i   s,   ImageJ does not support data type %s for RGBs%   ImageJ does not support planar imagest   ius!   prediction not implemented for %sc           sP   t  j |  d d } t  j | d |  d d d  d   f d d }    |  |  S(   Nt   axisii    .(   R.   t   difft   insert(   R8   t   levelR   (   t
   compressor(    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   compress  s    .c           s     |  |  S(   N(    (   R8   R   (   R   (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR     s    t   BHs#   invalid data dtype for palette modeR/   Rp   i   s   invalid color map shapec         s  s   |  ] } t  |  Vq d  S(   N(   t   int(   R   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>  s    i   c         s  s   |  ] } | d  k  Vq d S(   i   N(    (   R   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>  s    s   invalid tile shapeiis   not a RGB(A) images   invalid CFA imagei  c         s  s   |  ] } | d  Vq d S(   i    N(    (   R   t   et(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>T  s    s#   must specify DNG tags for CFA imagei   i   s#   invalid data shape for palette modes#   not a RGB image (samplesperpixel=2)s$   cannot save compressed bilevel images   cannot save tiled bilevel images   cannot save bilevel image as %sR   t   2c         S  s    t  |  t  r t |  d  S|  S(   Nt   ascii(   R   R{   t   bytes(   t   x(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   <lambda>  t    t   Tilet   Stript
   ByteCountst   Offsetsc           s   t  j   |  |  S(   N(   R   R   (   t   fmtt   val(   R*   (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR     s    c   
        s  t  t j j |  |    }  y t j | } Wn! t k
 rO t d |   n X| } | d k r   |  d } t |  } } | j d  } | d k  r | } n
 | d 7} | f } nP t	 | t
  rt j |  } t |  | r t d   n  t |  | } n  t |  d k r?| t  | d   9} | d } n   d	 |  |    |  g } d  }	 t j |  |  k r)t	 | t
  r| j   |   q| d k rt	 | t t t j f  r| d } n  | j    | |    q| j    t |  | |    n | j   d   t	 | t
  rW| }	 n t	 | t j  r| j | k s~t  | j j | k st  | j   }	 n@ t	 | t t f  r t |  | |  }	 n  | |  }	  j |  d
 j |  |	 | f  d  S(   Ns   unknown dtype %st   ss    s     i    i   s   invalid packed binary datait   HHR   (   R   RA   t	   TAG_NAMESR3   t   DATA_DTYPESt   KeyErrorR   R!   t   findR   R   R   t   calcsizeR-   R(   t   tuplet   listR.   t   ndarrayR{   R<   t   AssertionErrorR/   RH   t   tostringt   join(
   t   codeR/   t   countRZ   t	   writeoncet   tifftypet   rawcountt   dtsizet   ifdentryt   ifdvalue(   t   bytestrt   offsetformatt
   offsetsizeR   t   tagst   valueformat(    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   addtag  sZ    	
" 	i@B c         S  sm   d d l  m } y | j |   } Wn( t k
 rM | |  d |  d  } n X| j |  } | j | j f S(   s=   "Return nominator and denominator from float or two integers.i(   t   Fractioni    i   (   t	   fractionsR   t
   from_floatt	   TypeErrort   limit_denominatort	   numeratort   denominator(   t   argt   max_denominatorR   t   f(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   rational  s    t   ImageDescriptionR   R   t	   truncatedR   s    i@   t   Softwaret   DateTimes   %Y:%m:%d %H:%M:%St   Compressiont	   Predictort
   ImageWidthRq   t   ImageLengtht	   TileWidtht
   TileLengtht
   ImageDeptht	   TileDeptht   NewSubfileTypet   uR   R   t   ct   SampleFormatt   PhotometricInterpretationt   ColorMapt   SamplesPerPixelt   PlanarConfigurationt   BitsPerSamplet   ExtraSamplest   XResolutiont   2It   YResolutiont   ResolutionUnitt   RowsPerStripi   s&   cannot write non-contiguous empty filet   keyc         S  s   |  d S(   Ni    (    (   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR   f  R   i   s%   data too large for standard TIFF fileR   c         s  s   |  ] } | d  Vq d S(   i   N(    (   R   t   t(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>|  s    i  s       (   R   R   (   i   i   (    (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   ii   (   i(   i   (   ii   (   i   (   ii   (   i(   i   (   ii   (   i   (   i   i   (   i   (   i    i   (   i   i   (   i    (   i   i   (   i   i   I       i(   i   (b   R   R   R-   R   R.   R/   t   newbyteorderRH   R"   R<   R9   t   isnativeR   R0   R   R   R   R   R   t   array_equalR   t   _write_remaining_pagest   _write_image_descriptionR4   R   R   R   Rw   t   write_emptyt   write_arrayR   R   R   R   R   RA   t   PHOTOMETRICt
   MINISBLACKt   RGBt   CFAt   PALETTEt   PLANARCONFIGt   CONTIGt   SEPARATEt   enumargR   R   R   R   t   uppert   COMPRESSIONR   R   t   imagej_shapet
   COMPESSORSt   kindR!   R   t
   reshape_ndt
   MINISWHITER   t   reshapeR{   t   packbitsR~   t   versionR   R   R   R5   t   copyR   t   imagej_descriptionR@   t   json_descriptiont	   str2bytesR   t   _nowt   strftimeRZ   t   RESUNITt   imagej_metadata_tagst   emptyt   sortedR   t   rangeR   R   Rz   R   t	   enumeratet   endswitht   mint   flushR   R   R   t   sum(T   RO   R8   R9   R/   R=   t   photometrict   planarconfigt   tilet
   contiguousR>   R,   R   t   rowsperstript	   predictort   colormapt   descriptiont   datetimet
   resolutiont   softwaret   metadatat
   ijmetadatat	   extratagsR   t	   datashapet	   datadtypet   datadtypechart   bilevelt   indext   datasizeRG   t   input_shapet   tagnoformatt   tagsizeR  R  R  R  R	  R
  t   compresstagt   compresslevelt   volumet   ijrgbt   ijshapeRM   t   ndimt   samplesperpixelt   extrasamplest   s0t   strip_or_tilet   tagbytecountst   tag_offsetsR   R   t   sampleformatt   unitR   t   tilest   numtilest   stripbytecountst   chunkt   rowsizet	   numstripst	   pageindexR   t
   tag_offsett   tagindext   tagt   stripoffsetsoffsett   strip_bytecounts_offsett   data_offsett   skipt
   stripindext   planet   tzt   tyt   txt   c0t   c1t   c2R   t   stript   strip_offsetR<   (    (   R*   R   R   R   R   R   R   R   s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR6     s   ~					

						
										 .!		"				"	$				 		
$
%	 #		!:
		)
'			!"&""	#
 

		#	
###%C"


*					c           sI  |  j  s |  j r d S|  j } | j   } | d rP | j d  | d 7} n  |  j   |  j } |  j } |  j } |  j	 } |  j
 } t |  j  } |  j d |  j d d }	   f d   }
 t j   } | j |
 | t |  j     | j   } | j d j d   |  j  D   | j   } | j |
 | d   x@t |  j   D]/\ } } | | | | d	 } | d rY| j   } | d r| j d  | d 7} n  | j |  y | j |
 | | |   Wn@ t k
 r|  j rt j d
  t |  _ d St d   n X| j |  | j | d  | d |  j k r{| } | } q{qL| d |  j k rLd } | } qLqLW| j   d r| j d  n  | j   } |  j r| | j   |	 d k r|  j rt j d
  t |  _ d St d   n  xt |	  D]} | j   } | j |  j  | j |
 | |   | j |  | | |  _ | | 7} | d k r| j |  | j |
 | |   nn | j |  | j |
 | | |   | j |  | } x1 |  j D]& } | j |
 | |   | | 7} qW| j | j     qWd |  _  d |  _! d |  _
 d |  _ d S(   s(   Write outstanding IFDs and tags to file.Ni   s    i   i    c           s   t  j   |  |  S(   N(   R   R   (   R   R   (   R*   (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR     s    R   c         s  s   |  ] } | d  Vq d S(   i   N(    (   R   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>  s    i   s   truncating ImageJ files#   data too large for non-BigTIFF filei    i   I       I     ("   R   R   R   Rw   R   R   R   R   R   R   R   R%  R   R   R   t   iot   BytesIOR!   R   R!  R   R2   R   R   R   R5   R   R   R-   R   R   Rz   t   getvalueR   (   RO   R   t   fhposR   R   R;  R<  t
   dataoffsett   pagedatasizet   pagenoR   t   ifdt	   tagoffsett	   ifdoffsetRS  RT  t   offset2valueR   t   stripoffset2offsett   stripoffset2valueRM   t   stripoffsetR<   (    (   R*   s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR     s    	
						#

		$		
			c         C  sR  |  j  s, |  j  d d k s, |  j d k r0 d S|  j d k	 } |  j ry |  j d d k } t |  j  | | |  j  } n t |  j  |  j  } | j	 d  } | |  j
 d  } |  j j   } |  j j |  j  |  j j |  |  j j |  j  |  j j t j |  j |  j t |  d   |  j j |  d |  _ d |  _ d |  _
 d S(	   s(   Write meta data to ImageDescription tag.i    i   Nii   i   s   utf-8(   i   i   (   R   R   R   R-   R   R   R  R   R  t   encodeR   R   Rw   R   R   R   R   R   R   R   R!   (   RO   t   colormappedt   isrgbR-  R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR   V  s*    			c         C  s   t  j  j   S(   s   Return current date and time.(   R.  t   now(   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  s  s    c         C  s1   |  j  s |  j   n  |  j   |  j j   d S(   s,   Write remaining pages and close file handle.N(   R   R   R   R   t   close(   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRu  w  s    	
c         C  s   |  S(   N(    (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt	   __enter__~  s    c         C  s   |  j    d  S(   N(   Ru  (   RO   t   exc_typet	   exc_valuet	   traceback(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   __exit__  s    (   RV   R]   R^   R4   R-   RP   R5   R6   R   R   R  Ru  Rv  Rz  (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR   n  s$   	l		   	d				c           B  sZ  e  Z d  Z d0 d0 d0 e d0 d  Z e d    Z e d    Z e	 d    Z
 d   Z d0 d0 d0 e d d  Z e	 d    Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d d d  Z e	 d    Z e	 d    Z e d    Z e	 d    Z  e	 d    Z! e	 d    Z" e	 d     Z# e	 d!    Z$ e	 d"    Z% e	 d#    Z& e	 d$    Z' e	 d%    Z( e	 d&    Z) e	 d'    Z* e	 d(    Z+ e	 d)    Z, e	 d*    Z- e	 d+    Z. e	 d,    Z/ e	 d-    Z0 e	 d.    Z1 e d/    Z2 RS(1   s  Read image and metadata from TIFF file.

    TiffFile instances must be closed using the 'close' method, which is
    automatically called when using the 'with' context manager.

    Attributes
    ----------
    pages : TiffPages
        Sequence of TIFF pages in file.
    series : list of TiffPageSeries
        Sequences of closely related TIFF pages. These are computed
        from OME, LSM, ImageJ, etc. metadata or based on similarity
        of page properties such as shape, dtype, and compression.
    byteorder : '>', '<'
        The endianness of data in the file.
        '>': big-endian (Motorola).
        '>': little-endian (Intel).
    is_flag : bool
        If True, file is of a certain format.
        Flags are: bigtiff, movie, shaped, ome, imagej, stk, lsm, fluoview,
        nih, vista, 'micromanager, metaseries, mdgel, mediacy, tvips, fei,
        sem, scn, svs, scanimage, andor, epics, pilatus, qptiff.

    All attributes are read-only.

    Examples
    --------
    >>> # read image array from TIFF file
    >>> imsave('temp.tif', numpy.random.rand(5, 301, 219))
    >>> with TiffFile('temp.tif') as tif:
    ...     data = tif.asarray()
    >>> data.shape
    (5, 301, 219)

    c      
   K  sv  d | k r" | d =t  d   n  x| | j   D]n \ } }	 | d  d k r | d t j k r |	 d$ k	 r |	 r t |  | t |	   q q/ t d |   q/ Wt | d d d | d	 | d
 | }
 |
 |  _	 t |  |  _
 i |  |
 j 6|  _ ya|
 j d  y% i d d 6d d 6|
 j d  } Wn t k
 rDt d   n Xi d d 6d d 6t j } | | k |  _ t j | d |
 j d   d } | d k rHt |  _ t j | d |
 j d   \ } } | s| d k rt d   n  | |  _ d |  _ | d |  _ d |  _ | d |  _ d |  _ | d |  _ | d |  _ n| | d k rt |  _ | |  _ d |  _ | d |  _ d |  _ | d |  _ d |  _ | d |  _ | d  |  _ n t d!   t  |   |  _! |  j" r;|  j# j$ d% k s|  j! d j% d# k s|  j! d# j% d# k r;|  j&   |  j'   |  j(   n | rPt |  j! _) n  Wn t* k
 rq|
 j+     n Xd$ S(&   s  Initialize instance from file.

        Parameters
        ----------
        arg : str or open file
            Name of file or open file object.
            The file objects are closed in TiffFile.close().
        name : str
            Optional name of file in case 'arg' is a file handle.
        offset : int
            Optional start position of embedded file. By default, this is
            the current file position.
        size : int
            Optional size of embedded file. By default, this is the number
            of bytes from the 'offset' to the end of the file.
        multifile : bool
            If True (default), series may include pages from multiple files.
            Currently applies to OME-TIFF only.
        movie : bool
            If True, assume that later pages differ from first page only by
            data offsets and byte counts. Significantly increases speed and
            reduces memory usage when reading movies with thousands of pages.
            Enabling this for non-movie files will result in data corruption
            or crashes. Python 3 only.
        kwargs : bool
            'is_ome': If False, disable processing of OME-XML metadata.

        t   fastijs!   the fastij option will be removedi   Rb   s   unexpected keyword argument: %sRK   R`   t   nameRG   R<   i    Rl   Rt   Rm   Ru   i   s   not a TIFF filet   bigRk   Rp   i+   R   i   i   s   invalid BigTIFF fileRn   i   t   Q8si*   Rq   i   t   I4ss   invalid TIFF filei    i   NI       (,   t   DeprecationWarningt   itemsRA   t
   FILE_FLAGSR-   RW   R   R   R	   R   t
   _multifileR|  t   _filesR   t   readR   R   R~   R*   R   R   t   unpackR5   Rx   R   R   t	   tagnosizeR;  R<  t
   tagformat1t
   tagformat2R4   t	   TiffPagesRC   t   is_lsmt
   filehandleR<   t   compressiont   _lsm_load_pagest   _lsm_fix_strip_offsetst   _lsm_fix_strip_bytecountst	   useframesR2   Ru  (   RO   R   R|  RG   R<   R   t   movieR#   R   RZ   R   R*   t   sys_byteorderR  R   t   zero(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRP     sr    #$	%#	%									


c         C  s   |  j  S(   s   Return file handle.(   R   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  
  s    c         C  s
   |  j  j S(   s   Return name of file handle.(   R   R|  (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRI     s    c         C  s3   y t  j |  j j    SWn t k
 r. d SXd S(   s3   Return status of file handle as stat_result object.N(   t   ost   fstatR   t   filenoR2   R-   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c         C  s4   x$ |  j  j   D] } | j j   q Wi  |  _  d S(   s   Close open file handle(s).N(   R  t   valuesR  Ru  (   RO   R&   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRu    s    i   c   
      C  s;  |  j  s t j g   S| d k r7 | d k r7 d } n  | d k	 rz y |  j | } Wn t t f k
 rm n X| j } n	 |  j  } | d k r ny t | t	  r | | g } nZ t | t
  r | | } n> t | t j  r g  | D] } | | ^ q } n t d   | s t d   n  |  j rJt | d | d | d t } n| d k r| r| j r|  j | j j }	 | d k r| d j r|  j j |	 | j | j  } qb| d k	 rt | | j | j  } n  |  j j | j  |  j j |	 t | j  d | d t } nI t |  d	 k rJ| d j d | d
 |  } n t | d | d | } | d k rrd S| d k ry | j | _ Wq7t k
 ry1 t  j! d | j | j f  d | j | _ Wqt k
 rd | d j | _ qXq7Xn9 t |  d	 k r#| d j | _ n d | d j | _ | S(   sB  Return image data from multiple TIFF pages as numpy array.

        By default, the data from the first series is returned.

        Parameters
        ----------
        key : int, slice, or sequence of page indices
            Defines which pages to return as array.
        series : int or TiffPageSeries
            Defines which series of pages to return as array.
        out : numpy.ndarray, str, or file-like object; optional
            Buffer where image data will be saved.
            If None (default), a new array will be created.
            If numpy.ndarray, a writable array of compatible dtype and shape.
            If 'memmap', directly memory-map the image data in the TIFF file
            if possible; else create a memory-mapped array in a temporary file.
            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.
        validate : bool
            If True (default), validate various tags.
            Passed to TiffPage.asarray().
        maxworkers : int
            Maximum number of threads to concurrently get data from pages.
            Default is 1. If None, up to half the CPU cores are used.
            Reading data from file is limited to a single thread.
            Using multiple threads can significantly speed up this function
            if the bottleneck is decoding compressed data, e.g. in case of
            large LZW compressed LSM files.
            If the bottleneck is I/O or pure Python code, using multiple
            threads might be detrimental.

        i    s&   key must be an int, slice, or sequences   no pages selectedt   outt
   maxworkerst   squeezeR   t   nativei   t   validateNs   failed to reshape %s to %si(   i(   i(   i("   RC   R.   t   arrayR-   RF   R   R   t   _pagesR   t   inttypest   slicet   collectionst   IterableR   t   is_niht   stack_pagesR4   RG   R*   R/   RH   RD   R  t   memmap_arrayR9   R   R   t
   read_arrayR   R5   R!   R"   R   R   (
   RO   R   RF   R  R  R  RC   t   kRL   t   typecode(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR"   "  sl    "			 			$	c         C  s   |  j  s g  S|  j  j } |  j  j } g  } xD d j   D]6 } t |  d | t  r8 t |  d |    } Pq8 q8 W| |  j  _ | |  j  _ | s |  j   } n  g  | D]! } t | j  d k r | ^ q } x# t	 |  D] \ } } | | _
 q W| S(   s   Return related pages as TiffPageSeries.

        Side effect: after calling this function, TiffFile.pages might contain
        TiffPage and TiffFrame instances.

        s(   ome imagej lsm fluoview nih mdgel shapedRb   s
   _%s_seriesi    (   RC   R  t   keyframet   splitRT   R4   t   _generic_seriesR%  R9   R!  R8  (   RO   R  R  RF   R|  R   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRF     s"    	.c   
   	   C  s  |  j  j r |  j  d } | j } | j } t |  j   d k rc t |  j   f | } d | } n  t |  j  | | j | d d g S|  j  j t  |  j  j	   g  } g  } i  } t
 j } xy |  j  D]n } | j s q n  | j | j | j | k f } | | k r| | j |  q | j |  | g | | <q Wx | D] } | | }	 |	 d } | j } | j } t |	  d k rt |	  f | } d | } n  | j t |	 | | j | d d  qAW| S(   s   Return image series in file.i    i   Rq   t   stypeR  t   Generic(   RC   R  R9   t   axesR!   t   TiffPageSeriesR/   t   clearR4   t   loadRA   t   DECOMPESSORSR  R(   (
   RO   RJ   R9   R  RL   t   keysRF   t   compressionsR   RC   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    sD    		
		

		c         C  sW  |  j  } t | _ t |  } d   } d } } } } } g  }	 d }
 xt rR|
 | k rb Pn  |
 | _ | |
 } | j s t j d  d Sd } d } t	 | j  } | j
 d d  } | d } | j
 d d  } d	 | k r%| d	 } t |  t |  k r| } q%d } t j d
  n  | g } t |  } t | t | j   \ } } | rot j d  d Sd | k  o| |
 k n r)| | j j 9} | rd } q)| j r| j | | |
 d j k  rt } q)t } xB t |
 d |
 |  D]& } | | } | | _ | j |  qWn  | |	 | | | | | |  |
 | 7}
 qL W|	 S(   s%   Return image series in "shaped" file.c         S  sA  | d } | sW | j  } | j } t |  d k rW t |  f | } d | } qW n  t |  } t |  }	 | j r |	 | k r |	 | d k r | d  k r t } n  d | } |	 | f | } n  y t | | |  } | } Wn& t k
 r}
 t	 j
 t |
   n X|  j t | | | j | d | d d d |  d  S(   Ni    i   Rn   R|  R  t   ShapedR   (   R9   R  R!   R   RE   R-   R5   t   reshape_axesR   R   R   R{   R(   R  R/   (   RF   RC   R  R9   R  R|  R   RJ   R<   t   resizeR[   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   append_series  s,    
		%	

i    s(   invalid shape metadata or corrupted fileNR|  R   R9   R   R  s   axes do not match shapes&   series shape does not match page shapei   (   RC   R5   R  R!   R-   R  t	   is_shapedR   R   t   json_description_metadataR3   R   t   divmodR9   t   _dtypeR0   t   is_finalRG   R4   R   R(   (   RO   RC   t   lenpagesR  R  R  R9   R  R|  RF   R8  R1  R   t   spagesR<   t   npagest   modt   jRJ   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   _shaped_series  sb    					
	

		 			
	c      	     s  t   j _ d  j _  j    j   d       f d   } y |   } Wn t k
 rz t j d  d SX| r  g  n  j j   g  } g  } d   k r | j	   d  | j	 d  n  d   k r | j	   d  | j	 d  n  d	   k rP j
 d
 k o+  j d t  rP| j	   d	  | j	 d  n    j d t    | rwt |  n d } | d k r| j	 |  | j	 d  n   j d d k r| j  j d  | j  j d  n  j d
  d k rH j d d !t |   j d
 } t  j d  | t  j d
  } n  | j  j  | j  j  | ot  j  d k o j d t |   j d k } t  |  j | d d d | g S(   s#   Return image series in ImageJ file.i    c            s    j  s t S  j d d  }  |  d k r/ t S j \ } } | t  j   j d k sx | | |   j j k r t	    n  t
   d k r | | |   d j k r t St S(   Nt   imagesi    i   i   (   R  R4   R3   RE   R   R9   t   bitspersampleR  R<   R   R!   RG   R5   (   R  RG   R   (   t   ijRJ   RC   RO   (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   is_hyperstack-  s    	 -s)   invalid ImageJ metadata or corrupted fileNt   framest   Tt   slicest   Zt   channelsi   t
   hyperstackR?   R  i   Rq   t   SIi   R  t   ImageJR   (   R5   RC   R  R  t   imagej_metadataR   R   R   R  R(   R&  R3   R4   R!   R   R  t   extendR9   R   R   RE   R  R  R/   (   RO   R  R  R9   R  t   remainR   (    (   R  RJ   RC   RO   s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   _imagej_series"  sT    		
.%+$c      	   C  s   t  |  j _ d |  j _ |  j j   |  j } t t | d   } d j d   | D  } t	 d   | D  } t
 |  j | |  j d j | d | d d d	 g S(
   s%   Return image series in FluoView file.i    t
   DimensionsR   c         s  s>   |  ]4 } | d  d  k r t  j j | d j   d  Vq d S(   i   i    Rn   N(   RA   t   MM_DIMENSIONSR3   R  (   R   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>s  s   c         s  s/   |  ]% } | d  d  k r t  | d   Vq d S(   i   N(   R   (   R   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>u  s    R|  t	   ImageNameR  t   FluoView(   R5   RC   R  R  R  t   fluoview_metadataR   t   reversedR   R   R  R/   (   RO   t   mmt   mmhdR  R9   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   _fluoview_seriesl  s    	c      	     s   t  |  j _ d |  j _ |  j j   |  j } | d d k r t j d  } | d     d   d   | d d k r   f d   } q   f d	   } n d } |  j d } t	 | g | j
 | | j d
 | d d g S(   s#   Return image series in MD Gel file.i    t   FileTagi   i   t   float32t
   ScalePixeli   c           s   |  j  d  d   S(   NR  i   (   t   astype(   Rc   (   t   scale(    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt	   transform  s    c           s   |  j  d    S(   NR  (   R  (   Rc   (   R  (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    R  R  t   MDGel(   i   i   N(   R4   RC   R  R  R  t   mdgel_metadataR.   R/   R-   R  R9   R  (   RO   t   mdR/   R  RJ   (    (   R  s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   _mdgel_seriesy  s    	
c         C  s   t  |  j _ d |  j _ |  j j   |  j d } t |  j  d k r\ | j } | j } n& t |  j  f | j } d | j } t |  j | | j	 | d d g S(   s    Return image series in NIH file.i    i   Rq   R  t   NIH(
   R5   RC   R  R  R  R!   R9   R  R  R/   (   RO   t   page0R9   R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   _nih_series  s    	c   (        s	  d d l  m } |  j d j } y | j |  } Wnj | j k
 r } t j d |  y. | j d d  j	 d  } | j |  } Wq t
 k
 r d SXn Xt |  j _ d |  j _ |  j j   | j j d d  } i |  | 6|  _ |  j j } i  } g  } x| D]}	 |	 j j d	  r2t j d
  Pn  |	 j j d  rx]|	 D]R}
 |
 j j d d  j d  suqKn  x%|
 D]} x| D]} x| D] } | j d  j d  sqn  | j d } | j j d d  } t j | } d | j k rSt | j j d d   } t | j d  } t | j d  | } t j | | |  } n. g  | D]! } | j j d  rZ| j ^ qZ} | | f | | <qWqWq|WqKWn  |	 j j d  sq	n  |	 j     j d d  } x|	 D]} | j j d  sqn  | j     j d d  } d j t   d   } t   f d   | D  } t  | d   } d } d } xj| D]b} | j j d  r| j   | d k rt!   j d |   } d g | | } qot!   j d d   | k rot" d    qoqon  | d k rd g | | } n  | j j d!  s3qon  | j   t!   j d" d   } t!   j d# d"   k rrd n d   } t!   j d$ |   } g  | d  D]" }  t!   j d% |  d   ^ q}! y t j# |! | d   }! Wn! t" k
 rt j d&  qon Xx| D]R} | j j d  s,qn  | j |  j k r|  j$ sKg  S| j d' }" yD t% t& j' j | |"   }# t |# j _ d |# j _ |# j j   Wn, t( t) t" f k
 rt j d( |"  Pn X|# |  j | j <|# j*   n  |  j | j j }$ yC x< t+ | r| n	 t, |$   D] }% |$ | |% | |! |% <qWWn t- k
 r^t j d)  n XPqW|  j }$ yC x< t+ | r| n	 t, |$   D] }% |$ | |% | |! |% <qWWqot- k
 rt j d)  qoXqoWt. d*   | D  rqn  d }& x- | D]% }% |% r|% |% j k r|% }& PqqW|& sxV t/ |  D]E \ }% }& |& r:|& j0 |& j1 j _ |& j1 j |& j0 }& |& | |% <Pq:q:Wn  x& | D] }% |% d k	 r|& |% _ qqW|& j2 } | j3 t4 | | | | d+ |  d, | d- d.  qWq	Wx | D] }' t |' j5  } x | j6   D] \ } \ } } |' j7 j0 |  }% t, |  } | |% | k ru|' j7 j8 | | d  |' _7 q| |% c | <| j9 |% d |  |' j7 j8 | | | d  |' _7 qWt: |  |' _5 qWx/ | D]' }' t; |' j5 |' j7  \ |' _5 |' _7 qW| S(/   s(   Return image series in OME-TIFF file(s).i(   t   cElementTreei    s   ome-xml: %ss   utf-8t   ignoreNt   UUIDt
   BinaryOnlys$   ome-xml: not an ome-tiff master filet   StructuredAnnotationst	   NamespaceR   t   modulot   Alongt   Typet   othert   Startt   Stepi   t   Endt   Labelt   Imaget   Namet   Pixelst	   PixelTypet   DimensionOrderc         3  s#   |  ] } t    d  |  Vq d S(   t   SizeN(   R   (   R   t   ax(   t   attr(    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>  s    it   ChannelR   s'   cannot handle differing SamplesPerPixelt   TiffDatat   IFDt	   NumPlanest
   PlaneCountt   Firsts   ome-xml: invalid TiffData indext   FileNames   ome-xml: failed to read '%s's   ome-xml: index out of rangec         s  s   |  ] } | d  k Vq d  S(   N(   R-   (   R   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>%	  s    t   parentR|  R  t   OME(<   t	   xml.etreeR  RC   R-  t
   fromstringt
   ParseErrorR   R   t   decodeRq  R2   R5   R  R  R  t   attribR3   R-   R  R   t   dirnameRT  R"  RA   t   AXES_LABELSt   floatR.   t   aranget   textR   R  R   R   R   R   t   ravel_multi_indexR  R   R  t   pathR|   R}   Ru  R   R!   t
   IndexErrort   allR!  R8  R  R/   R(   R  R9   R  R  t   replaceR   R   t   squeeze_axes((   RO   t   etreet   omexmlt   rootR[   t   uuidR  R  RF   t   elementt   annotRZ   t   modult   alongR   t   newaxist   stept   startt   stopt   labelst   labelR|  t   pixelsR/   R  R9   R<   t   ifdst   sppR8   Rj  t   numR  t   idxt   fnameR&   RC   R   R  t   serie(    (   R   s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   _ome_series  s(   	!#				*3	%	%
	#%c   	   
     s  |  j    t j   d } |  j d j d k rQ | j d d  j d d  } n    j d d  d	 k rv | d
 7} n    j d d  d	 k r | d 7} n  | d d d  } t   f d   | D  }   j d d  } d |  j _ |  j d d d  } | d j	 } t
 | | | | d | d d g } |  j d	 j rd	 |  j _ |  j d	 d d  } | d j	 } d \ } } xD | t |  k  r| t |  d k  r| | | 9} | d	 7} q}W| |  | d j } | |  d } | j t
 | | | | d | d d  n  | S(   s6   Return main image series in LSM file. Skip thumbnails.t   ScanTypei    i   R?   R   t   XYt   XYCt
   DimensionPi   t   Pt
   DimensionMt   MNic         3  s&   |  ] } t    t j |  Vq d  S(   N(   R   RA   t   CZ_LSMINFO_DIMENSIONS(   R   R   (   t   lsmi(    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>\	  s    R  R|  R  t   LSMt   CYXt
   LSMreduced(   i   i    (   t   lsm_metadataRA   t   CZ_LSMINFO_SCANTYPERC   R&  R  R3   R   R  R/   R  t
   is_reducedR!   R9   R(   (	   RO   R  R9   R|  RC   R/   RF   t   cpR   (    (   R8  s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   _lsm_seriesQ	  s:    	!+c         C  s   t  |  j _ t  |  j _ d |  j _ |  j d } x' |  j d d d  D] } | | _ qH Wd |  j _ |  j d } x' |  j d d d  D] } | | _ q Wd S(   s   Load all pages from LSM file.i   Ni   i    (   R5   RC   t   cacheR  R  (   RO   R  RJ   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  s	  s    c         C  s#  |  j  j d
 k  r d S|  j } t |  } |  j d } | j } d } x5 d D]- } | j | d k rN | | j | 9} qN qN W| d k rCd } x/ d D]' } | | d k r | j | } Pq q W| r^t | d | |  \ } }	 |	 d k s t  | | | d f }
 t	 j
 t |
   j |
  } t	 j | d d  } q^n t	 j
 |  j d d  } | d j d | d j d k r| d	 d d d  f } n  d } d } xt | j D]i } | | } g  } xA | j D]6 } | | k  r| d 7} n  | j | |  | } qWt |  | _ qWd S(   s   Unwrap strip offsets for LSM files greater than 4 GB.

        Each series and position require separate unwrapping (undocumented).

        i   i    Ni    i   t   PMR  i.I       (   i    i   (   i   i   I       (   R  R<   RC   R!   RF   R  R9   R  R   R.   R  R   R  t   moveaxist   dataoffsetst   flatR(   R   (   RO   RC   R  RF   R  t	   positionsR   t   ntimest   divR  R9   t   indicest   wrapt   previousoffsetRJ   RD  t   currentoffset(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  	  sH    		"

c           s  |  j  } | d j d k r  d St | d d   } t |  d } x t |  D] \ } } | j d rq qR n  | j   | j } | | k  r | | d j d } n% t   d d | d |  j	 j
  }   | f   t   f d   t t |   D  | _ qR Wd S(	   s   Set databytecounts to size of compressed data.

        The StripByteCounts tag in LSM files contains the number of bytes
        for the uncompressed data.

        i    i   NR   c         S  s   |  j  d S(   Ni    (   RD  (   t   p(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR   	  R   i   ic         3  s%   |  ] }   | d    | Vq d S(   i   N(    (   R   R  (   t   offsets(    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>	  s   (   RC   R  R  R!   R!  R8  RD  t   databytecountsR#  R   R<   R   R   (   RO   RC   R  R   RJ   t
   bytecountst
   lastoffset(    (   RN  s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  	  s     			%c         C  sp   | d t  j k rP |  j s  t St t |  j d |   } t |  | |  | St d |  j j	 | f   d S(   s,   Return 'is_flag' attributes from first page.i   i    s!   '%s' object has no attribute '%s'N(
   RA   R  RC   R4   R   RT   RW   RQ   t	   __class__RV   (   RO   R|  RZ   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   __getattr__	  s    	c         C  s   |  S(   N(    (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRv  	  s    c         C  s   |  j    d  S(   N(   Ru  (   RO   Rw  Rx  Ry  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRz  	  s    i    iO   c           s  d t  |  j j  i d d 6d d 6|  j g } |  j rI | j d  n  | j d j d   |  j D   t |  j	  d	 k r | j d
 t |  j	   n  t |  j
  d	 k r | j d t |  j
   n  t |  j  d	 k r| j d t |  j   n  d j |  } | j d d  j d d  } | t |  j j t d  d t |    }   d k ro| S| g } | j d j d   |  j
 D     d k r| j    f d   |  j	 D  n# | j    f d   |  j
 D    d k r~x t |  j  D]k } t |  | d  rt |  | d  } | rw| j d | j   t | d  d   d f  qwqqWn  d j |  j d d  S(   s  Return string containing information about file.

        The detail parameter specifies the level of detail returned:

        0: file only.
        1: all series, first page of series and its tags.
        2: large tag values and file metadata.
        3: all pages.

        s   TiffFile '%s't   LittleEndianRl   t	   BigEndianRm   t   BigTiffRj   c         s  s   |  ] } | j    Vq d  S(   N(   R  (   R   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>	  s    i   s   %i Pagess	   %i Seriess   %i Filess     s       s      i   i   i    s   
c         s  s   |  ] } t  |  Vq d  S(   N(   R{   (   R   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>
  s    i   c         3  s6   |  ], } | d k	 r t j | d    d  Vq d S(   t   detailt   widthN(   R-   t   TiffPaget   __str__(   R   RM  (   RW  RX  (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>
  s   c         3  sD   |  ]: } | j  d  d k	 r t j | j  d  d   d  Vq d S(   i    RW  RX  N(   RC   R-   RY  RZ  (   R   R   (   RW  RX  (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>
  s   R   s   %s_METADATA
%sRX  t   heights   

s   


(   R   R   R<   R*   Rx   R(   R   t   flagsR!   RC   RF   R  R  t   snipstrR|  t   maxR  R  R    RT   R  t   pformat(   RO   RW  RX  t   infoR|  t   m(    (   RW  RX  s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRZ  	  sD    	#0	#c           s#   t    f d   t t j  D  S(   s   Return set of file flags.c         3  s.   |  ]$ } t    d  |  r | j   Vq d S(   Rb   N(   RT   t   lower(   R   R|  (   RO   (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>
  s    (   t   setR  RA   R  (   RO   (    (   RO   s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR\  
  s    c         C  s;   y" |  j  d j p  |  j  d j SWn t k
 r6 t SXd S(   s   File has MD Gel format.i    i   N(   RC   t   is_mdgelR  R4   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRd  
  s    "c         C  s
   |  j  j S(   s   Return if file is a movie.(   RC   R  (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   is_movie$
  s    c         C  s$   |  j  s d St d   |  j D  S(   s9   Return Tifffile metadata from JSON descriptions as dicts.Nc         s  s:   |  ]0 } | j  j   d  k r t | j d j  Vq d S(   t   shapedi    N(   R  Rb  R  RC   R  (   R   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>.
  s   (   R  R   RF   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   shaped_metadata)
  s    		c         C  s%   |  j  s d St |  j d j  d S(   s   Return OME XML as dict.Ni    R	  (   R   R   RC   R-  (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   ome_metadata1
  s    	c         C  sE   |  j  s d Sd } |  j d j j d | d |  } t |  | S(   s<   Return PerkinElmer-QPI-ImageDescription XML element as dict.Ns    PerkinElmer-QPI-ImageDescriptioni    t    (   t	   is_qptiffRC   R-  R  R   (   RO   R  t   xml(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   qptiff_metadata9
  s
    	$c         C  s"   |  j  s d S|  j d j d j S(   s0   Return LSM metadata from CZ_LSMINFO tag as dict.Ni    t
   CZ_LSMINFO(   R  RC   R   RZ   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR<  B
  s    	c         C  s  |  j  s d S|  j d } | j } i  } | d j | d <| j r\ | j j d  | d <n  d | k r | j | d j  n  d | k r | j | d j  n  d	 | k r | j | d	 j  n  | d j } | d
 | d
 <| d | d <| d | d <y t j	 g  t
 | d | d  D] } t |   ^ qd d | d <t j	 g  t
 | d | d  D] } t |   ^ q`d d | d <Wn$ t k
 r} t j d |  n X| S(   s*   Return STK metadata from UIC tags as dict.Ni    t   UIC2tagt   NumberPlaness    t   PlaneDescriptionst   UIC1tagt   UIC3tagt   UIC4tagt	   ZDistancet   TimeCreatedt   TimeModifiedt   DateCreatedR/   s   datetime64[ns]t   DatetimeCreatedt   DateModifiedt   DatetimeModifieds   stk_metadata: %s(   t   is_stkRC   R   R   R-  R  R@   RZ   R.   R  t   zipt   julian_datetimeR   R   R   (   RO   RJ   R   RL   t   uic2tagt   dtR[   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   stk_metadataI
  s<    			--c         C  sn   |  j  s d S|  j d } t | j   } d | j k rj y | j | j d j  Wqj t k
 rf qj Xn  | S(   s,   Return consolidated ImageJ metadata as dict.Ni    t
   IJMetadata(   t	   is_imagejRC   t   imagej_description_metadataR   R@   RZ   R2   (   RO   RJ   RL   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  m
  s    	c         C  sO   |  j  s d Si  } |  j d } | j | j d j  | j d j | d <| S(   s.   Return consolidated FluoView metadata as dict.Ni    t	   MM_Headert   MM_Stampt   Stamp(   t   is_fluoviewRC   R@   R   RZ   (   RO   RL   RJ   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  {
  s    		c         C  s"   |  j  s d S|  j d j d j S(   s:   Return NIH Image metadata from NIHImageHeader tag as dict.Ni    t   NIHImageHeader(   R  RC   R   RZ   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   nih_metadata
  s    	c         C  sO   |  j  s d S|  j d j } d | k r4 | d j Sd | k rK | d j Sd S(   s5   Return FEI metadata from SFEG or HELIOS tags as dict.Ni    t   FEI_SFEGt
   FEI_HELIOS(   t   is_feiRC   R   RZ   (   RO   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   fei_metadata
  s    	c         C  s"   |  j  s d S|  j d j d j S(   s,   Return SEM metadata from CZ_SEM tag as dict.Ni    t   CZ_SEM(   t   is_semRC   R   RZ   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   sem_metadata
  s    	c         C  s   x5 |  j  d  D]" } d | j k r | j } Pq q Wd Si  } xK t d d  D]: } t j | } | | k rs qN n  | | j | | d <qN W| S(   s6   Return consolidated metadata from MD GEL tags as dict.i   t	   MDFileTagNi  i  (   RC   R   R   RA   t   TAGSRZ   (   RO   RJ   R   RL   R   R|  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  
  s    	c         C  s   |  j  d j S(   s   Return Andor tags as dict.i    (   RC   t
   andor_tags(   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   andor_metadata
  s    c         C  s   |  j  d j S(   s'   Return EPICS areaDetector tags as dict.i    (   RC   t
   epics_tags(   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   epics_metadata
  s    c         C  s"   |  j  s d S|  j d j d j S(   s   Return TVIPS tag as dict.Ni    t   TVIPS(   t   is_tvipsRC   R   RZ   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   tvips_metadata
  s    	c         C  s!   |  j  s d St |  j d j  S(   s:   Return MetaSeries metadata from image description as dict.Ni    (   t   is_metaseriest   metaseries_description_metadataRC   R-  (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   metaseries_metadata
  s    	c         C  s!   |  j  s d St |  j d j  S(   s7   Return Pilatus metadata from image description as dict.Ni    (   t
   is_pilatust   pilatus_description_metadataRC   R-  (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   pilatus_metadata
  s    	c         C  s>   |  j  s d St |  j  } | j |  j d j d j  | S(   s2   Return consolidated MicroManager metadata as dict.Ni    t   MicroManagerMetadata(   t   is_micromanagert   read_micromanager_metadataR   R@   RC   R   RZ   (   RO   RL   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   micromanager_metadata
  s
    	c         C  s   |  j  s d Si  } y0 t |  j  \ } } | | d <| j |  Wn t k
 rV n Xy t |  j d j  | d <Wn$ t k
 r } t	 j
 d |  n X| S(   s<   Return ScanImage non-varying frame and ROI metadata as dict.Nt	   FrameDatai    t   Descriptions)   scanimage_description_metadata failed: %s(   t   is_scanimaget   read_scanimage_metadataR   R@   R   t   scanimage_description_metadataRC   R-  R2   R   R   (   RO   RL   t	   framedatat   roidataR[   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   scanimage_metadata
  s    	
c         C  s   |  j  s d S|  j d j S(   s0   Return GeoTIFF metadata from first page as dict.Ni    (   t
   is_geotiffRC   t   geotiff_tags(   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   geotiff_metadata
  s    	N(3   RV   R]   R^   R-   R5   RP   t   propertyR  RI   R
   R  Ru  R"   RF   R  R  R  R  R  R  R/  R@  R  R  R  RS  Rv  Rz  RZ  R\  Rd  Re  Rg  Rh  Rl  R<  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR     s^   #	`	d	)	T	J					"		5				3	$R  c           B  s   e  Z d  Z d   Z e d    Z e j d    Z e d    Z e j d    Z e d    Z e j d    Z e d    Z	 d	   Z
 e d
  Z d d  Z d   Z d   Z d   Z d   Z RS(   s(   Sequence of TIFF image file directories.c         C  s   | |  _  g  |  _ t |  _ t |  _ d |  _ t |  _	 | j
 } | j   |  _ t j | j | j | j   d } | d k r t |  _ d S| | j k r t j d |  t |  _ d S| j |  t | d d } |  j j |  | |  _ d S(   s   Initialize instance from file. Read first TiffPage from file.

        The file position must be at an offset to an offset to a TiffPage.

        i    Ns   invalid page offset (%i)R8  (   R  RC   R4   t   completeRY  t	   _tiffpageR-   t	   _keyframeR5   t   _cacheR  Rw   t   _nextpageoffsetR   R  R   R  R   R<   R   R   R   R(   (   RO   R  R   RG   RJ   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRP     s*    									c         C  s   |  j  S(   s1   Return if pages/frames are currenly being cached.(   R  (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRA  #  s    c         C  s6   t  |  } |  j r) | r) |  j   n  | |  _ d S(   s@   Enable or disable caching of pages/frames. Clear cache if False.N(   R   R  R  (   RO   RZ   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRA  (  s    c         C  s   |  j  t k o t t k	 S(   s?   Return if currently using TiffFrame (True) or TiffPage (False).(   R  t	   TiffFrameRY  (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  0  s    c         C  s   | r t  n t |  _ d S(   s0   Set to use TiffFrame (True) or TiffPage (False).N(   R  RY  R  (   RO   RZ   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  5  s    c         C  s
   |  j  j S(   s!   Return index of current keyframe.(   R  R8  (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  :  s    c         C  s   |  j  j | k r d S|  j sD d | k o? t |  j  k  n r |  j | } t | t  rm | |  _  d St | t  r | j |  j | <q n  |  j	 } t |  _
 |  | |  _  | |  _	 d S(   s;   Set current keyframe. Load TiffPage from file if necessary.Ni    (   R  R8  R  R!   RC   R   RY  R  RG   R  R  (   RO   R8  RJ   R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  ?  s    .			c         C  s    |  j  s |  j d  n  |  j S(   s7   Return offset where offset to a new page can be stored.i(   R  t   _seekR  (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRy   R  s    	c         C  s   |  j  j } |  j } |  j } |  j s7 |  j d  n  xa t |  D]S \ } } t | t  rD | j	 |  |  j
 |  j  d | d | } | | | <qD qD Wd S(   s#   Read all remaining pages from file.iR8  R  N(   R  R  R  RC   R  R  R!  R   R  R   R  (   RO   R   R  RC   R   RJ   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  Y  s    			c         C  s   |  j  } |  j s% t |  d k  r) d S| d |  _ | r x t | d  D]/ \ } } t | t  sM | j | | d <qM qM WnK t t	 k	 r x< t |  D]+ \ } } t | t  r | j | | <q q Wn  d S(   sA   Delete all but first page from cache. Set keyframe to first page.i   Ni    (
   RC   R  R!   R  R!  R   R  RG   R  RY  (   RO   t   fullyRC   R   RJ   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  f  s    	i   i   c         C  s  |  j  } | s d S|  j j } | j r7 t d   n  |  j sb d | k o] t |  k  n r | | } t | t  r | n | j	 } | j
 |  d S|  j j } |  j j } |  j j }	 |  j j }
 |  j j } t j } | d } t | t  r | n | j	 } xNt |  | k  rX| j
 |  y; | |	 | j |
   d } | d k rdt d   n  Wn3 t k
 rt j d |  | d =t |  _ Pn X| |
 | | |  _ | j
 |  j  | | | j |   d } | d k rt |  _ Pn  | | j k r"t j d |  t |  _ Pn  | j |  d | k oLt |  k  n rPqqW| t |  k rzt d	   n  | | } | j
 t | t  r| n | j	  d S(
   s&   Seek file to offset of specified page.Ns   FileHandle is closedi    ii   s   suspicious number of tagss   corrupted tag list at offset %is   invalid page offset (%i)s   list index out of range(   RC   R  R  t   closedRR   R  R!   R   R  RG   R   R   R   R;  R  R<  R   R  R  R   R2   R   R   R5   R  R<   R(   R  (   RO   R8  t   maxpagesRC   R   RJ   RG   R   R   R;  R  R<  R  t   tagno(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  w  s^    		+
	
			"
c         C  s   t  |  j  d k S(   s'   Return True if file contains any pages.i    (   R!   RC   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   __bool__  s    c         C  s&   |  j  s |  j d  n  t |  j  S(   s   Return number of pages in file.i(   R  R  R!   RC   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   __len__  s    	c         C  sk  |  j  } | s t d   n  | d k r2 | | St | t  r | j d
  \ } } } |  j r t | |  t |  k r |  j d  n  g  t	 | j t |     D] } |  | ^ q S|  j r | t |  k r t d   n  y | | } Wn t k
 rd } n Xt | t
  s#| S|  j |  |  j |  j d | d |  j } |  j rg| | | <n  | S(   s,   Return specified page(s) from cache or file.s   list index out of rangei    i   i   i   iR8  R  I       i(   RC   R  R   R  RI  R  R^  R!   R  R   R  R  R  R  R  (   RO   R   RC   R$  R%  RM   R   RJ   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   __getitem__  s.    	%0
!	c         c  sC   d } x6 t  r> y |  | V| d 7} Wq	 t k
 r: Pq	 Xq	 Wd S(   s   Return iterator over all pages.i    i   N(   R5   R  (   RO   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   __iter__  s    		i  @ (   RV   R]   R^   RP   R  RA  t   setterR  R  Ry   R  R5   R  R  R  R  R  R  (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  
  s    	"	>			RY  c           B  s)  e  Z d  Z d Z d Z d Z d Z d Z d Z d Z	 d Z
 d Z d5 Z d Z d Z d Z d Z d Z d Z d6 Z d Z d Z d Z d6 d  Z d6 e d6 e d7 e d  Z e d6 d6 d6 d6 d	  Z d
   Z e d    Z e j  d    Z e! d    Z" e! d    Z# e! d    Z$ e! d    Z% d d d  Z& e! d    Z' e d    Z( e d    Z) e! d    Z* e! d    Z+ e! d    Z, e d    Z- e d    Z. e d    Z/ e! d    Z0 e! d    Z1 e d    Z2 e d    Z3 e d     Z4 e d!    Z5 e d"    Z6 e d#    Z7 e d$    Z8 e d%    Z9 e d&    Z: e d'    Z; e d(    Z< e d)    Z= e d*    Z> e d+    Z? e d,    Z@ e d-    ZA e d.    ZB e d/    ZC e d0    ZD e d1    ZE e d2    ZF e d3    ZG RS(8   s  TIFF image file directory (IFD).

    Attributes
    ----------
    index : int
        Index of page in file.
    dtype : numpy.dtype or None
        Data type (native byte order) of the image in IFD.
    shape : tuple
        Dimensions of the image in IFD.
    axes : str
        Axes label codes:
        'X' width, 'Y' height, 'S' sample, 'I' image series|page|plane,
        'Z' depth, 'C' color|em-wavelength|channel, 'E' ex-wavelength|lambda,
        'T' time, 'R' region|tile, 'A' angle, 'P' phase, 'H' lifetime,
        'L' exposure, 'V' event, 'Q' unknown, '_' missing
    tags : dict
        Dictionary of tags in IFD. {tag.name: TiffTag}
    colormap : numpy.ndarray
        Color look up table, if exists.

    All attributes are read-only.

    Notes
    -----
    The internal, normalized '_shape' attribute is 6 dimensional:

    0 : number planes/images  (stk, ij).
    1 : planar samplesperpixel.
    2 : imagedepth Z  (sgi).
    3 : imagelength Y.
    4 : imagewidth X.
    5 : contig samplesperpixel.

    i    i   i   i    R   c           s3	  | |  _  | |  _ d' |  _ d( |  _ d
 |  _ d
 |  _ d |  _ i  |  _ d) |  _	 d* |  _
 | j } | j   |  _ yD t j | j | j | j   d } | d k r t d   n  Wn$ t k
 r t d |  j   n X| j } | j | |  } |  j } | } x*t |  D]}	 | | 7} y! t |  j  | | | | ! }
 Wn, t j k
 ru} t j t |   qn X|
 j } | | k r| } |
 | | <n= d } x4 t rd | | f } | | k r|
 | | <PqqWt j j  | d  } | r| d  d	 k rt! |
 j" t  rq2t# |  | |
 j"  qqW| s@d
 S|  j$ rS|  j% n |  j& rf|  j' n  |  j( s|  j r|  j  j( r|  j d j) |   n  |  j* s|  j r|  j  j* rd |  _+ n  |  j, r:d | k r:| d j" r:| d } | j- | j.  t/ | |  j  j0 | j | j1 d
 | d j1  | d _" n  d | k ry1 t2 | d j" | d j" |  j  j0  | d _" Wqt k
 r} t j t |   qXn  d | k r| d }
 |
 j1 d k r|
 j" |  _3 q|
 j" |  j4    t5   f d     D  r  |  _3 q  d |  _3 n  d | k r| d }
 |
 j1 d k rS|
 j" |  _6 q|
 j" |  j4    t5   f d     D  r  |  _6 q  d |  _6 n  d | k rd | k s| d j1 d k r|  j7 |  _8 qn  |  j6 |  j3 f } t j9 j  | d
  } | d
 k	 rt: j |  } n  | |  _ |  _ |  j7 } |  j; } |  j+ } |  j4 } |  j, r|  j+ d k sot<  | d j" } | d j1 } |  j= d k r| d d | | | f |  _ | d k r| | | f |  _ d |  _ qa| | | | f |  _ d |  _ nc | | d | | d f |  _ | d k rC| | | f |  _ d |  _ n | | | | f |  _ d |  _ | d k r|  j d |  _ qGt: j> | d d k  rd |  j |  _ qGt: j> t: j? | d  d k  rd |  j |  _ qGd |  j |  _ nS|  j@ d k s| d k r|  j= d k rd d | | | | f |  _ | d k rc| | | f |  _ d |  _ q| | | | f |  _ d |  _ qGd | | | | d f |  _ | d k r| | | f |  _ d |  _ qG| | | | f |  _ d |  _ n] d d | | | d f |  _ | d k r,| | f |  _ d |  _ n | | | f |  _ d  |  _ d! | k rf| d! j" |  _	 n( d" | k r| d" j" |  _	 n	 d+ |  _	 d# | k r| d# j" |  _
 n^ d$ | k r| d$ j" |  _
 n? tA |  j  |  j3 d% f |  _
 |  jB d k r	t j d&  n  tC |  j  tC |  j  k s/	t<  d
 S(,   sl   Initialize instance from file.

        The file handle position must be at offset to a valid IFD.

        R   i    i   s   suspicious number of tagss   corrupted tag list at offset %ii   s   %s%ii   s   sof desNR   Rq  Rn  R  t   IJMetadataByteCountsc         3  s   |  ] } |   d  Vq d S(   i    N(    (   R   t   v(   RZ   (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>  s    R   c         3  s   |  ] } |   d  Vq d S(   i    N(    (   R   R  (   RZ   (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>  s    R   R   t   YXt   YXSt   SYXRt  R  Ru  R  Rq   i   t   ZYXSt   SZYXt   ZYXt   TileOffsetst   StripOffsetst   TileByteCountst   StripByteCountsi   s"   required ByteCounts tag is missing(    (    (    (    (   i    (D   R  R8  R9   R   R-   R/   R  R  R   RD  RO  R  Rw   RG   R   R  R;  R  R  R   R2   R<  R   t   TiffTagt   ErrorR   R   R{   R|  R5   RA   t   TAG_ATTRIBUTESR3   R   RZ   RW   t   is_andorR  t   is_epicsR  R  t   _fix_lsm_bitspersamplet   is_vistat
   imagedepthR{  R   t   valueoffsett   read_uic1tagR*   R   R  R  RC  R   RI  t   imagelengthR*  t   SAMPLE_DTYPESR.   t
   imagewidthR   R'  R  R   R&  R   R  R!   (   RO   R  R8  R  R   R  R<  R8   R   RM   RT  R[   t   tagnameR|  R   t   uic1tagR/   R  R  R  RC  t   uictagt   planes(    (   RZ   s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRP   "  s6   													
!		
#	
	
#
#



						"			 i,   c   *        sn	   }  j    j s. t  j  d k r2 d S j } | sM | d k r| r t  j  | k r t d t  j    n   j d k r t d  j  j	 f   n   j
 t j k r t d  j
 j   n  d | k r:| d   j d k r:t  f d    j D  r:t d	  j   q:n   j rp j
 d
 k sa j d k rpt d   n  | d k rd Sn  | j j }	 | d k r|	 j n | } | 6 |	 j }
 |
 r| r|	 j   qt d   n  Wd QX j   j }  j }  j }  j }  j	    j j  j }  j  d k } | j! \ } }  j" } | r j# }  j$ }  j% } | | d | } | | d | } | | d | } | d | d | | | | | | | d f } | | | | d f } | } n | }  j d k r#|  j& 9} n  | d k rd j' rd| ! |	 j( | | d | d } Wd QXn j) r| d k	 rt* | |   } n  | 4 |	 j+ | d  |	 j, | t |  d | } Wd QX| d k r| j j- r| j. t/  | j0   } n  | ret1 |  qenPt* | |   } t j  j
 }  j
 d
 k r  d) k ret d     n  d | k r| d j } n d } t2 } t j3  j4  j }  | |   |  d  } nw   d* k r  | d rt d   n  |     f d  } n3 t5   t6  r|   d  } n |   | d  } | rd }! d+ \ } } } }" x
t7 |	 | | |  D]}# | rt1 |#  }# n  | |#  }# | |#  }# y | |# _8 Wnk t k
 rt9 j: d   t; j< |   j= d  }$ t> |# j? |$ j?  }% |# |%  |$ |% *|$ j= |  }# n X j@ d k r|! d k r>|# jA d! }! n  |! rft; jB |# d" d# d$  d |# qt; jB |# d" d# d$  }# n  j@ d% k rt    n  |# | d |" | | |  | | |  | | |  d d  f <~# | | 7} | | d& k red | | } } | | d% k rXd | | } } | | d k rUd |" d } }" qUqXqeqeW| d' d |  d |  d |  d d  f } n  jC  j }&  j d k r|&  j& 9}& n  | j= d  } d }' x t7 |	 | | |  D]w }( | rt1 |(  }( n  | |(  }( | |(  }( t> | j? |( j? |& | j? |'  }) |( |)  | |' |' |) +~( |' |) 7}' qW j | _8  j@ d k r	| o j) r	 j jD r j
 d k rq	 j@ d k rt; jB | d" d# d$  d | q	 j@ d% k r	tE |  } q	n  | rW	y  j8 | _8 WqW	t k
 rS	t9 j: d( t | j8  t  j8  f  qW	Xn  |
 rj	|	 jF   n  | S(,   s4  Read image data from file and return as numpy array.

        Raise ValueError if format is unsupported.

        Parameters
        ----------
        out : numpy.ndarray, str, or file-like object; optional
            Buffer where image data will be saved.
            If None (default), a new array will be created.
            If numpy.ndarray, a writable array of compatible dtype and shape.
            If 'memmap', directly memory-map the image data in the TIFF file
            if possible; else create a memory-mapped array in a temporary file.
            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.
        squeeze : bool
            If True, all length-1 dimensions (except X and Y) are
            squeezed out from the array.
            If False, the shape of the returned array might be different from
            the page.shape.
        lock : {RLock, NullContext}
            A reentrant lock used to syncronize reads from file.
            If None (default), the lock of the parent's filehandle is used.
        reopen : bool
            If True (default) and the parent file handle is closed, the file
            is temporarily re-opened and closed if no exception occurs.
        maxsize: int or None
            Maximum size of data before a ValueError is raised.
            Can be used to catch DOS. Default: 16 TB.
        validate : bool
            If True (default), validate various parameters.
            If None, only validate parameters and return None.

        i    Ns   data are too large %ss   data type not supported: %s%is   cannot decompress %sR   i   c         3  s    |  ] } |   j  d  Vq d S(   i    N(   RZ   (   R   R   (   RT  (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>5  s    s   sample formats do not match %si   i   s    chroma subsampling not supporteds   file handle is closediR   RG   R  i   i   s   unsupported JPEG precision %it
   JPEGTablesR   c         S  s   | |  | | |  j  d  S(   Ni(   R  (   R   RN   t   tableR  t
   colorspace(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt
   decompress  s    i   i    i@   i   s   data and sample size mismatchc           st    j  d k r  j } n  y t j |  |  SWn> t k
 ro t |     d   d } t j |  |  |  SXd  S(   Ni   i   (   R+  RH   R.   t
   frombufferR   R!   (   R   R  t   xlen(   R  R/   RO   (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c         S  s   t  |  | |  S(   N(   t
   unpack_rgb(   R   R  R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c         S  s   t  |  | | |  S(   N(   t   unpack_ints(   R   R  R  t   runlen(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    s   invalid tile datat	   WRITEABLER   iR/   i   i   .s   failed to reshape from %s to %s(   i   i   (   i   i   i    i@   i   (   i    i    i    i    (G   R  R   R   R   R-   R   R{   R/   RI  R  R  RA   R  R|  R   R   RZ   t   is_chroma_subsampledR'  t   NotImplementedErrorR  R  t   lockR  t   openR|   R  R  R  R  R*   RH   t	   fillordert   offsets_bytecountst   is_tiledt	   tilewidtht
   tilelengtht	   tiledepthRC  RD   R  RE   R   R   R  R   t   byteswapR5   R   t   reverse_bitordert   identityfuncR  R&  R   R   t   buffered_readR9   R   R   R.   t   zerosR  R#  R<   R+  R\  t   cumsumR*  R  t   decode_floatsRu  (*   RO   R  R  R  t   reopent   maxsizeR  t   self_R   R   R  R9   R  R  R  R  t   lsb2msbRN  RP  t   istiledR  R  R  t   twt   tlt   tdt	   tileshapeR  RL   R  R  R  R  t   writablet   plR(  R   R   t
   strip_sizeR8  Ra  R<   (    (   R  R/   RO   RT  s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR"     s<   #		
.											"	%	$"@
4 "	'c         O  s  |  j  | |   } |  j }  |  j }	 t j }
 |	 |
 j k r |  j } | j d d |  j k  sq |  j	 j
 d k r t d   n  | r | j   d k r | d L} n  | j d  } n  d |  j k r |  j d k r | d n | d
 } n  t | |  } n|	 |
 j k r.d |  j k r| d k r4t j } n  |  j } |  j d j d k r_| f } n  x t |  D]t \ } } | | k rl|  j d k r| d	 d
 d d d | g f } n& | d d  d
 d d d | g f } PqlqlWq|  j d k r| d	 d d  f } q| d d  d d  f } nZ |	 |
 j k rIt    n? |	 |
 j k rdt    n$ |	 |
 j k rt    n	 t    | S(   sA   Return image data as RGB(A).

        Work in progress.

        i   i   R   s   cannot apply colormapi   i   t   uint8t   S.i    R   i   N(   .i    (   R"   R  R&  RA   R  R  R,  R9   R  R/   RH   R   R^  R  R  R'  t   apply_colormapR  R   R-   t   EXTRASAMPLERD  R   R!  R  R  R  t	   SEPARATED(   RO   R  t   alphaR,  t   dmint   dmaxt   argsR#   R8   R&  R  RD  R   t   exs(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   asrgb  sP    				&	#&	c         C  s   |  S(   N(    (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   aspage(  s    c         C  s   |  S(   N(    (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  +  s    c         C  s   d  S(   N(    (   RO   R8  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  /  s    c         C  s;   |  j  r( |  j  \ } } | g | g f St |  j |  j  S(   s)   Return simplified offsets and bytecounts.(   RE   t   clean_offsets_countsRD  RO  (   RO   RG   t
   byte_count(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  3  s    	c           s>  |  j  d k s |  j d k r" d Sd |  j k r |  j |  j k sm |  j |  j sm |  j d sm |  j d rq d Sd |  j k r d	 |  j k r |  j |  j k s |  j |  j r d Sn  |  j	  |  j
   t   d k r  d
   d
 f S|  j s&t    f d   t t   d  D  r: d
 t    f Sd S(   sl   Return offset and size of contiguous data, else None.

        Excludes prediction and fill_order.

        i   i   i   i    i@   NR   R   R   i    c         3  sC   |  ]9 }  |   |  | d  k p:   | d  d k Vq d S(   i   i    N(    (   R   R   (   RP  RN  (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>S  s   (   i   i   i    i@   (   R  R  R   R  R  R  R  R  R  RD  RO  R!   R{  R  R   R%  (   RO   (    (   RP  RN  s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRE   ;  s&    		c         C  s/   |  j  o. |  j d k o. |  j d k o. |  j S(   s`   Return if page's image data are stored in final form.

        Excludes byte-swapping.

        i   (   RE   R  R+  R  (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  X  s    c         C  s3   |  j  j j o2 |  j o2 |  j d |  j j d k S(   s9   Return if page's image data in file can be memory-mapped.i    (   R  R  t   is_fileR  RE   R/   R0   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRD   b  s    iO   c         C  sc  |  j  |  k r t j |  |  Sd } x7 d! D]/ } t |  d |  } | r, | j   } Pq, q, Wd j d   d j d	   |  j D  d
 t j |  j	  j
 |  j f d j d   t j |  j  j
 |  j r d n d |  j d k r |  j j
 n d |  j d k r|  j j
 n d |  j d k r*|  j j
 n d |  j d k rH|  j j
 n d f D  | d j d   |  j D  f D  } d |  j |  j | f } | d k r| S| g } |  j } g  } g  } x t | j   d d   D] }	 |	 j d | d  }
 | j |
 |  j    | d k rt |
  | k r|	 j
 j   } | d k rd | k sed | k rt |	 j d | d | d }
 n t |	 j d | d | d }
 | j d |	 j
 |
 f  qqW| j d j |   | d k r| j d j |   n  | d k rVy1 | j d t |  j   d | d | d   WqVt k
 rRqVXn  d j |  S("   s0   Return string containing information about page.R   t   memmappablet   finalR)  Rb   s     c         s  s   |  ] } | r | Vq d  S(   N(    (   R   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>s  s    R   c         s  s   |  ] } t  |  Vq d  S(   N(   R{   (   R   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>t  s    s   %s%sRj   c         s  s   |  ] } | r | Vq d  S(   N(    (   R   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>w  s    t   TILEDi   c         s  s   |  ] } | j    Vq d  S(   N(   R  (   R   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>  s    s   TiffPage %i @%i  %si    R   c         S  s   |  j  S(   N(   R   (   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR     R   RX  i   t   COUNTSt   OFFSETSR[  i   i   s   %s
%ss   
s   

i   s   DATA
%si   (   R  R  R)  (    R  R  RZ  RT   R  R   R9   RA   t   SAMPLEFORMATRI  R|  R  R  R&  R  R  R'  R+  R  R\  R8  RG   R   R  R  R(   Ra  R!   R_  RZ   R"   R2   (   RO   RW  RX  R   R|  R`  R   t   tlinest   vlinesRT  RZ   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRZ  i  s^    
(&		"$"!%c           s#   t    f d   t t j  D  S(   s   Return set of flags.c         3  s.   |  ]$ } t    d  |  r | j   Vq d S(   Rb   N(   RT   Rb  (   R   R|  (   RO   (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>  s    (   Rc  R  RA   R  (   RO   (    (   RO   s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR\    s    c         C  s   t  |  j  S(   s"   Return number of array dimensions.(   R!   R9   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRB    s    c         C  s   t  |  j  S(   s#   Return number of elements in array.(   R   R9   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR<     s    c         C  s   |  j  s d S|  j } i | d j d 6} x t |  j j    D]y } | j } d | k  of d k  n sq q@ n  | j } t | j  d k r | j d n | j } | | | <| | j =q@ W| S(   sj   Return consolidated metadata from Andor tags as dict.

        Remove Andor tags from self.tags.

        Nt   AndorIdt   Idi   i  i   (   R  R   RZ   R   R  R   R!   R|  (   RO   R   RL   RT  R   RZ   R|  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    				+
c         C  s.  |  j  s d Si  } |  j } xt |  j j    D] } | j } d | k oX d k  n sc q2 n  | j } | d k r t j j t |   | d <n | d k r t	 |  | d <nf | d k r t	 |  | d <nG | d	 k r t	 |  | d
 <n( | j
 d d  \ } } t |  | | <| | j =q2 W| S(   s~   Return consolidated metadata from EPICS areaDetector tags as dict.

        Remove areaDetector tags from self.tags.

        Ni  i  t	   timeStampi  t   uniqueIDi  t
   epicsTSSeci  t   epicsTSNsect   :i   (   R  R   R   R  R   RZ   R.  t   fromtimestampR  R   R  R  R|  (   RO   RL   R   RT  R   RZ   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s,    					c      
   C  s  |  j  s d S|  j } | d j } | d d k rD t j d  i  Si | d d 6| d d 6| d d	 6} t j } t j } xt | d
  D]} | d | d | d d !\ } } }	 }
 | j	 | |  } | d k r |
 } nv t j
 | } | | j |
 |
 |	 !} | d k r>|	 d k r>| d d k r>| d  } n  |	 d k rP| n | d } | | k ry | | |  } Wqt k
 rqXn  | | | <q Wd | k r| d j } t j |  } t |  d k r| j d7  j   } n  | | d <n  d | k r3t j | d j  j   } | | d <n  d | k r}| d j } t j |  j d8  j   j   } | | d <n  d | k r| d j } t j |  j d9  j   } | | d <nt r| d j \ } } } | d j } g  } x t d t |  d  D] } | | | d !\ } } } } } } | j | d d | | | g d | d | | | g d d | | | | g d d d d g g  q	Wt |  d k r| d } n  | | d <n  d | k r| d j } i | d d 6| d d 6| d d 6| d
 d  6| d d! 6| d" d# 6| d d$ 6| d% d& 6| d d' 6| d( d) 6| d* d+ 6| d, d- 6| d. d/ !d0 6| d/ d1 !d2 6| d1 d3 !d4 6| d3 d5 6| d6 <n  | S(:   s7   Return consolidated metadata from GeoTIFF tags as dict.Nt   GeoKeyDirectoryTagi    i   s   invalid GeoKeyDirectoryTagt   KeyDirectoryVersiont   KeyRevisioni   t   KeyRevisionMinori   i   i   i  iRj   t   IntergraphMatrixTagi   t   IntergraphMatrixt   ModelPixelScaleTagt   ModelPixelScalet   ModelTiepointTagi   t   ModelTiepointt   ModelTransformationTagt   ModelTransformationg        g      ?t   RPCCoefficientTagt   ERR_BIASt   ERR_RANDt   LINE_OFFt   SAMP_OFFt   LAT_OFFi   t   LONG_OFFt
   HEIGHT_OFFi   t
   LINE_SCALEt
   SAMP_SCALEi	   t	   LAT_SCALEi
   t
   LONG_SCALEi   t   HEIGHT_SCALEi   i!   t   LINE_NUM_COEFFi5   s   LINE_DEN_COEFF iI   t   SAMP_NUM_COEFFt   SAMP_DEN_COEFFt   RPCCoefficient(   i   i   (   ii   (   i   i   (   R  R   RZ   R   R   RA   t   GEO_KEYSt	   GEO_CODESR   R3   R  R2   R.   R  R!   R  t   tolistR  R4   R(   (   RO   R   t   gkdRL   t   geokeyst   geocodesR8  t   keyidt   tagidR   RG   RZ   R  t   sxt   syt   szt	   tiepointst
   transformst   tpR   R  R  R   t   yt   zt   rpcc(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    				)	($#c         C  s   d |  j  k S(   s   Page contains tiled image.R   (   R   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  A  s    c         C  s!   d |  j  k o  |  j  d j d @S(   s'   Page is reduced image of another image.R   i   (   R   RZ   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR>  F  s    c         C  s#   d |  j  k o" |  j  d j d k S(   s&   Page contains chroma subsampled image.t   YCbCrSubSamplingi   (   i   i   (   R   RZ   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  L  s    c         C  s?   x8 |  j  |  j f D]$ } | s# d S| d  d k r | Sq Wd S(   s/   Return ImageJ description if exists, else None.Ni   s   ImageJ=(   R-  t   description1(   RO   R-  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  R  s
    c         C  s_   xX |  j  |  j f D]D } | s# d S| d  d k rC d | k rC | S| d  d k r | Sq Wd S(   s?   Return description containing array shape if exists, else None.Ni   t   {s   "shape":i   s   shape=(   R-  RR  (   RO   R-  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  [  s    c         C  s   d |  j  k S(   s   Page contains MDFileTag tag.R  (   R   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRd  f  s    c         C  s'   d |  j  k o& |  j  d j d  d k S(   s'   Page contains Media Cybernetics Id tag.t   MC_Idi   s   MC TIFF(   R   RZ   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt
   is_mediacyk  s    c         C  s   d |  j  k S(   s   Page contains UIC2Tag tag.Rn  (   R   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR{  q  s    c         C  s   d |  j  k S(   s   Page contains CZ_LSMINFO tag.Rm  (   R   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  v  s    c         C  s   d |  j  k S(   s$   Page contains FluoView MM_STAMP tag.R  (   R   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  {  s    c         C  s   d |  j  k S(   s   Page contains NIH image header.R  (   R   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c         C  s   d |  j  k o d |  j  k S(   s,   Page contains SGI image and tile depth tags.R   R   (   R   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   is_sgi  s    c         C  s   |  j  d k S(   s   Software tag is 'ISS Vista'.s	   ISS Vista(   R0  (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c         C  sG   |  j  d k s |  j d k r" t S|  j } | j d  oF | j d  S(   s>   Page contains MDS MetaSeries metadata in ImageDescription tag.i   t
   MetaSeriess
   <MetaData>s   </MetaData>(   R8  R0  R4   R-  t
   startswithR"  (   RO   t   d(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    	c         C  sD   |  j  d k s |  j r t S|  j } | d  d k oC | d d k S(   s.   Page contains OME-XML in ImageDescription tag.i   i   s   <?xml version=is   </OME>(   R8  R-  R4   (   RO   RY  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR     s    	c         C  sD   |  j  d k s |  j r t S|  j } | d  d k oC | d d k S(   s4   Page contains Leica SCN XML in ImageDescription tag.i   i   s   <?xml version=is   </scn>(   R8  R-  R4   (   RO   RY  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   is_scn  s    	c         C  s   d |  j  k S(   s%   Page contains Micro-Manager metadata.R  (   R   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c         C  s   d |  j  k S(   s$   Page contains Andor Technology tags.R  (   R   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c         C  s$   |  j  d  d k o# |  j d  d k S(   s   Page contains Pilatus tags.i   s   TVX TIFFi   s   # (   R0  R-  (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c         C  s   |  j  d k p |  j d k S(   s&   Page contains EPICS areaDetector tags.s   EPICS areaDetector(   R-  R0  (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c         C  s   d |  j  k S(   s   Page contains TVIPS metadata.R  (   R   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c         C  s   d |  j  k p d |  j  k S(   s&   Page contains SFEG or HELIOS metadata.R  R  (   R   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c         C  s   d |  j  k S(   s!   Page contains Zeiss SEM metadata.R  (   R   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c         C  s   |  j  d  d k S(   s   Page contains Aperio metadata.i   s   Aperio Image Library(   R-  (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   is_svs  s    c         C  s7   |  j  d  d k p6 |  j d  d k p6 d |  j  d k S(   s!   Page contains ScanImage metadata.i   s   state.configi   s   SI.LINE_FORMAT_VERSIONs   scanimage.SI.i (   R-  R0  (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c         C  s   |  j  d  d k S(   s1   Page contains PerkinElmer tissue images metadata.i   s   PerkinElmer-QPI(   R0  (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRj    s    c         C  s   d |  j  k S(   s   Page contains GeoTIFF metadata.R#  (   R   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    I       I    NI       (H   RV   R]   R^   R  R  R  R  R  R  R  RC  RI  R*  R  R'  R  R&  R+  RD  R-   R,  R0  R-  RR  RP   R5   R"   R4   R  R  R  R  R  R
   R  RE   R  RD   RZ  R\  RB  R<   R  R  R  R  R>  R  R  R  Rd  RU  R{  R  R  R  RV  R  R  R   RZ  R  R  R  R  R  R  R  R[  R  Rj  R  (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRY    s   #	7	
5_	R  c           B  s   e  Z d  Z d Z e Z i  Z d   Z d   Z d	   Z	 d
   Z
 e d    Z e d    Z e d    Z d   Z d d  Z RS(   s  Lightweight TIFF image file directory (IFD).

    Only a limited number of tag values are read from file, e.g. StripOffsets,
    and StripByteCounts. Other tag values are assumed to be identical with a
    specified TiffPage instance, the keyframe.

    TiffFrame is intended to reduce resource usage and speed up reading data
    from file, not for introspection of metadata.

    Not compatible with Python 2.

    R  R  R8  RG   RD  RO  c         C  s  | |  _  | |  _ | |  _ d |  _ d |  _ t j } | j } | j	   |  _
 yA | | j | j | j   d } | d k r t d   n  Wn$ t k
 r t d |  j
   n Xd d d d h } | j } | j d	  }	 | j | |  }
 | } x t |  D] } | | 7} | |	 |
 | | d	 ! d } | | k rEqn  y t | |
 | | | ! } Wn, t j k
 r} t j t |   qn X| d k s| d k rt |  d
 | j  q| d k s| d k rt |  d | j  qqWd S(   sp   Read specified tags from file.

        The file handle position must be at the offset to a valid IFD.

        i    i   s   suspicious number of tagss    corrupted page list at offset %ii  i  iD  iE  i   RD  RO  N(   R  R  R8  R-   RD  RO  R   R  R  Rw   RG   R;  R  R  R   R2   R<  R  R   R  R  R   R   R{   RW   RZ   (   RO   R  R8  R  R  R   R  t   tagcodesR<  t
   codeformatR8   RM   R   RT  R[   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRP     sB    							"	
c         C  s2   |  j  j j |  j  t |  j  d |  j d d S(   s   Return TiffPage from file.R8  R  N(   R  R  R   RG   RY  R8  R-   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  ,  s    c         O  s   t  | d <t j |  | |  S(   s4   Read image data from file and return as numpy array.R  (   R4   RY  R"   (   RO   R  R#   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR"   1  s    
c         O  s   t  | d <t j |  | |  S(   s>   Read image data from file and return RGB image as numpy array.R  (   R4   RY  R  (   RO   R  R#   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  9  s    
c         C  s:   |  j  j r' |  j d  |  j  j d f St |  j |  j  S(   s)   Return simplified offsets and bytecounts.i   (   R  RE   RD  R  RO  (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  >  s    c         C  s+   |  j  j r' |  j d |  j  j d f Sd S(   s5   Return offset and size of contiguous data, else None.i    i   N(   R  RE   RD  (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRE   E  s    c         C  s
   |  j  j S(   s9   Return if page's image data in file can be memory-mapped.(   R  RD   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRD   K  s    c         C  s?   | t  j k r t |  j |  St d |  j j | f   d S(   s   Return attribute from keyframe.s!   '%s' object has no attribute '%s'N(   RA   t   FRAME_ATTRSRT   R  RQ   RR  RV   (   RO   R|  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRS  P  s    i    c         C  sU   d j  d   d j  d   |  j D  t |  j  f D  } d |  j |  j | f S(   s1   Return string containing information about frame.s     c         s  s   |  ] } | Vq d  S(   N(    (   R   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>[  s    R   c         s  s   |  ] } t  |  Vq d  S(   N(   R{   (   R   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>\  s    s   TiffFrame %i @%i  %s(   R   R9   R{   R/   R8  RG   (   RO   RW  R`  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRZ  Y  s    (   R  R  R8  RG   RD  RO  (   RV   R]   R^   R_   R4   Rd  R   RP   R  R"   R  R  R  RE   RD   RS  RZ  (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    	4					R  c           B  sZ   e  Z d  Z d Z d e f d     YZ d   Z e d	    Z d
   Z	 d d d  Z
 RS(   s  TIFF tag structure.

    Attributes
    ----------
    name : string
        Name of tag.
    code : int
        Decimal code of tag.
    dtype : str
        Datatype of tag data. One of TIFF DATA_FORMATS.
    count : int
        Number of values.
    value : various types
        Tag data as Python object.
    ImageSourceData : int
        Location of value in file.

    All attributes are read-only.

    R   R   R/   RZ   R  R  c           B  s   e  Z RS(    (   RV   R]   (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  x  s   c           s  | j  } | j } t j } | j } | j   | d |  _ | | j | d   \ } }	 | | j | d  \ }
 } y t	 j
 |	 } Wn$ t k
 r t j d |	   n Xd | |
 t | d  | d f } t j |  } | | k s | t	 j k r$| | j |  d |  _ } | d k  s6| | j | k rHt j d   n  | j |  | t	 j k rt	 j | } | | | | |
 |  } q`|	 d k s|
 d k r| d	 d
 k rt | | | |
 |  } q`| t	 j k s| d	 d k r	| | | j |   } q`t | | | |
 |  } n< | d	 d
 k s@|	 d k rM| |  } n | | | |   } | t	 j k o| t	 j k o|	 d k } | r| d	 d k rt | d t  r| d } y t t |  j    } Wqt k
 rt j  d |  d } qXn | t	 j! k rot	 j! |   y  t"   f d   | D  } Wqot# k
 rk} t j  t$ |   qoXn  | rt% |  d k r| d } qn  | |  _& | |  _' |
 |  _( | |  _) d S(   s$   Initialize instance from tag header.i   s   unknown tag data type %is   %s%i%si    i   i   s   invalid tag value offseti   iR   R   s'   tag %i: coercing invalid ASCII to bytest   1Bc         3  s   |  ] }   |  Vq d  S(   N(    (   R   R  (   R   (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>  s    N(*   R  R*   R   R  R   Rw   R  R  R  RA   t   DATA_FORMATSR   R  R  R   R   t   TAG_READERSR   R<   R   t
   read_bytesR  R  t
   read_numpyt	   TAG_TUPLER   R   t	   bytes2strt
   stripasciiRa  t   UnicodeDecodeErrorR   R   t   TAG_ENUMR   R   R{   R!   R   R/   R   RZ   (   RO   R  t	   tagheaderR#   R   R*   R  R   R   t   type_R   RZ   R/   R   R<   RG   t   readfunct   processR[   (    (   R   s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRP   {  sf    				%()
 			c         C  s   t  j j |  j t |  j   S(   N(   RA   R  R3   R   R{   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR|    s    c         C  s   |  j  d k r |  j d k r t j d  | j | j } t j | |  j  d |  _	 | j
 j |  j	  t j d | j
 j d   |  _ n  d S(   s   Correct LSM bitspersample tag.

        Old LSM writers may use a separate region for two 16-bit values,
        although they fit into the tag value element of the tag.

        i  i   s    correcting LSM bitspersample tagi    s   <HHi   N(   R   R   R   R   R   R   R   R  t   _valueR  R  R   R  RZ   (   RO   R  t   tof(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    i    iO   c         C  s  | d k r d n d | } d |  j  t |  j d  |  j d f } d |  j |  j | |  j f |  } |  j t j k r |  j  d k r t j |  j |  j  j } q t	 t
 d   |  j D   } n t	 |  j d | d | } | d k r
| | 7} | |  } n | d	 | 7} | S(
   s/   Return string containing information about tag.i    i   i   s   %i%ss   TiffTag %i %s  %s @%i  c         s  s   |  ] } | j  Vq d  S(   N(   R|  (   R   R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>  s    RX  R[  s   
(   R   R   R/   R   R|  R  RA   Rh  RZ   R_  R   (   RO   RW  RX  R[  t   tcodet   lineRZ   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRZ    s    + "
(   R   R   R/   RZ   R  (   RV   R]   R^   R_   R2   R  RP   R  R|  R  RZ  (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  a  s   	B	R  c           B  s   e  Z d  Z d d d d e d  Z d d  Z e d    Z e	 d    Z
 e	 d    Z e	 d    Z d   Z d   Z d	   Z d
   Z RS(   s  Series of TIFF pages with compatible shape and data type.

    Attributes
    ----------
    pages : list of TiffPage
        Sequence of TiffPages in series.
    dtype : numpy.dtype
        Data type (native byte order) of the image array in series.
    shape : tuple
        Dimensions of the image array in series.
    axes : str
        Labels of axes in shape. See TiffPage.axes.
    offset : int or None
        Position of image data in file if memory-mappable, else None.

    c
   
      C  s  d |  _  | |  _ t |  |  _ d j |  |  _ t j |  |  _ | rQ | n d |  _ | rf | n d |  _	 | |  _
 | r | |  _ n" | r | d j |  _ n	 d |  _ t |  d k r |	 r t t |  j  t | d j   |  _ n t |  |  _ d S(   s   Initialize instance.i    R   i   N(   R8  R  R   R9   R   R  R.   R/   R  R|  R  R  R-   R!   R   R   t   _len(
   RO   RC   R9   R/   R  R  R|  R  R  R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRP     s     				,c         C  sM   |  j  rI |  j  j d |  d |  } |  j d k	 rE |  j |  } n  | Sd S(   s;   Return image data from series of TIFF pages as numpy array.RF   R  N(   R  R"   R  R-   (   RO   R  RL   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR"     s
    	c         C  s   |  j  s d Sd } xz |  j  D]o } | d k r3 d S| j s@ d S| sd | j d | j d } q n  | | j d k r{ d S| | j d 7} q W|  j  d } | j d } | j s | j r t |  j   d k r | S| | t |  j  |  j	 j
 k r | Sd S(   s-   Return offset to series data in file, if any.Ni    i   (   R  R-   R  RE   R  R  R!   R   R9   R/   R0   (   RO   R   RJ   RG   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRG     s(    		'#c         C  s   t  |  j  S(   s"   Return number of array dimensions.(   R!   R9   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRB  1  s    c         C  s   t  t |  j   S(   s#   Return number of elements in array.(   R   R   R9   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR<   6  s    c         C  s   |  S(   s'   Return sequence of all pages in series.(    (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRC   ;  s    c         C  s   |  j  S(   s%   Return number of TiffPages in series.(   Rq  (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  A  s    c         C  sa   t  |  j  d k rV d | k  o/ |  j k  n rV |  j d j } |  j j | | S|  j | S(   s   Return specified TiffPage.i   i    (   R!   R  Rq  R8  R  RC   (   RO   R   R8  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  E  s    4c         c  s{   t  |  j  |  j k r4 x\ |  j D] } | Vq" WnC |  j j } |  j d j } x$ t |  j  D] } | | | Vq` Wd S(   s)   Return iterator over TiffPages in series.i    N(   R!   R  Rq  R  RC   R8  R   (   RO   RJ   RC   R8  R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  L  s    c      
   C  s   d j  d   |  j r+ t d |  j d  n d d j  d   |  j D  t |  j  |  j |  j d t |  j	  |  j
 r d	 |  j
 n d f D  } d
 |  j | f S(   s,   Return string with information about series.s     c         s  s   |  ] } | r | Vq d  S(   N(    (   R   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>Y  s    s   '%s'i   R   R   c         s  s   |  ] } t  |  Vq d  S(   N(   R{   (   R   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>[  s    s   %i Pagess	   Offset=%is   TiffPageSeries %i  %s(   R   R|  R]  R9   R{   R/   R  R  R!   RC   RG   R8  (   RO   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRZ  W  s    "&N(   RV   R]   R^   R-   R4   RP   R"   R
   RG   R  RB  R<   RC   R  R  R  RZ  (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s   			c           B  s   e  Z d  Z i d d 6Z d e f d     YZ e d d  Z d   Z d   Z	 d   Z
 d	   Z d
   Z d d  Z d   Z RS(   s  Sequence of TIFF files.

    The image data in all files must match shape, dtype, etc.

    Attributes
    ----------
    files : list
        List of file names.
    shape : tuple
        Shape of image sequence. Excludes shape of image array.
    axes : str
        Labels of axes in shape.

    Examples
    --------
    >>> # read image stack from sequence of TIFF files
    >>> imsave('temp_C001T001.tif', numpy.random.rand(64, 64))
    >>> imsave('temp_C001T002.tif', numpy.random.rand(64, 64))
    >>> tifs = TiffSequence('temp_C001*.tif')
    >>> tifs.shape
    (1, 2)
    >>> tifs.axes
    'CT'
    >>> data = tifs.asarray()
    >>> data.shape
    (1, 2, 64, 64)

    s  
            # matches Olympus OIF and Leica TIFF series
            _?(?:(q|l|p|a|c|t|x|y|z|ch|tp)(\d{1,4}))
            _?(?:(q|l|p|a|c|t|x|y|z|ch|tp)(\d{1,4}))?
            _?(?:(q|l|p|a|c|t|x|y|z|ch|tp)(\d{1,4}))?
            _?(?:(q|l|p|a|c|t|x|y|z|ch|tp)(\d{1,4}))?
            _?(?:(q|l|p|a|c|t|x|y|z|ch|tp)(\d{1,4}))?
            _?(?:(q|l|p|a|c|t|x|y|z|ch|tp)(\d{1,4}))?
            _?(?:(q|l|p|a|c|t|x|y|z|ch|tp)(\d{1,4}))?
            R  R  c           B  s   e  Z RS(    (   RV   R]   (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s   c           s  t  | t j  r! t |  } n  t  | t  rH t t j |   } n  t |  } | si t d   n  t  | d t j  r g  | D] } t t j |   ^ q } n" t  | d t  s t d   n  | |  _	 t
 | d  r |     f d   } n  | |  _ |  j j | |  |  _ y# |  j   |  j s?d |  _ n  Wn] |  j k
 rd |  _ t |  f |  _ d	 |  _ t d   t t |   D  |  _ n Xd S(
   s\  Initialize instance from multiple files.

        Parameters
        ----------
        files : str, pathlib.Path, or sequence thereof
            Glob pattern or sequence of file names.
            Binary streams are not supported.
        imread : function or class
            Image read function or class with asarray function returning numpy
            array from single file.
        pattern : str
            Regular expression pattern that matches axes names and sequence
            indices in file names.
            By default, the pattern matches Olympus OIF and Leica TIFF series.

        s   no files foundi    s   not a file nameR"   c           s)     |    } | j  | |   SWd  QXd  S(   N(   R"   (   R-  R  R#   t   im(   t   _imread(    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR     s    Rq   c         s  s   |  ] } | f Vq d  S(   N(    (   R   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>  s    N(   i    (   R   t   pathlibt   PathR{   R   R   R   R   R   R   R    R   t	   _patternsR3   R   t   _parseR  R  R!   R9   t   _startindexR   R   t   _indices(   RO   R   R   R   R  R#   R   (    (   Rs  s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRP     s4    +		
			c         C  sA   d j  |  j d d t |  j  d |  j d t |  j  g  S(   s4   Return string with information about image sequence.s   
i    s	    size: %is	    axes: %ss
    shape: %s(   R   R   R!   R  R{   R9   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRZ    s
    

c         C  s   t  |  j  S(   N(   R!   R   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c         C  s   |  S(   N(    (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRv    s    c         C  s   |  j    d  S(   N(   Ru  (   RO   Rw  Rx  Ry  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRz    s    c         C  s   d  S(   N(    (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRu    s    c         O  s   |  j  |  j d | |  } |  j | j } t | | d | j } | j d | j  } x t |  j |  j  D]o \ } } g  t | |  j  D] \ }	 }
 |	 |
 ^ q } t	 j
 | |  j  } |  j  | | |  } | | | <qo W| | _ | S(   s   Read image data from all files and return as numpy array.

        The args and kwargs parameters are passed to the imread function.

        Raise IndexError or ValueError if image shapes do not match.

        i    R/   i(   R   R   R9   R   R/   R  R|  Ry  Rx  R.   R  (   RO   R  R  R#   Rr  R9   RL   R8  R-  R   R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR"     s    "/	c   	      C  s!  |  j  s |  j d   n  t j |  j  t j t j B } | j |  j d  } | sh |  j d   n  | d } t |  d r |  j d   n  d j	 d   | d	 d	 d  D  } | s |  j d   n  g  } x |  j D] } | j |  d } | d j	 d
   | d	 d	 d  D  k r6t
 d   n  | j g  | d d	 d  D] } | rPt |  ^ qP q Wt t j | d d  } t t j | d d  } t d   t | |  D  } t |  t |  j  k rt j d  n  | j   |  _ | |  _ | |  _ | |  _ d	 S(   s#   Get axes and shape from file names.s   invalid patterni    s!   pattern does not match file namesii   s*   pattern does not match axis name and indexR   c         s  s   |  ] } | r | Vq d  S(   N(    (   R   Ra  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>  s    Nc         s  s   |  ] } | r | Vq d  S(   N(    (   R   Ra  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>  s    s+   axes do not match within the image sequencei   R   c         s  s#   |  ] \ } } | | d  Vq d S(   i   N(    (   R   R   R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>  s    s*   files are missing. Missing data are zeroed(   R   R  t   ret   compilet
   IGNORECASEt   VERBOSEt   findallR   R!   R   R   R(   R   R   R.   R^  R#  R|  R   R   R   R  R  R9   Ry  Rx  (	   RO   R   t   matchesR  RI  R-  Ra  R9   t
   startindex(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRw    s6    	
&,=		N(   RV   R]   R^   Rv  R2   R  R   RP   RZ  R  Rv  Rz  Ru  R-   R"   Rw  (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR   d  s   

4					c        
   B  s@  e  Z d  Z d+ Z d d, d, d, d  Z d   Z d d  Z d   Z d   Z	 d d d d  Z
 d d d- d, e d  Z d d, d  Z d   Z d   Z d   Z d d  Z d    Z d!   Z d"   Z d#   Z e d$    Z e d%    Z e d&    Z e d'    Z e d(    Z e d)    Z e j d*    Z RS(.   s  Binary file handle.

    A limited, special purpose file handler that can:

    * handle embedded files (for CZI within CZI files)
    * re-open closed files (for multi-file formats, such as OME-TIFF)
    * read and write numpy arrays and records from file like objects

    Only 'rb' and 'wb' modes are supported. Concurrently reading and writing
    of the same stream is untested.

    When initialized from another file handle, do not use it unless this
    FileHandle is closed.

    Attributes
    ----------
    name : str
        Name of the file.
    path : str
        Absolute path to file.
    size : int
        Size of file in bytes.
    is_file : bool
        If True, file has a filno and can be memory-mapped.

    All attributes are read-only.

    R   t   _filet   _modet   _namet   _dirt   _lockt   _offsett   _sizet   _closeR  R`   c         C  sk   | |  _  d |  _ | |  _ | |  _ d |  _ | |  _ | |  _ t |  _	 t
 |  _ t   |  _ |  j   d S(   s  Initialize file handle from file name or another file handle.

        Parameters
        ----------
        file : str, pathlib.Path, binary stream, or FileHandle
            File name or seekable binary stream, such as an open file
            or BytesIO.
        mode : str
            File open mode in case 'file' is a file name. Must be 'rb' or 'wb'.
        name : str
            Optional name of file in case 'file' is a binary stream.
        offset : int
            Optional start position of embedded file. By default, this is
            the current file position.
        size : int
            Optional size of embedded file. By default, this is the number
            of bytes from the 'offset' to the end of the file.

        R   N(   R  R-   R   R  R  R  R  R  R5   R  R4   R  t   NullContextR  R  (   RO   R7   RK   R|  RG   R<   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRP   -  s    									c         C  s}  |  j  r d St |  j t j  r7 t |  j  |  _ n  t |  j t  r t j j	 |  j  |  _ t j j
 |  j  \ |  _ |  _ t |  j |  j  |  _  t |  _ |  j d k rd |  _ qn	t |  j t  r|  j j  |  _  |  j d k r d |  _ n  |  j |  j j 7_ t |  _ |  j sy|  j rgt j j |  j j  \ } } d | |  j | f |  _ qy|  j j |  _ n  |  j r|  j |  j j k rt d   n  |  j j |  _ |  j j |  _ nt |  j d  ry |  j j   Wn t k
 r	t d   n X|  j |  _  |  j d k r:|  j j   |  _ n  t |  _ |  j sy( t j j
 |  j  j  \ |  _ |  _ Wqt k
 rd |  _ qXn  y |  j  j |  _ Wqt k
 rqXn t d   |  j r|  j  j |  j  n  |  j d k rB|  j  j   } |  j  j |  j d	  |  j  j   |  _ |  j  j |  n  y |  j  j   t |  _  Wn t k
 rxt |  _  n Xd S(
   s   Open or re-open file.Ni    s   %s@%i%ss   FileHandle has wrong modeR   s   binary stream is not seekables   Unnamed binary streamsN   The first parameter must be a file name, seekable binary stream, or FileHandlei   (!   R   R   R  Rt  Ru  R{   R   R  R  t   realpathR  R  R  R  R  R5   R  R  R-   R	   R4   t   splitextR   R    Rw   R2   R|  RQ   RK   R   R  R  R  (   RO   R|  t   extR   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  M  sr    	!						(	ic         C  s1   | d k  r! |  j  r! |  j } n  |  j j |  S(   s5   Read 'size' bytes from file, or until EOF is reached.i    (   R  R  R   R  (   RO   R<   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c         C  s   |  j  j |  S(   s   Write bytestring to file.(   R   R   (   RO   t
   bytestring(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR     s    c         C  s   |  j  j   S(   s"   Flush write buffers if applicable.(   R   R$  (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR$    s    i    t   rR?   c         C  sM   |  j  s t d   n  t j |  j d | d | d |  j | d | d | S(   s+   Return numpy.memmap of data stored in file.s%   Cannot memory-map file without filenoR/   RK   RG   R9   t   order(   R  R   R.   R   R   R  (   RO   R/   R9   RG   RK   R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s
    	R   i   i   c         C  s  |  j  } t j |  } | d k  r- |  j n
 | | j } | d k r y t j | | | |  }	 Wn; t k
 r | j |  }
 t j	 |
 | |  j
   }	 n X| r |	 j j r |	 j t  |	 j   }	 n  |	 S| j } t | j |  } | j d  } d } x | d k r| j t | |   }
 t |
  } | d k rFPn  | | 8} t j	 |
 |  }
 |
 | | | |
 j +| |
 j 7} qWt | d  r| j   n  | j |  S(   s   Return numpy array from file.

        Work around numpy issue #2230, "numpy.fromfile does not accept
        StringIO object" https://github.com/numpy/numpy/issues/2230.

        i    iR$  N(   R   R.   R/   R  R0   R-   t   fromfileR|   R  R  R  R   R  R5   R   R9   R#  R1   R  R!   R<   R    R$  (   RO   R/   R   t   sept	   chunksizeR  R  R   R<   RL   R8   R9   R8  R9  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s:    	"	
i   c         C  s   t  j } y" | j |  j | | d | } Wn t k
 r t  j |  } | d k ri |  j | j } n  t	 t
 |   | j } |  j j |  } | j | | | d | } n X| d k r | d S| S(   s   Return numpy record from file.R*   i   i    N(   R.   t   recR  R   R2   R/   R-   R  R0   R   t   sequenceR  R  (   RO   R/   R9   R*   R  t   recordR<   R8   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   read_record  s    	"c         C  s;   | d k  r d S|  j  j | d d  |  j  j d  d S(   s;   Append size bytes to file. Position must be at end of file.i   Ns    (   R   R   R   (   RO   R<   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c         C  sB   y | j  |  j  Wn' t k
 r= |  j j | j    n Xd S(   s!   Write numpy array to binary file.N(   t   tofileR   R2   R   R   (   RO   R8   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c         C  s   |  j  j   |  j S(   s   Return file's current position.(   R   Rw   R  (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRw     s    c         C  s   |  j  rv | d k r3 |  j j |  j  | |  d S| d k rv |  j d k rv |  j j |  j  |  j | d  d Sn  |  j j | |  d S(   s   Set file's current position.i    Ni   (   R  R   R   R  (   RO   RG   t   whence(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR     s    	!c         C  s/   |  j  r+ |  j r+ |  j j   d |  _ n  d S(   s   Close file.N(   R  R   Ru  R-   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRu    s    c         C  s   |  S(   N(    (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRv    s    c         C  s   |  j    d  S(   N(   Ru  (   RO   Rw  Rx  Ry  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRz  
  s    c         C  s-   |  j  r t j d |  n  t |  j |  S(   s-   Return attribute from underlying file object.s3   FileHandle: '%s' not implemented for embedded files(   R  R   R   RT   R   (   RO   R|  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRS    s    	c         C  s   |  j  S(   N(   R  (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR|    s    c         C  s   |  j  S(   N(   R  (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c         C  s   t  j j |  j |  j  S(   N(   R  R  R   R  R  (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c         C  s   |  j  S(   N(   R  (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR<      s    c         C  s   |  j  d  k S(   N(   R   R-   (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  $  s    c         C  s   |  j  S(   N(   R  (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  (  s    c         C  s"   | r t  j   n t   |  _ d  S(   N(   t	   threadingt   RLockR  R  (   RO   RZ   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  ,  s    (
   R   R  R  R  R  R  R  R  R  R  Ni   (   RV   R]   R^   R_   R-   RP   R  R  R   R$  R  R4   R  R  R  R  Rw   R   Ru  Rv  Rz  RS  R  R|  R  R  R<   R  R  R  (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR	     s6     	F		+							R  c           B  s    e  Z d  Z d   Z d   Z RS(   sI   Null context manager.

    >>> with NullContext():
    ...     pass

    c         C  s   |  S(   N(    (   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRv  8  s    c         C  s   d  S(   N(    (   RO   Rw  Rx  Ry  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRz  ;  s    (   RV   R]   R^   Rv  Rz  (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  1  s   	t   OpenFileCachec           B  s;   e  Z d  Z d	 Z d
 d  Z d   Z d   Z d   Z RS(   s   Keep files open.R   t   pastR  R<   c         C  sC   g  |  _  i  |  _ | d k r' t   n | |  _ t |  |  _ d S(   s   Initialize open file cache.N(   R  R   R-   R  R  R   R<   (   RO   R<   R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRP   D  s    		c         C  sl   |  j  ] | |  j k r/ |  j | c d 7<n3 | j rb | j   d |  j | <|  j j |  n  Wd QXd S(   s   Re-open file if necessary.i   N(   R  R   R  R  R  R(   (   RO   R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  K  s    
	
c         C  s   |  j   | |  j k r |  j | c d 8<d } t |  j  } xw | |  j k r | | k  r |  j | } |  j | d k r | j   |  j | =|  j | =| d 8} qD | d 7} qD Wn  Wd QXd S(   s%   Close openend file if no longer used.i   i    N(   R  R   R!   R  R<   Ru  (   RO   R  R8  R<   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRu  U  s    



c         C  ss   |  j  d x\ t |  j j    D]E \ } } | d k r  | j   |  j | =|  j |  j j |  =q  q  WWd QXd S(   s%   Close all opened files if not in use.i    N(   R  R   R   R  Ru  R  R8  (   RO   R  t   refcount(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  g  s    
"

(   R   R  R  R<   N(	   RV   R]   R^   R_   R-   RP   R  Ru  R  (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  ?  s   	
	t	   LazyConstc           B  s    e  Z d  Z d   Z d   Z RS(   sE   Class whose attributes are computed on first access from its methods.c         C  s   | |  _  t | d  |  _ d  S(   NR^   (   t   _clsRT   R^   (   RO   t   cls(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRP   s  s    	c         C  sc   t  |  j |  } t |  s" | Sy |   } Wn t k
 rN | j   } n Xt |  | |  | S(   N(   RT   R  t   callableR   t   __func__RW   (   RO   R|  RN   RZ   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRS  w  s    (   RV   R]   R^   RP   RS  (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  q  s   	RA   c           B  s<  e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z  d   Z! d    Z" d!   Z# d"   Z$ d#   Z% d$   Z& d%   Z' d&   Z( d'   Z) d(   Z* d)   Z+ d*   Z, d+   Z- d,   Z. d-   Z/ d.   Z0 d/   Z1 d0   Z2 d1   Z3 d2   Z4 d3   Z5 d4   Z6 d5   Z7 d6   Z8 d7   Z9 d8   Z: d9   Z; d:   Z< d;   Z= d<   Z> d=   Z? d>   Z@ RS(?   s   Namespace for module constants.c           C  s  iGd d 6d d 6d d 6d d 6d	 d
 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d  6d! d" 6d# d$ 6d% d& 6d' d( 6d) d* 6d+ d, 6d- d. 6d/ d0 6d1 d2 6d3 d4 6d5 d6 6d7 d8 6d9 d: 6d; d< 6d= d> 6d? d@ 6dA dB 6dC dD 6dE dF 6dG dH 6dI dJ 6dK dL 6dM dN 6dO dP 6dQ dR 6dS dT 6dU dV 6dW dX 6dY dZ 6d[ d\ 6d] d^ 6d_ d` 6da db 6dc dd 6de df 6dg dh 6di dj 6dk dl 6dm dn 6do dp 6dq dr 6ds dt 6du dv 6dw dx 6dy dz 6d{ d| 6d} d~ 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6dd6dd6dd6dd6d	d
6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd 6d!d"6d#d$6d%d&6d'd(6d)d*6d+d,6d-d.6d/d06d1d26d3d46d5d66d7d86d9d:6d;d<6d=d>6d?d@6dAdB6dCdD6dEdF6dGdH6dIdJ6dKdL6dMdN6dOdP6dQdR6dSdT6dUdV6dWdX6dYdZ6d[d\6d]d^6d_d`6dadb6dcdd6dedf6dgdh6didj6dkdl6dmdn6dodp6dqdr6dsdt6dudv6dwdx6dydz6d{d|6d}d~6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd 6dd6dd6dd6dd6d	d
6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd 6d!d"6d#d$6d%d&6d'd(6d)d*6d+d,6d-d.6d/d06d1d26d3d46d5d66d7d86d9d:6d;d<6d=d>6d?d@6dAdB6dCdD6dEdF6dGdH6dIdJ6dKdL6dMdN6dOdP6dQdR6dSdT6dUdV6dWdX6dYdZ6d[d\6d]d^6d_d`6dadb6dcdd6dedf6dgdh6didj6dkdl6dmdn6dodp6dqdr6dsdt6dudv6dwdx6dydz6d{d|6d}d~6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd 6dd6dd6dd6dd6d	d
6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd 6d!d"6d#d$6d%d&6d'd(6d)d*6d+d,6d-d.6d/d06d1d26d3d46d5d66d7d86d9d:6d;d<6d=d>6d?d@6dAdB6dCdD6dEdF6dGdH6dIdJ6dKdL6dMdN6dOdP6dQdR6dSdT6dUdV6dWdX6dYdZ6d[d\6d]d^6d_d`6dadb6dcdd6dedf6dgdh6didj6dkdl6dmdn6dodp6dqdr6dsdt6dudv6dwdx6dydz6d{d|6d}d~6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd 6dd6dd6dd6dd6d	d
6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd 6d!d"6d#d$6d%d&6d'd(6d)d*6d+d,6d-d.6d/d06d1d26d3d46d5d66d7d86d9d:6d;d<6d=d>6d?d@6dAdB6dCdD6dEdF6dGdH6dIdJ6dKdL6dMdN6dOdP6dQdR6dSdT6dUdV6dWdX6dYdZ6d[d\6d]d^6d_d`6dadb6dcdd6dedf6dgdh6didj6dkdl6dmdn6dodp6dqdr6dsdt6dudv6dwdx6dydz6d{d|6d}d~6dd6dd6dd6dd6dd6dd6dd6dd6S(  Nt   ProcessingSoftwarei   R   i   t   SubfileTypei   R   i   R   i  R   i  R   i  R   i  t   Thresholdingi  t	   CellWidthi  t
   CellLengthi	  t	   FillOrderi
  t   DocumentNamei  R   i  t   Makei  t   Modeli  R  i  t   Orientationi  R   i  R   i  R  i  t   MinSampleValuei  t   MaxSampleValuei  R   i  R   i  R   i  t   PageNamei  t	   XPositioni  t	   YPositioni  t   FreeOffsetsi   t   FreeByteCountsi!  t   GrayResponseUniti"  t   GrayResponseCurvei#  t	   T4Optionsi$  t	   T6Optionsi%  R   i(  t
   PageNumberi)  t   ColorResponseUniti,  t   TransferFunctioni-  R   i1  R   i2  t   Artisti;  t   HostComputeri<  R   i=  t
   WhitePointi>  t   PrimaryChromaticitiesi?  R   i@  t   HalftoneHintsiA  R   iB  R   iC  R  iD  R  iE  t   BadFaxLinesiF  t   CleanFaxDataiG  t   ConsecutiveBadFaxLinesiH  t   SubIFDsiJ  t   InkSetiL  t   InkNamesiM  t   NumberOfInksiN  t   DotRangeiP  t   TargetPrinteriQ  R   iR  R   iS  t   SMinSampleValueiT  t   SMaxSampleValueiU  t   TransferRangeiV  t   ClipPathiW  t   XClipPathUnitsiX  t   YClipPathUnitsiY  t   IndexediZ  R  i[  t   OPIProxyi_  t   GlobalParametersIFDi  t   ProfileTypei  t
   FaxProfilei  t   CodingMethodsi  t   VersionYeari  t
   ModeNumberi  t   Decodei  t   DefaultImageColori  t
   T82Optionsi  t   JPEGTables_i  t   JPEGProci   t   JPEGInterchangeFormati  t   JPEGInterchangeFormatLengthi  t   JPEGRestartIntervali  t   JPEGLosslessPredictorsi  t   JPEGPointTransformsi  t   JPEGQTablesi  t   JPEGDCTablesi  t   JPEGACTablesi	  t   YCbCrCoefficientsi  RQ  i  t   YCbCrPositioningi  t   ReferenceBlackWhitei  t   StripRowCountsi/  t   XMPi  t   GDIGammai  t   ICCProfileDescriptori  t   SRGBRenderingIntenti  t
   ImageTitlei   t   USPTO_Miscellaneousi  R  i   t   AndorTemperaturei  t   AndorExposureTimei  t   AndorKineticCycleTimei  t   AndorAccumulationsi  t   AndorAcquisitionCycleTimei  t   AndorReadoutTimei  t   AndorPhotonCountingi  t   AndorEmDacLeveli  t   AndorFramesi  t   AndorHorizontalFlipi   t   AndorVerticalFlipi!  t   AndorClockwisei"  t   AndorCounterClockwisei#  t   AndorVerticalClockVoltagei(  t   AndorVerticalShiftSpeedi)  t   AndorPreAmpSettingi+  t   AndorCameraSeriali,  t   AndorActualTemperaturei/  t   AndorBaselineClampi0  t   AndorPrescansi1  t
   AndorModeli2  t   AndorChipSizeXi3  t   AndorChipSizeYi4  t   AndorBaselineOffsetiP  t   AndorSoftwareVersionif  t   RatingiFG  t
   XP_DIP_XMLiGG  t
   StitchInfoiHG  t   RatingPercentiIG  t   ResolutionXUnitiP  t   ResolutionYUnitiP  t   ResolutionXLengthUnitiP  t   ResolutionYLengthUnitiP  t
   PrintFlagsiP  t   PrintFlagsVersioniP  t   PrintFlagsCropiP  t   PrintFlagsBleedWidthiP  t   PrintFlagsBleedWidthScalei	P  t   HalftoneLPIi
P  t   HalftoneLPIUnitiP  t   HalftoneDegreeiP  t   HalftoneShapeiP  t   HalftoneMisciP  t   HalftoneScreeniP  t   JPEGQualityiP  t   GridSizeiP  t   ThumbnailFormatiP  t   ThumbnailWidthiP  t   ThumbnailHeightiP  t   ThumbnailColorDepthiP  t   ThumbnailPlanesiP  t   ThumbnailRawBytesiP  t   ThumbnailSizeiP  t   ThumbnailCompressedSizeiP  t   ColorTransferFunctioniP  t   ThumbnailDataiP  t   ThumbnailImageWidthi P  t   ThumbnailImageHeighti!P  t   ThumbnailBitsPerSamplei"P  t   ThumbnailCompressioni#P  t   ThumbnailPhotometricInterpi$P  t   ThumbnailImageDescriptioni%P  t   ThumbnailEquipMakei&P  t   ThumbnailEquipModeli'P  t   ThumbnailStripOffsetsi(P  t   ThumbnailOrientationi)P  t   ThumbnailSamplesPerPixeli*P  t   ThumbnailRowsPerStripi+P  t   ThumbnailStripBytesCounti,P  t   ThumbnailResolutionXi-P  t   ThumbnailResolutionYi.P  t   ThumbnailPlanarConfigi/P  t   ThumbnailResolutionUniti0P  t   ThumbnailTransferFunctioni1P  t   ThumbnailSoftwareUsedi2P  t   ThumbnailDateTimei3P  t   ThumbnailArtisti4P  t   ThumbnailWhitePointi5P  t   ThumbnailPrimaryChromaticitiesi6P  t   ThumbnailYCbCrCoefficientsi7P  t   ThumbnailYCbCrSubsamplingi8P  t   ThumbnailYCbCrPositioningi9P  t   ThumbnailRefBlackWhitei:P  t   ThumbnailCopyRighti;P  t   InteroperabilityIndexiAP  t   InteroperabilityVersioniBP  t   LuminanceTableiP  t   ChrominanceTableiP  t
   FrameDelayi Q  t	   LoopCountiQ  t   GlobalPaletteiQ  t   IndexBackgroundiQ  t   IndexTransparentiQ  t	   PixelUnitiQ  t   PixelPerUnitXiQ  t   PixelPerUnitYiQ  t   PaletteHistogramiQ  t   SonyRawFileTypei p  t   VignettingCorrParamsi2p  t   ChromaticAberrationCorrParamsi5p  t   DistortionCorrParamsi7p  t   ImageIDi  t   WangTag1i  t   WangAnnotationi  t   WangTag3i  t   WangTag4i  t   ImageReferencePointsi  t   RegionXformTackPointi  t   WarpQuadrilaterali  t   AffineTransformMati  t   Matteingi  t   DataTypei  R   i  R   i  t   ImageFullWidthi  t   ImageFullLengthi  t   TextureFormati  t   TextureWrapModesi  t   FieldOfViewCotangenti  t   MatrixWorldToScreeni  t   MatrixWorldToCamerai  t   Model2i}  t   CFARepeatPatternDimi  t
   CFAPatterni  t   BatteryLeveli  t   KodakIFDi  t   ExposureTimei  t   FNumberi  t	   Copyrighti  R  i  t   MDScalePixeli  t   MDColorTablei  t	   MDLabNamei  t   MDSampleInfoi  t
   MDPrepDatei  t
   MDPrepTimei  t   MDFileUnitsi  R)  i  t   AdventScalei5  t   AdventRevisioni6  Rq  i\  Rn  i]  Rr  i^  Rs  i_  t   IPTCNAAi  t   ExtendedTagsOffsetiB  t   IntergraphPacketDatai~  t   IntergraphFlagRegistersi  R'  i  t   INGRReservedi  R+  i  t
   LeicaMagici  t   Sitei  t   ColorSequencei  t	   IT8Headeri  t   RasterPaddingi  t   BitsPerRunLengthi  t   BitsPerExtendedRunLengthi  t
   ColorTablei  t   ImageColorIndicatori  t   BackgroundColorIndicatori  t   ImageColorValuei  t   BackgroundColorValuei  t   PixelIntensityRangei  t   TransparencyIndicatori  t   ColorCharacterizationi  t   HCUsagei  t   TrapIndicatori  t   CMYKEquivalenti  R  iF  t	   AFCP_IPTCih  t   PixelMagicJBIGOptionsi  t   JPLCartoIFDiׅ  t   IPLABiJ  R-  i؅  t   WB_GRGBLevelsi  t   LeafDatai  R  i9  R  i:  t
   MM_Unknowni;  t   ImageResourcesiI  t   MM_UserBlockiR  Rm  il  t   ExifTagii  t   InterColorProfileis  R  ix  R  iz  t	   FEI_TITANi{  t   FXExtensionsi  t   MultiProfilesi  t
   SharedDatai  t
   T88Optionsi  t   MarCCDi  t
   ImageLayeri  R#  i  t   GeoDoubleParamsTagi  t   GeoAsciiParamsTagi  t   JBIGOptionsi  t   PIXTIFFi  t   ExposureProgrami"  t   SpectralSensitivityi$  t   GPSTagi%  t   ISOSpeedRatingsi'  t   OECFi(  t	   Interlacei)  t   TimeZoneOffseti*  t   SelfTimerModei+  t   SensitivityTypei0  t   StandardOutputSensitivityi1  t   RecommendedExposureIndexi2  t   ISOSpeedi3  t   ISOSpeedLatitudeyyyi4  t   ISOSpeedLatitudezzzi5  t   HylaFAXFaxRecvParamsi\  t   HylaFAXFaxSubAddressi]  t   HylaFAXFaxRecvTimei^  t   FaxDcsi_  t   FedexEDRiq  t
   LeafSubIFDi  t	   Aphelion1i  t	   Aphelion2i  t   AphelionInternali  t   ExifVersioni   t   DateTimeOriginali  t   DateTimeDigitizedi  t   GooglePlusUploadCodei	  t
   OffsetTimei  t   OffsetTimeOriginali  t   OffsetTimeDigitizedi  t   ComponentsConfigurationi  t   CompressedBitsPerPixeli  t   ShutterSpeedValuei  t   ApertureValuei  t   BrightnessValuei  t   ExposureBiasValuei  t   MaxApertureValuei  t   SubjectDistancei  t   MeteringModei  t   LightSourcei  t   Flashi	  t   FocalLengthi
  t   FlashEnergy_i  t   SpatialFrequencyResponse_i  t   Noisei  t   FocalPlaneXResolutioni  t   FocalPlaneYResolutioni  t   FocalPlaneResolutionUniti  t   ImageNumberi  t   SecurityClassificationi  t   ImageHistoryi  t   SubjectLocationi  t   ExposureIndexi  t   TIFFEPStandardIDi  t   SensingMethodi  t   CIP3DataFilei:  t	   CIP3Sheeti;  t   CIP3Sidei<  t   StoNitsi?  t	   MakerNotei|  t   UserCommenti  t
   SubsecTimei  t   SubsecTimeOriginali  t   SubsecTimeDigitizedi  t   MODITexti/  t   MODIOLEPropertySetStoragei0  t   MODIPositioningi1  R  iJ  t   TVIPS1iK  t   TVIPS2iL  t   ImageSourceDatai\  t   Temperaturei   t   Humidityi  t   Pressurei  t
   WaterDepthi  t   Accelerationi  t   CameraElevationAnglei  t   MC_IpWinScaliA  t   MC_IdOldi  t   InteroperabilityTagi  t   XPTitlei  t	   XPCommenti  t   XPAuthori  t
   XPKeywordsi  t	   XPSubjecti  t   FlashpixVersioni   t
   ColorSpacei  t   PixelXDimensioni  t   PixelYDimensioni  t   RelatedSoundFilei  t   SamsungRawPointersOffseti  t   SamsungRawPointersLengthi  t   SamsungRawByteOrderi  t   SamsungRawUnknowni  t   FlashEnergyi  t   SpatialFrequencyResponsei  t   Noise_i  t   FocalPlaneXResolution_i  t   FocalPlaneYResolution_i  t   FocalPlaneResolutionUnit_i  t   ImageNumber_i  t   SecurityClassification_i  t   ImageHistory_i  t   SubjectLocation_i  s   ExposureIndex_ i  s   TIFF-EPStandardIDi  t   SensingMethod_i  t
   FileSourcei   t	   SceneTypei  t   CFAPattern_i  t   CustomRenderedi  t   ExposureModei  t   WhiteBalancei  t   DigitalZoomRatioi  t   FocalLengthIn35mmFilmi  t   SceneCaptureTypei  t   GainControli  t   Contrasti  t
   Saturationi	  t	   Sharpnessi
  t   DeviceSettingDescriptioni  t   SubjectDistanceRangei  t   ImageUniqueIDi   t   CameraOwnerNamei0  t   BodySerialNumberi1  t   LensSpecificationi2  t   LensMakei3  t	   LensModeli4  t   LensSerialNumberi5  t   GDAL_METADATAi  t   GDAL_NODATAi  t   Gammai   R  i2  t   ExpandSoftwarei  t
   ExpandLensi  t
   ExpandFilmi¯  t   ExpandFilterLensiï  t   ExpandScanneriį  t   ExpandFlashLampiů  t   PixelFormati  t   Transformationi  t   Uncompressedi  t	   ImageTypei  t   ImageWidth_i  t   ImageHeight_i  t   WidthResolutioni  t   HeightResolutioni  t   ImageOffseti  t   ImageByteCounti  t   AlphaOffseti¼  t   AlphaByteCountiü  t   ImageDataDiscardiļ  t   AlphaDataDiscardiż  t   OceScanjobDescriptioni'  t   OceApplicationSelectori(  t   OceIdentificationNumberi)  t   OceImageLogicCharacteristicsi*  t   AnnotationsiO  RT  ip  t   MC_XYPositioniq  t   MC_ZPositionir  t   MC_XYCalibrationis  t   MC_LensCharacteristicsit  t   MC_ChannelNameiu  t   MC_ExcitationWavelengthiv  t   MC_TimeStampiw  t   MC_FramePropertiesix  t   PrintImageMatchingi  t   PCO_RAWi?  t   OriginalFileNameis  t   USPTO_OriginalContentTypei  t   USPTO_RotationCodei  t   CR2CFAPatterni  t
   DNGVersioni  t   DNGBackwardVersioni  t   UniqueCameraModeli  t   LocalizedCameraModeli  t   CFAPlaneColori  t	   CFALayouti  t   LinearizationTablei  t   BlackLevelRepeatDimi  t
   BlackLeveli  t   BlackLevelDeltaHi  t   BlackLevelDeltaVi  t
   WhiteLeveli  t   DefaultScalei  t   DefaultCropOrigini  t   DefaultCropSizei   t   ColorMatrix1i!  t   ColorMatrix2i"  t   CameraCalibration1i#  t   CameraCalibration2i$  t   ReductionMatrix1i%  t   ReductionMatrix2i&  t   AnalogBalancei'  t   AsShotNeutrali(  t   AsShotWhiteXYi)  t   BaselineExposurei*  t   BaselineNoisei+  t   BaselineSharpnessi,  t   BayerGreenSpliti-  t   LinearResponseLimiti.  t   CameraSerialNumberi/  t   LensInfoi0  t   ChromaBlurRadiusi1  t   AntiAliasStrengthi2  t   ShadowScalei3  t   DNGPrivateDatai4  t   MakerNoteSafetyi5  t   RawImageSegmentationi@  t   CalibrationIlluminant1iZ  t   CalibrationIlluminant2i[  t   BestQualityScalei\  t   RawDataUniqueIDi]  t   AliasLayerMetadatai`  t   OriginalRawFileNamei  t   OriginalRawFileDatai  t
   ActiveAreai  t   MaskedAreasi  t   AsShotICCProfilei  t   AsShotPreProfileMatrixi  t   CurrentICCProfilei  t   CurrentPreProfileMatrixi  R  i  R  i  R/  i  t   ColorimetricReferencei  t   SRawTypei  t   PanasonicTitlei  t   PanasonicTitle2i  t   CameraCalibrationSignaturei  t   ProfileCalibrationSignaturei  t
   ProfileIFDi  t   AsShotProfileNamei  t   NoiseReductionAppliedi  t   ProfileNamei  t   ProfileHueSatMapDimsi  t   ProfileHueSatMapData1i  t   ProfileHueSatMapData2i  t   ProfileToneCurvei  t   ProfileEmbedPolicyi  t   ProfileCopyrighti  t   ForwardMatrix1i  t   ForwardMatrix2i  t   PreviewApplicationNamei  t   PreviewApplicationVersioni  t   PreviewSettingsNamei  t   PreviewSettingsDigesti  t   PreviewColorSpacei  t   PreviewDateTimei  t   RawImageDigesti  t   OriginalRawFileDigesti  t   SubTileBlockSizei  t   RowInterleaveFactori  t   ProfileLookTableDimsi%  t   ProfileLookTableDatai&  t   OpcodeList1i@  t   OpcodeList2iA  t   OpcodeList3iN  t	   FibicsXMLiO  t   NoiseProfileia  t	   TimeCodesic  t	   FrameRateid  t   TStopir  t   ReelNamei  t   OriginalDefaultFinalSizei  t   OriginalBestQualitySizei  t   OriginalDefaultCropSizei  t   CameraLabeli  t   ProfileHueSatMapEncodingi  t   ProfileLookTableEncodingi  t   BaselineExposureOffseti  t   DefaultBlackRenderi  t   NewRawImageDigesti  t   RawToPreviewGaini  t   DefaultUserCropi  R  i  t   Paddingi  t   OffsetSchemai  t   FlexXMLi  t	   PerSamplei  (    (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s   c           C  s   d   t  j j   D S(   Nc         S  s   i  |  ] \ } } | |  q S(    (    (   R   R   R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys
   <dictcomp>  s   	 (   RA   R  R  (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR     s    c           C  s   i t  d 6t d 6t d 6t d 6t d 6t d 6t d 6t d 6t d	 6t	 d
 6t	 d 6t
 d 6t d 6t d 6t d 6t d 6t d 6t d 6t d 6t d 6t d 6t d 6t d 6t d 6t d 6t d 6S(   Ni@  i  i\  i]  i^  i_  iF  i9  i:  i;  iR  il  ix  iz  iJ  i\  i  i2  i  ip  ix  i  i  ii  i%  i  (   t   read_colormapRb  R  t   read_uic2tagt   read_uic3tagt   read_uic4tagt   read_cz_semt   read_mm_headert   read_mm_stampRc  t   read_cz_lsminfot   read_fei_metadatat   read_tvips_headert   read_nih_image_headert	   read_jsont   read_exif_ifdt   read_gps_ifdt   read_interoperability_ifd(    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRa    s6    c           C  s
   t  d  S(	   Ni  i  iD  iE  i  i  i  (   i  i  iD  iE  i  i  i  (   t	   frozenset(    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRd    s    c           C  s   i d d 6d d 6d d 6d d 6d	 d
 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d  6d! d" 6d# d$ 6d% d& 6d' d( 6S()   NR  R   R  R   R  R   R  R   R'  R   R  R  R&  R   R,  R   R-  R   RR  t   ImageDescription1RC  R   R*  R   R0  R   R+  R   R  R   R  R   RD  R   RI  R   R  R   R  R   (    (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  !  s*    c           C  s   i t  j d 6t  j d 6t  j d 6t  j d 6t  j d 6t  j d 6t  j d 6t  j d 6t  j	 d	 6t  j
 d
 6t  j d 6t  j d 6t  j d 6S(   Ni   i  i  i  i
  i  i  i"  i(  i,  i=  iR  iS  (   RA   t	   OFILETYPER  R  t
   THRESHHOLDt	   FILLORDERt   ORIENTATIONR  t   GRAYRESPONSEUNITR  t   COLORRESPONSEUNITt	   PREDICTORR  R  (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRh  :  s    











c          C  s   d t  j f d     Y}  |  S(   Nt   FILETYPEc           B  s    e  Z d  Z d Z d Z d Z RS(   i    i   i   i   (   RV   R]   t	   UNDEFINEDt   REDUCEDIMAGEt   PAGEt   MASK(    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  Q  s   (   t   enumt   IntFlag(   R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  P  s    c          C  s   d t  j f d     Y}  |  S(   NR  c           B  s    e  Z d  Z d Z d Z d Z RS(   i    i   i   i   (   RV   R]   R  t   IMAGER  R  (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  Z  s   (   R  t   IntEnum(   R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  Y  s    c          C  s   d t  j f d     Y}  |  S(   NR  c           B  s"  e  Z d  Z d Z d Z d Z d Z d Z d Z d Z	 d Z
 d	 Z d
 Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z  d Z! d  Z" d! Z# d" Z$ d# Z% d$ Z& d% Z' d& Z( d' Z) d( Z* d) Z+ d* Z, d+ Z- d, Z. d- Z/ d. Z0 RS(/   i   i   i   i   i   i   i   i   i	   i
   ic   i  i  i  i  i  i  i  i  i)  i  i  i  i  i  i  i  i  i  i  ie  it  iu  i  i  i  i  i  i  iL  im  in  iu  iv  i]  i  i  (1   RV   R]   t   NONEt   CCITTRLEt   CCITT_T4t   CCITT_T6t   LZWt   OJPEGt   JPEGR   t   JBIG_BWt
   JBIG_COLORt   JPEG_99t	   KODAK_262t   NEXTt   SONY_ARWt
   PACKED_RAWt   SAMSUNG_SRWt   CCIRLEWt   SAMSUNG_SRW2t   PACKBITSt   THUNDERSCANt   IT8CTPADt   IT8LWt   IT8MPt   IT8BLt	   PIXARFILMt   PIXARLOGt   DEFLATEt   DCSt   APERIO_JP2000_YCBCt   APERIO_JP2000_RGBt   JBIGt   SGILOGt   SGILOG24t   JPEG2000t	   NIKON_NEFt   JBIG2t
   MDI_BINARYt   MDI_PROGRESSIVEt
   MDI_VECTORt
   JPEG_LOSSYR   R   t   OPS_PNGt
   OPS_JPEGXRR  t	   KODAK_DCRt
   PENTAX_PEF(    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  b  s^   (   R  R  (   R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  a  s    1c          C  s   d t  j f d     Y}  |  S(   NR  c           B  s\   e  Z d  Z d Z d Z d Z d Z d Z d Z d Z	 d Z
 d	 Z d
 Z d Z d Z d Z RS(   i    i   i   i   i   i   i   i   i	   i
   i#  iL  iM  iL  (   RV   R]   R  R  R  R  R  R  t   YCBCRt   CIELABt   ICCLABt   ITULABR  t   LOGLt   LOGLUVt
   LINEAR_RAW(    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s   (   R  R  (   R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c          C  s   d t  j f d     Y}  |  S(   NR  c           B  s   e  Z d  Z d Z d Z RS(   i   i   i   (   RV   R]   t   BILEVELt   HALFTONEt   ERRORDIFFUSE(    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s   (   R  R  (   R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c          C  s   d t  j f d     Y}  |  S(   NR  c           B  s   e  Z d  Z d Z RS(   i   i   (   RV   R]   t   MSB2LSBt   LSB2MSB(    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s   (   R  R  (   R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c          C  s   d t  j f d     Y}  |  S(   NR  c           B  s8   e  Z d  Z d Z d Z d Z d Z d Z d Z d Z	 RS(   i   i   i   i   i   i   i   i   (
   RV   R]   t   TOPLEFTt   TOPRIGHTt   BOTRIGHTt   BOTLEFTt   LEFTTOPt   RIGHTTOPt   RIGHTBOTt   LEFTBOT(    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s   (   R  R  (   R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    	c          C  s   d t  j f d     Y}  |  S(   NR  c           B  s   e  Z d  Z d Z RS(   i   i   (   RV   R]   R	  R
  (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s   (   R  R  (   R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c          C  s   d t  j f d     Y}  |  S(   NR  c           B  s&   e  Z d  Z d Z d Z d Z d Z RS(   i   i   i   i   i   (   RV   R]   t   _10St   _100St   _1000St   _10000St   _100000S(    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s
   (   R  R  (   R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c          C  s   d t  j f d     Y}  |  S(   Nt	   GROUP4OPTc           B  s   e  Z d  Z RS(   i   (   RV   R]   t   UNCOMPRESSED(    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s   (   R  R  (   R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c          C  s   d t  j f d     Y}  |  S(   NR  c           B  s   e  Z d  Z d Z d Z RS(   i   i   i   (   RV   R]   R  t   INCHt
   CENTIMETER(    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s   (   R  R  (   R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c          C  s   d t  j f d     Y}  |  S(   NR  c           B  s&   e  Z d  Z d Z d Z d Z d Z RS(   i   i   i   i   i   (   RV   R]   R  R  R  R  R  (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s
   (   R  R  (   R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c          C  s   d t  j f d     Y}  |  S(   NR  c           B  s   e  Z d  Z d Z d Z RS(   i   i   i   (   RV   R]   R  t
   HORIZONTALt   FLOATINGPOINT(    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s   (   R  R  (   R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c          C  s   d t  j f d     Y}  |  S(   NR  c           B  s   e  Z d  Z d Z d Z RS(   i    i   i   (   RV   R]   t   UNSPECIFIEDt
   ASSOCALPHAt
   UNASSALPHA(    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s   (   R  R  (   R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c          C  s   d t  j f d     Y}  |  S(   NR  c           B  s,   e  Z d  Z d Z d Z d Z d Z d Z RS(   i   i   i   i   i   i   (   RV   R]   t   UINTt   INTt   IEEEFPt   VOIDt
   COMPLEXINTt   COMPLEXIEEEFP(    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s   (   R  R  (   R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c          C  s   d t  j f d     Y}  |  S(   Nt	   DATATYPESc           B  sz   e  Z d  Z d Z d Z d Z d Z d Z d Z d Z	 d Z
 d	 Z d
 Z d Z d Z d Z d Z d Z d Z d Z d Z RS(   i    i   i   i   i   i   i   i   i   i	   i
   i   i   i   i   i   i   i   i   (   RV   R]   t   NOTYPEt   BYTEt   ASCIIt   SHORTt   LONGt   RATIONALt   SBYTER  t   SSHORTt   SLONGt	   SRATIONALt   FLOATt   DOUBLER  t   UNICODEt   COMPLEXt   LONG8t   SLONG8t   IFD8(    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR'    s&   (   R  R  (   R'  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR'    s    c           C  st   i d d 6d d 6d d 6d d 6d	 d
 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6S(   NR_  i   t   1si   t   1Hi   t   1Ii   R   i   t   1bi   i   t   1hi   t   1ii	   t   2ii
   t   1fi   t   1di   i   t   1Qi   t   1qi   i   (    (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR`    s"    c           C  s_   i d d 6d d 6d d 6d d 6d	 d
 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6S(   Ni   R   i   R   i   Rp   i   Rq   i   R   i   t   bi   t   hi	   R   i
   R?  i   R   i   RY  i   Rn   i   t   q(    (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR   2  s    -c           C  s7  i+ d d1 6d d2 6d d3 6d d4 6d d5 6d d6 6d d7 6d d8 6d d9 6d d: 6d d; 6d d< 6d d= 6d d> 6d d? 6d d@ 6d dA 6d dB 6d dC 6d dD 6d dE 6d dF 6d dG 6d dH 6d dI 6d dJ 6d dK 6d dL 6d dM 6d dN 6d dO 6d dP 6d% dQ 6d' dR 6d( dS 6d) dT 6d* dU 6d+ dV 6d, dW 6d- dX 6d. dY 6d/ dZ 6d d d[ f 6S(\   NR   i   R   i   i   i   i   i   i   i   Rp   i	   i
   i   i   i   i   i   i   Rq   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i    Rn   i@   RD  RE  R   RF  R[   R   RY  t   Ft   Di   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i	   (   i   i
   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i    (   i   i@   (   i   i   (   i   i   (   i   i    (   i   i@   (   i   i   (   i   i    (   i   i@   (   i   i@   (   i   i   (   i   i   i   (    (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  7  sX    c          C  s   d t  f d     Y}  |    S(   Nt   Compressorsc           B  s)   e  Z d  Z d   Z d   Z d   Z RS(   s"   Delay import compressor functions.c         S  s-   i t  j d f d 6t  j d f d 6|  _ d  S(   Ni   i   i  (   t   zlibR   t   _compressors(   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRP   l  s    c           s  | |  j  k r |  j  | S| d k r y d d  l   Wn> t k
 rv y d d  l j   Wqw t k
 rr t  qw Xn X  f d   } | d f |  j  | <| d f S| d k r y d d  l } Wn t k
 r t  n X| j d f |  j  | <| j d f St  d  S(   Nim  ic           s     j  |   S(   N(   R   (   R   R   (   t   lzma(    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   lzma_compress}  s    i    in  i	   (   RK  RL  t   ImportErrort   backports.lzmaR   t   zstdR   (   RO   R   RM  RP  (    (   RL  s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  p  s*    

c         S  s)   y |  | t  SWn t k
 r$ t SXd  S(   N(   R5   R   R4   (   RO   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   __contains__  s
    (   RV   R]   R^   RP   R  RQ  (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRI  j  s   		(   t   object(   RI  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  g  s    *c          C  s   d t  f d     Y}  |    S(   Nt   Decompressorsc           B  s)   e  Z d  Z d   Z d   Z d   Z RS(   s$   Delay import decompressor functions.c         S  s=   i t  d  6t  d 6t d 6t j d 6t d 6t j d 6|  _ d  S(   Ni   i   i   i  i  (   R  R-   R   RJ  R  t   decode_packbitst   _decompressors(   RO   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRP     s    

c           sK  | |  j  k r |  j  | S| d k r y d d l m   m  Wn t k
 rY t  n Xd     f d  } | |  j  | <| S| d k r y d d  l } Wn> t k
 r y d d  l j } Wq t k
 r t  q Xn X| j	 |  j  | <| j	 S| d k rAy d d  l
 } Wn t k
 r)t  n X| j	 |  j  | <| j	 St  d  S(   Ni   i(   t   jpegt   jpeg_12c           sN   | d k r   j  |  | |  S| d k r>  j |  | |  St d   d  S(   Ni   i   s   bitspersample not supported(   t   decode_jpegt   decode_jpeg_12R   (   R   R  t   bpsR  (   RV  RW  (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRX    s
    im  in  (   RU  t   imagecodecsRV  RW  RN  R   R-   RL  RO  R  RP  (   RO   R   RX  RL  RP  (    (   RV  RW  s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s8    

c         S  s)   y |  | t  SWn t k
 r$ t SXd  S(   N(   R5   R   R4   (   RO   t   item(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRQ    s
    (   RV   R]   R^   RP   R  RQ  (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRS    s   		)(   RR  (   RS  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    :c           C  s   t  d j    S(   Ns#   shape ndim size dtype axes is_final(   Rc  R  (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR^    s    c             s2   t  d j      t    f d   t t  D  S(   Ns<   reduced final memmappable contiguous tiled chroma_subsampledc         3  s9   |  ]/ } | d   d k r | d    k r | d  Vq d S(   i   Rb   N(    (   R   Rc   (   t   exclude(    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>  s    (   Rc  R  t   dirRY  (    (    (   R]  s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c           C  s   t  d j    S(   NsB   tif tiff ome.tif lsm stk qptiff pcoraw gel seq svs bif tf8 tf2 btf(   R   R  (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   FILE_EXTENSIONS  s    c          C  s5   g  t  j D]  }  d |  j   d |  f ^ q
 d g S(   Ns   %s filess   *.%st   allfilest   *(   R`  Ra  (   RA   R_  R  (   R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   FILEOPEN_FILTER  s    c          C  s   i d d 6d d 6d d 6d d 6d	 d
 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d  6}  |  j  t d!   |  j   D   |  S("   NRX  t   XR[  t   Yt   depthR  t   sampleR  RF   Rq   t   timeR  t   channelR?   t   anglet   At   phaseR4  R(  t   Rt   lifetimeRp   t   lambdat   Et   exposuret   Lt   eventt   VR  Rn   t   mosaicR6  c         s  s!   |  ] \ } } | | f Vq d  S(   N(    (   R   R  R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>  s    (   R@   t   dictR  (   R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s&    
#c           C  s   t  t d d   S(   Ni   i  (   Rc  R   (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt
   ANDOR_TAGS  s    c          C  s|   i d d 6d d 6d d 6d d 6d	 d
 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6}  |  j  t j  |  S(   Nt	   OwnerNamei  t   SerialNumberi  t   Lensi  t   RawFileiL  t	   ConverteriM  R  iN  t   ExposureiQ  t   ShadowsiR  t
   BrightnessiS  R  iT  R  iU  R  iV  t
   SmoothnessiW  t   MoireFilteriX  (   R@   RA   R  (   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt	   EXIF_TAGS  s"    
c           C  s   i  d d 6d d 6d d 6d d 6d	 d
 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d  6d! d" 6d# d$ 6d% d& 6d' d( 6d) d* 6d+ d, 6d- d. 6d/ d0 6d1 d2 6d3 d4 6d5 d6 6d7 d8 6d9 d: 6d; d< 6d= d> 6d? d@ 6S(A   Nt   GPSVersionIDi    t   GPSLatitudeRefi   t   GPSLatitudei   t   GPSLongitudeRefi   t   GPSLongitudei   t   GPSAltitudeRefi   t   GPSAltitudei   t   GPSTimeStampi   t   GPSSatellitesi   t	   GPSStatusi	   t   GPSMeasureModei
   t   GPSDOPi   t   GPSSpeedRefi   t   GPSSpeedi   t   GPSTrackRefi   t   GPSTracki   t   GPSImgDirectionRefi   t   GPSImgDirectioni   t   GPSMapDatumi   t   GPSDestLatitudeRefi   t   GPSDestLatitudei   t   GPSDestLongitudeRefi   t   GPSDestLongitudei   t   GPSDestBearingRefi   t   GPSDestBearingi   t   GPSDestDistanceRefi   t   GPSDestDistancei   t   GPSProcessingMethodi   t   GPSAreaInformationi   t   GPSDateStampi   t   GPSDifferentiali   t   GPSHPositioningErrori   (    (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   GPS_TAGS  sB    c           C  s'   i d d 6d d 6d d 6d d 6d	 d
 6S(   NRB  i   RC  i   t   RelatedImageFileFormati   t   RelatedImageWidthi  t   RelatedImageLengthi  (    (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   IOP_TAGS>  s    c           C  sT  i0 d d 6d d 6d d 6d d 6d	 d
 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d  6d! d" 6d# d$ 6d% d& 6d' d( 6d) d* 6d+ d, 6d- d. 6d/ d0 6d1 d2 6d3 d4 6d5 d6 6d7 d8 6d9 d: 6d; d< 6d= d> 6d? d@ 6dA dB 6dC dD 6dE dF 6dG dH 6dI dJ 6dK dL 6dE dM 6dN dO 6dP dQ 6dR dS 6dT dU 6dV dW 6dX dY 6dZ d[ 6d\ d] 6d^ d_ 6S(`   Nt   GTModelTypeGeoKeyi   t   GTRasterTypeGeoKeyi  t   GTCitationGeoKeyi  t   GeographicTypeGeoKeyi   t   GeogCitationGeoKeyi  t   GeogGeodeticDatumGeoKeyi  t   GeogPrimeMeridianGeoKeyi  t   GeogLinearUnitsGeoKeyi  t   GeogLinearUnitSizeGeoKeyi  t   GeogAngularUnitsGeoKeyi  t   GeogAngularUnitsSizeGeoKeyi  t   GeogEllipsoidGeoKeyi  t   GeogSemiMajorAxisGeoKeyi	  t   GeogSemiMinorAxisGeoKeyi
  t   GeogInvFlatteningGeoKeyi  t   GeogAzimuthUnitsGeoKeyi  t   GeogPrimeMeridianLongGeoKeyi  t   GeogTOWGS84GeoKeyi  t"   ProjLinearUnitsInterpCorrectGeoKeyi  t   ProjectedCSTypeGeoKeyi   t   PCSCitationGeoKeyi  t   ProjectionGeoKeyi  t   ProjCoordTransGeoKeyi  t   ProjLinearUnitsGeoKeyi  t   ProjLinearUnitSizeGeoKeyi  t   ProjStdParallel1GeoKeyi  t   ProjStdParallel2GeoKeyi  t   ProjNatOriginLongGeoKeyi  t   ProjNatOriginLatGeoKeyi	  t   ProjFalseEastingGeoKeyi
  t   ProjFalseNorthingGeoKeyi  t   ProjFalseOriginLongGeoKeyi  t   ProjFalseOriginLatGeoKeyi  t   ProjFalseOriginEastingGeoKeyi  t   ProjFalseOriginNorthingGeoKeyi  t   ProjCenterLongGeoKeyi  t   ProjCenterLatGeoKeyi  t   ProjCenterEastingGeoKeyi  i  t   ProjScaleAtNatOriginGeoKeyi  t   ProjScaleAtCenterGeoKeyi  t   ProjAzimuthAngleGeoKeyi  t   ProjStraightVertPoleLongGeoKeyi  t   ProjRectifiedGridAngleGeoKeyi  t   VerticalCSTypeGeoKeyi   t   VerticalCitationGeoKeyi  t   VerticalDatumGeoKeyi  t   VerticalUnitsGeoKeyi  (    (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR@  G  sb    c          C  sf   y d d l  m }  WnK t t f k
 ra y d d l  m }  Wqb t t f k
 r] i  }  qb Xn X|  S(   Ni   (   RA  i(   t   tifffile_geodbRA  RN  R   (   RA  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRA  {  s    c        ;   C  s   dA dB dC dD dE dF dG dH dI dJ dK dL dM dN dO dP dQ dR dS dT dU dV dW dX dY dZ d[ d\ d] d^ d_ d` da db dc dd de df dg dh di dj dk dl dm dn do dp dq dr ds dt du dv dw dx dy dz g: S({   Nt   MagicNumbert   u4t   StructureSizet   i4t
   DimensionXt
   DimensionYt
   DimensionZt   DimensionChannelst   DimensionTimeR]  t
   ThumbnailXt
   ThumbnailYt
   VoxelSizeXt   f8t
   VoxelSizeYt
   VoxelSizeZt   OriginXt   OriginYt   OriginZR0  t   u2t   SpectralScant
   TypeOfDatat   OffsetVectorOverlayt   OffsetInputLutt   OffsetOutputLutt   OffsetChannelColorst   TimeIntervallt   OffsetChannelDataTypest   OffsetScanInformationt   OffsetKsDatat   OffsetTimeStampst   OffsetEventListt	   OffsetRoit   OffsetBleachRoit   OffsetNextRecordingt   DisplayAspectXt   DisplayAspectYt   DisplayAspectZt   DisplayAspectTimet   OffsetMeanOfRoisOverlayt   OffsetTopoIsolineOverlayt   OffsetTopoProfileOverlayt   OffsetLinescanOverlayt   ToolbarFlagst   OffsetChannelWavelengtht   OffsetChannelFactorst   ObjectiveSphereCorrectiont   OffsetUnmixParameterst   OffsetAcquisitionParameterst   OffsetCharacteristicst   OffsetPalettet   TimeDifferenceXt   TimeDifferenceYt   TimeDifferenceZt   InternalUse1R3  R5  t   DimensionsReservedt   16i4t   OffsetTilePositionsR   t   9u4t   OffsetPositions(   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R]  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R0  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R   R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R	  R  (   R
  R  (   R  R  (   R  R  (   R3  R  (   R5  R  (   R  R  (   R  R  (   R   R  (   R  R  (    (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRm    st    c           C  s   i t  d 6t d 6t d 6t d 6t d 6t d 6d  d 6d  d 6d  d	 6d  d
 6d  d 6d  d 6d  d 6d  d 6d  d 6d  d 6d  d 6d  d 6d  d 6d  d 6d  d 6d  d 6d  d 6d  d 6S(   Nt   ScanInformationt
   TimeStampst	   EventListt   ChannelColorst	   Positionst   TilePositionst   VectorOverlayt   InputLutt	   OutputLutR  t   ChannelDataTypest   KsDatat   Roit	   BleachRoit   NextRecordingt   MeanOfRoisOverlayt   TopoIsolineOverlayt   TopoProfileOverlayt   ChannelWavelengtht   SphereCorrectiont   ChannelFactorst   UnmixParameterst   AcquisitionParameterst   Characteristics(   t   read_lsm_scaninfot   read_lsm_timestampst   read_lsm_eventlistt   read_lsm_channelcolorst   read_lsm_floatpairsR-   (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   CZ_LSMINFO_READERS  s2    c           C  sQ   i d d 6d d 6d d 6d d 6d d 6d d	 6d d
 6d d 6d d 6d d 6d d 6S(   Nt   XYZCTi    i   i   t   XYTCZi   t   XYZTCi   i   i   t   XYCTZi   t   XYCZTi   i	   i
   (    (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR=    s    c           C  s5   i d d 6d d 6d d 6d d 6d	 d
 6d d 6d d 6S(   NR  Rc  R  Rd  R  R  R  R?   R  R  R3  R4  R5  R6  (    (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR7    s    c           C  s    i d d 6d d 6d d 6d d 6S(	   Ns   varying data typesi    s   8 bit unsigned integeri   s   12 bit unsigned integeri   s   32 bit floati   (    (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   CZ_LSMINFO_DATATYPES   s
    c           C  s    i d d 6d d 6d d 6d d 6S(	   Ns   Original scan datai    s   Calculated datai   s   3D reconstructioni   s   Topography height mapi   (    (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   CZ_LSMINFO_TYPEOFDATA	  s
    c           C  s<   i d d 6d d 6d d 6d d 6d	 d
 6d d 6d d 6d d 6S(   Nt   Tracksi    t   Lasersi   0t   DetectionChannelsi   `t   IlluminationChannelsI       t   BeamSplittersI       t   DataChannelsI       t   Timersi   t   Markersi   (    (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   CZ_LSMINFO_SCANINFO_ARRAYS  s    c           C  s<   i d d 6d d 6d d 6d d 6d	 d
 6d d 6d d 6d d 6S(   Nt   Tracki   @t   Laseri   Pt   DetectionChanneli   pt   IlluminationChannelI       t   BeamSplitterI       t   DataChannelI       t   Timeri   t   Markeri   (    (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   CZ_LSMINFO_SCANINFO_STRUCTS  s    c           C  s!  i d d 6d d 6d d 6d d 6d	 d
 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d  6d! d" 6d# d$ 6d% d& 6d' d( 6d) d* 6d+ d, 6d- d. 6d/ d0 6d1 d2 6d3 d4 6d5 d6 6d7 d8 6d9 d: 6d; d< 6d= d> 6d? d@ 6dA dB 6dC dD 6dE dF 6dG dH 6dI dJ 6dK dL 6dM dN 6dO dP 6dQ dR 6dS dT 6dU dV 6dW dX 6dY dZ 6d[ d\ 6d] d^ 6d_ d` 6da db 6dc dd 6de df 6dg dh 6di dj 6dk dl 6dm dn 6do dp 6dq dr 6ds dt 6du dv 6dw dx 6dy dz 6d{ d| 6d} d~ 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6dd6dd6dd6dd6d	d
6dd6dd6dd6dd6dd6dd6dd6dd6dd6d d6d d6dd 6d!d"6d#d$6d%d&6d'd(6d)d*6d+d,6d d-6d d.6d d/6d0d16d2d36d4d56d6d76d8d96d:d;6d<d=6d>d?6d@dA6dBdC6dDdE6dFdG6dHdI6dJdK6dLdM6dNdO6ddP6ddQ6dRdS6d dT6d dU6d dV6dWdX6d dY6d dZ6d[d\6d]d^6d d_6d d`6d da6d db6S(c  NR  i  R  i  t   Notesi  t	   Objectivei  t   ProcessingSummaryi  t   SpecialScanModei  R0  i  t   ScanModei  t   NumberOfStacksi	  t   LinesPerPlanei
  t   SamplesPerLinei  t   PlanesPerVolumei  t   ImagesWidthi  t   ImagesHeighti  t   ImagesNumberPlanesi  t   ImagesNumberStacksi  t   ImagesNumberChannelsi  t   LinscanXySizei  t   ScanDirectioni  t
   TimeSeriesi  t   OriginalScanDatai  t   ZoomXi  t   ZoomYi  t   ZoomZi  t   Sample0Xi  t   Sample0Yi  t   Sample0Zi  t   SampleSpacingi  t   LineSpacingi  t   PlaneSpacingi  t
   PlaneWidthi  t   PlaneHeighti   t   VolumeDepthi!  t   Nutationi#  t   Rotationi4  t
   Precessioni5  t   Sample0timei6  t   StartScanTriggerIni7  t   StartScanTriggerOuti8  t   StartScanEventi9  t   StartScanTimei@  t   StopScanTriggerIniA  t   StopScanTriggerOutiB  t   StopScanEventiC  t   StopScanTimeiD  t   UseRoisiE  t   UseReducedMemoryRoisiF  t   UseriG  t   UseBcCorrectioniH  t   PositionBcCorrection1iI  t   PositionBcCorrection2iP  t   InterpolationYiQ  t   CameraBinningiR  t   CameraSupersamplingiS  t   CameraFrameWidthiT  t   CameraFrameHeightiU  t   CameraOffsetXiV  t   CameraOffsetYiW  t	   RtBinningiY  t   RtFrameWidthiZ  t   RtFrameHeighti[  t   RtRegionWidthi\  t   RtRegionHeighti]  t	   RtOffsetXi^  t	   RtOffsetYi_  t   RtZoomi`  t   RtLinePeriodia  t   Prescanib  t   ScanDirectionZic  t   MultiplexTypei  @t   MultiplexOrderi  @t   SamplingModei  @t   SamplingMethodi  @t   SamplingNumberi  @t   Acquirei  @t   SampleObservationTimei  @t   TimeBetweenStacksi  @i  @t   Collimator1Namei  @t   Collimator1Positioni  @t   Collimator2Namei  @t   Collimator2Positioni  @t   IsBleachTracki  @t   IsBleachAfterScanNumberi  @t   BleachScanNumberi  @t	   TriggerIni  @t
   TriggerOuti  @t   IsRatioTracki  @t   BleachCounti  @t   SpiCenterWavelengthi  @t	   PixelTimei  @t   CondensorFrontlensi!  @t   FieldStopValuei#  @t   IdCondensorAperturei$  @t   CondensorAperturei%  @t   IdCondensorRevolveri&  @t   CondensorFilteri'  @t   IdTransmissionFilter1i(  @t   IdTransmission1i)  @t   IdTransmissionFilter2i0  @t   IdTransmission2i1  @t   RepeatBleachi2  @t   EnableSpotBleachPosi3  @t   SpotBleachPosxi4  @t   SpotBleachPosyi5  @t   SpotBleachPoszi6  @t
   IdTubelensi7  @t   IdTubelensPositioni8  @t   TransmittedLighti9  @t   ReflectedLighti:  @t   SimultanGrabAndBleachi;  @t   BleachPixelTimei<  @i  Pi  Pt   Poweri  Pt   IntegrationModei  pt   SpecialModei  pt   DetectorGainFirsti  pt   DetectorGainLasti  pt   AmplifierGainFirsti  pt   AmplifierGainLasti  pt   AmplifierOffsFirsti  pt   AmplifierOffsLasti  pt   PinholeDiameteri	  pt   CountingTriggeri
  pi  pt   PointDetectorNamei  pt   AmplifierNamei  pt   PinholeNamei  pt   FilterSetNamei  pt
   FilterNamei  pt   IntegratorNamei  pt   ChannelNamei  pt   DetectorGainBc1i  pt   DetectorGainBc2i  pt   AmplifierGainBc1i  pt   AmplifierGainBc2i  pt   AmplifierOffsetBc1i  pt   AmplifierOffsetBc2i   pt   SpectralScanChannelsi!  pt   SpiWavelengthStarti"  pt   SpiWavelengthStopi#  pt   DyeNamei&  pt	   DyeFolderi'  pI      I      t
   WavelengthI      t   AquireI      t   DetchannelNameI      t   PowerBc1I      t   PowerBc2I      t	   FilterSetI      t   FilterI      I      I      I      t   ColorI      t
   SampleTypeI      R   I      t	   RatioTypeI      t   RatioTrack1I      t   RatioTrack2I	      t   RatioChannel1I
      t   RatioChannel2I      t   RatioConst1I      t   RatioConst2I      t   RatioConst3I      t   RatioConst4I      t   RatioConst5I      t   RatioConst6I      t   RatioFirstImages1I      t   RatioFirstImages2I      I      I      t   SpectrumI      I      i  i  t   Intervali  i  i  t   ActivationTimei  t   ActivationNumberi  i  i  i  i  (    (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   CZ_LSMINFO_SCANINFO_ATTRIBUTES+  sx   c        /   C  s   d> d? d@ dA dB dC d	 d
 dD f dE dF d d dG f dH dI dJ dK dL dM dN d dO dP g f d dQ dR g f dS dT dU dV dW dX dY dZ d[ d\ d] d^ d_ d` da db dc dd de df dg dh di dj dk dl dm g. S(n   Nt   FileIDt   a8t   nLinest   i2t   PixelsPerLinet   Versiont
   OldLutModet
   OldnColorst   Colorst   u1i   i    t   OldColorStartt
   ColorWidtht   ExtraColorsR  i   t   nExtraColorst   ForegroundIndext   BackgroundIndext   XScaleR  t   Unused2t   Unused3t   UnitsIDt   p1R   RN  t   p2t   CurveFitTypet   nCoefficientst   Coefft   UMsizet   UMt   a15t   UnusedBooleant	   BinaryPict   b1t
   SliceStartt   SliceEndt   ScaleMagnificationt   f4t   nSlicest   SliceSpacingt   CurrentSlicet   FrameIntervalt   PixelAspectRatiot
   ColorStartt   ColorEndt   nColorst   Fill1t   3u2t   Fill2t   Tablet   LutModet   InvertedTablet   ZeroClipt	   XUnitSizet   XUnitt   a11t	   StackType(   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   i   i    (   R  R  (   R  R  (   i   i   (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R   R  (   RN  R  (   R   R  (   RN  R  (   R  R  (   R  R  (   R  R  i   (   R  R  (   R  R  (   R  R  (   R	  R
  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R
  (   R  R
  (   R  R  (   R  R   (   R!  R  (    (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   NIH_IMAGE_HEADER  s\    c        
   C  s   d S(   Nt   CustomTablet   AppleDefaultt   Pseudo20t   Pseudo32t   Rainbowt   Fire1t   Fire2t   Icet   GraysR  (
   R#  R$  R%  R&  R'  R(  R)  R*  R+  R  (    (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   NIH_COLORTABLE_TYPE&  s     c           C  s   d S(   Nt   PseudoColort   OldAppleDefaultt   OldSpectrumt	   GrayScalet   ColorLutt   CustomGrayscale(   R-  R.  R/  R0  R1  R2  (    (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   NIH_LUTMODE_TYPE*  s     c           C  s   d S(   Nt   StraightLinet   Poly2t   Poly3t   Poly4t   Poly5t   ExpoFitt   PowerFitt   LogFitt
   RodbardFitt	   SpareFit1t   Uncalibratedt   UncalibratedOD(   R4  R5  R6  R7  R8  R9  R:  R;  R<  R=  R>  R?  (    (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   NIH_CURVEFIT_TYPE.  s      c           C  s   d S(   Nt
   Nanometerst   Micrometerst   Millimeterst   Centimeterst   Meterst
   Kilometerst   Inchest   Feett   MilesR  t
   OtherUnits(   RA  RB  RC  RD  RE  RF  RG  RH  RI  R  RJ  (    (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   NIH_UNITS_TYPE3  s      c           C  s   d S(   Nt   VolumeStackt   RGBStackt
   MovieStackt   HSVStack(   RL  RM  RN  RO  (    (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   NIH_STACKTYPE_TYPE8  s    c        +   C  s   d- d. d/ d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 d: d; d< d= d> d? d@ dA dB dC dD dE dF dG dH dI dJ dK dL dM dN dO dP dQ dR dS dT dU dV g* S(W   NR  R  t	   CommentV1t   a80t   HighTensiont   SphericalAberrationt   IlluminationAperturet   Magnificationt   PostMagnificationR  t   Defocust   Astigmatismt   AstigmatismDirectiont   BiprismVoltaget   SpecimenTiltAnglet   SpecimenTiltDirectiont   IlluminationTiltDirectiont   IlluminationTiltAnglet	   ImageModet   EnergySpreadt   ChromaticAberrationt   ShutterTypet   DefocusSpreadt	   CcdNumbert   CcdSizet	   OffsetXV1t	   OffsetYV1t   PhysicalPixelSizet   Binningt   ReadoutSpeedt   GainV1t   SensitivityV1t   ExposureTimeV1t   FlatCorrectedt   DeadPxCorrectedt	   ImageMeant   ImageStdt   DisplacementXt   DisplacementYt   DateV1t   TimeV1t   ImageMint   ImageMaxt   ImageStatisticsQuality(   R  R  (   RQ  RR  (   RS  R  (   RT  R  (   RU  R  (   RV  R  (   RW  R  (   R  R  (   RX  R  (   RY  R  (   RZ  R  (   R[  R  (   R\  R  (   R]  R  (   R^  R  (   R_  R  (   R`  R  (   Ra  R  (   Rb  R  (   Rc  R  (   Rd  R  (   Re  R  (   Rf  R  (   Rg  R  (   Rh  R  (   Ri  R  (   Rj  R  (   Rk  R  (   Rl  R  (   Rm  R  (   Rn  R  (   Ro  R  (   Rp  R  (   Rq  R  (   Rr  R  (   Rs  R  (   Rt  R  (   Ru  R  (   Rv  R  (   Rw  R  (   Rx  R  (   Ry  R  (    (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   TVIPS_HEADER_V1;  sT    c        7   C  s   dC dD dE dF dG dH dI dJ dK dL dM dN dO dP dQ dR dS dT dU dV dW dX dY dZ d[ d\ d] d^ d_ d` da db dc dd de df dg dh di dj dk dl dm dn do dp dq dr ds dt du dv dw dx g6 S(y   NR  t   V160t   ImageFoldert
   ImageSizeXR  t
   ImageSizeYt
   ImageSizeZt
   ImageSizeEt   ImageDataTypet   Datet   Timet   Commentt   V1024R  t   Scalingt   16f4t   ImageStatisticst   16c16R-  t   ImageDisplaTypet
   PixelSizeXR  t
   PixelSizeYt   ImageDistanceZt   ImageDistanceEt	   ImageMisct   32f4t   TemTypet   TemHighTensiont   TemAberrationst	   TemEnergyt   TemModet   TemMagnificationt   TemMagnificationCorrectionRW  t   TemStageTypet   TemStagePositiont   5f4t   TemImageShiftt   2f4t   TemBeamShiftt   TemBeamTiltt   TilingParameterst   7f4t   TemIlluminationt   3f4t
   TemShuttert   TemMisct
   CameraTypet   PhysicalPixelSizeXt   PhysicalPixelSizeYt   OffsetXt   OffsetYt   BinningXt   BinningYRj  t   Gaint   ReadoutRatet   FlatfieldDescriptiont   Sensitivityt   Doset   CamMisct   FeiMicroscopeInformationt   FeiSpecimenInformationt   MagicR  (   R  R{  (   R|  R{  (   R}  R  (   R~  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R-  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R{  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   RW  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R{  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   Rj  R  (   R  R  (   R  R  (   R  R{  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (    (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   TVIPS_HEADER_V2j  sl    c          C  sm   d& d' d( d) d* g }  d+ d, d- d. d/ d0 d1 d2 d3 d |  d f d4 d5 d6 d7 d8 d9 d: d; d< d" |  f d= d> d? g S(@   NR  t   a16R  R  t   OriginR  t
   Resolutiont   Unitt   a64t
   HeaderFlagR  R-  R  R  t   a257t
   OffsetDataR  t   PaletteSizet   OffsetPalette0t   OffsetPalette1t   CommentSizet   OffsetCommentR  i
   t   OffsetPositiont   MapTypet   MapMint   MapMaxt   MinValuet   MaxValuet	   OffsetMapR#  t   Offsett   GrayChannelt   OffsetThumbnailt
   VoiceFieldt   OffsetVoiceField(   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R-  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R  R  (   R#  R  (   R  R  (   R  R  (   R  R  (   R  R  (    (   t   MM_DIMENSION(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt	   MM_HEADER  s8    		c           C  sJ   i
 d d 6d d 6d d 6d d 6d d 6d d 6d d 6d	 d
 6d d 6d d 6S(   NRc  Rd  R  R  R?   t   CHt
   WAVELENGTHt   TIMERl  R1  Rs  t   EVENTRq  t   EXPOSURE(    (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c       C   C  s  d d l  m }  d t f d t f d t f d t f d |  f d |  f d	 t f d
 t f d t f d t f dL d t f d t f d t f d t f d t f d t f d t f d t f dM dN d |  f d |  f d |  f d |  f d t f d t f d t f dO dP dQ dR dS dT dU dV d( t f dW d+ |  f d, |  f dX dY dZ d[ d\ d] d^ d8 t f d_ d: t f d` d= t f d> |  f d? |  f d@ t f dA t f dB t f dC |  f dD |  f dE t f dF t f dG t f dH |  f dI |  f dJ t f dK t f gB S(a   Ni(   R   t	   AutoScalet   MinScalet   MaxScalet   SpatialCalibrationt   XCalibrationt   YCalibrationt   CalibrationUnitsR  t   ThreshStatet   ThreshStateRedt   tagid_10t   ThreshStateGreent   ThreshStateBluet   ThreshStateLot   ThreshStateHit   Zoomt
   CreateTimet   LastSavedTimet   currentBuffert   grayFitt   grayPointCountt   grayXt   grayYt   grayMint   grayMaxt   grayUnitNamet   StandardLUTt
   wavelengtht   StagePositions
   (%i,2,2)u4t   CameraChipOffsett   OverlayMaskt   OverlayCompresst   Overlayt   SpecialOverlayMaskt   SpecialOverlayCompresst   SpecialOverlayt   ImagePropertyt
   StageLabels   %ipt   AutoScaleLoInfot   AutoScaleHiInfot	   AbsoluteZs   (%i,2)u4t   AbsoluteZValids   (%i,)u4R#  Rq   t   GammaRedt
   GammaGreent	   GammaBluet	   CameraBinR   t   NewLUTt   ImagePropertyExt   PlanePropertyt   UserLutTables	   (256,3)u1t   RedAutoScaleInfot   RedAutoScaleLoInfot   RedAutoScaleHiInfot   RedMinScaleInfot   RedMaxScaleInfot   GreenAutoScaleInfot   GreenAutoScaleLoInfot   GreenAutoScaleHiInfot   GreenMinScaleInfot   GreenMaxScaleInfot   BlueAutoScaleInfot   BlueAutoScaleLoInfot   BlueAutoScaleHiInfot   BlueMinScaleInfot   BlueMaxScaleInfo(   R  N(   R  N(   R  N(   R  s
   (%i,2,2)u4(   R  s
   (%i,2,2)u4(   R  N(   R  N(   R  N(   R  N(   R  N(   R  N(   R  s   %ip(   R  s   (%i,2)u4(   R  s   (%i,)u4(   R#  Rq   (   R  Rq   (   R 	  Rq   (   R	  Rq   (   R	  R   (   R	  N(   R	  s	   (256,3)u1(   R   R   R   R{   R-   R}  t   read_uic_image_property(   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   UIC_TAGS  s    																																												c           C  s  i& t  d d   g t f d 6d d g t f d 6d g t f d 6d g t f d 6d g t f d 6d g t f d	 6d g t f d
 6d g t f d 6d d g t f d 6d g t f d 6d g t f d 6d g t f d 6d g t f d 6d g t f d 6d g t f d 6d d g t f d 6d g t f d 6d g t f d 6d d g t f d 6d g t f d 6d g t f d 6d g t f d 6d g t f d 6d g t f d 6d g t f d 6d g t f d 6d g t f d 6d g t f d  6d g t f d! 6d g t f d" 6d g t f d# 6t  d d   g t f d$ 6d g t f d% 6d g t f d& 6d g t f d' 6d g t f d( 6d g t f d) 6d g t f d* 6S(+   Ni   t   Detectori   t
   Pixel_sizei   t   Silicont   Exposure_timet   Exposure_periodt   Taut   Count_cutofft   Threshold_settingi   t   Gain_settingt   N_excluded_pixelst   Excluded_pixelst
   Flat_fieldt	   Trim_filet
   Image_pathR  t   Energy_ranget   Detector_distancet   Detector_Voffsett   Beam_xyt   Fluxt   Filter_transmissiont   Start_anglet   Angle_incrementt   Detector_2thetat   Polarizationt   Alphat   Kappat   Phit   Phi_incrementt   Chit   Chi_incrementt   Oscillation_axist   N_oscillationst   Start_positiont   Position_incrementt   Shutter_timet   Omegat   Omega_increment(   R  R-   R{   R  R   (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   PILATUS_HEADER!  sN    c           C  s   d S(   Ns    @ `P0pH(hX8xD$dT4tL,l\<|B"bR2r
J*jZ:zF&fV6vN.n^>~A!aQ1q	I)iY9yE%eU5uM-m]=}C#cS3sK+k[;{G'gW7wO/o_?(    (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   REVERSE_BITORDER_BYTESN  s    c           C  s   t  j t j d d S(   NR/   R  (   R.   R  RA   R>	  (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   REVERSE_BITORDER_ARRAY_  s    c          C  s   d d  l  }  |  j S(   Ni(   t   mmapRB   (   R@	  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRB   c  s    (A   RV   R]   R^   R  R   Ra  Rd  R  Rh  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R'  R`  R   R  R  R  R^  R  R_  Rb  R  Rv  R  R  R  R@  RA  Rm  R.  R=  R7  R4  R5  R>  RG  R  R"  R,  R3  R@  RK  RP  Rz  R  R  R  R	  R=	  R>	  R?	  RB   (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRA     s   	  q		#							4														
				0	/	?								$			4	
	A											3						/	;	"		K	-		c         C  s(  | d k rC | d } d } | d } d }	 | d }
 | d } nO | d k r | d	 } d } | d	 } d
 }	 | d }
 | d } n t  d   | d k r i  } n  | d k r d } n  g  } t j } |  j   } x+t |  | k  ry; | | |  j |   d } | d k r&t  d   n  Wn# t k
 rLt j	 d |  Pn Xi  } |  j |	 |  } |  j   } d } xt
 |  D]} | |
 | | | d ! \ } } | | | | d | |	 ! \ } } | |	 7} | j | t |   } y t j | } Wn$ t k
 r(t j d |   n Xd | | t | d  | d f } t j |  } | | k su| | k r| | |  d } | d k  s| |  j | k rt j d |   n  |  j |  | | k r| | d } | |  | | | |  } q| d k s'| d k rB| d d k rBt |  | | | |  } q| | k s^| d d k ry| | |  j |   } qt |  | | | |  } n< | d d k s| d k r| |  } n | | | |   } | | k r| t j k rt |  d k r| d } qn  | d k r|| d d k r|t | t  r|y t t |  j    } Wq|t k
 rxt j	 d |  q|Xn  | | | <qW| j |  |  j |  | | |  j |   d } | d k rPn  | |  j k rt j	 d |  Pn  |  j |  q W| r$| d k r$| d } n  | S(   s|   Read tags from chain of IFDs and return as list of dicts.

    The file handle position must be at a valid IFD header.

    i   Rq   i   Rp   i   R   R  i   Rn   i   R~  s   invalid offset sizei    i    i   s   suspicious number of tagss   corrupted tag list at offset %is   unknown tag data type %is   %s%i%si   s   invalid tag value offset %ii   iR   R   s'   tag %i: coercing invalid ASCII to bytess   invalid page offset %iNI       (    R   R-   R   R  Rw   R!   R  R2   R   R   R   R3   R{   RA   R`  R   R  R  R   R   R<   R   Rb  Rc  Rd  R   R   Re  Rf  Ra  Rg  R(   (   R   R*   R   t   tagnamest
   customtagst   maxifdsR   R  R;  R<  R  R  RL   R  RG   R  R   R8   R   R8  RM   R   Rj  R   RZ   R|  R/   R   R<   Rk  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt	   read_tagsi  s    





			 $
%(+c         C  s   t  |  | | t j d d } x: d
 D]2 } y t | |  | | <Wq% t k
 rV q% Xq% Wd | k r | d d  } yU | d k r t | d d  | d <n* | d k r | d d j d	  | d <n  Wq t k
 r q Xn  | S(   s,   Read EXIF tags from file and return as dict.RC	  i   R  R  R  i   s   ASCII   s   UNICODE s   utf-16(   R  R  (   RD	  RA   R  Re  R2   R  (   R   R*   R/   R   R   t   exifR|  t   idcode(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s     "c         C  s   t  |  | | t j d d S(   s+   Read GPS tags from file and return as dict.RC	  i   (   RD	  RA   R  (   R   R*   R/   R   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c         C  s&   i d d 6} t  |  | | | d d S(   s8   Read Interoperability tags from file and return as dict.RB  i   RC	  (   RD	  (   R   R*   R/   R   R   t	   tag_names(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c         C  s   | d d k r d n | | d } | t  j |  j 9} |  j |  } t |  | k r{ t j d t |  | f  n  | S(   s2   Read tag data from file and return as byte string.iR   R   s    failed to read all bytes: %i, %i(   R.   R/   R0   R  R!   R   R   (   R   R*   R/   R   R   R8   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRb    s    $ c         C  s   |  j  |  j d  S(   s5   Read tag data from file and return as unicode string.s   utf-8(   R  R  (   R   R*   R/   R   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt	   read_utf8  s    c         C  s4   | d d k r d n | | d } |  j  | |  S(   s2   Read tag data from file and return as numpy array.iR   RD  (   R  (   R   R*   R/   R   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRc    s    $c         C  s'   |  j  | | d |  } d | _ | S(   s7   Read ColorMap data from file and return as numpy array.ii   (   i   i(   R  R9   (   R   R*   R/   R   R   t   cmap(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    	c         C  sX   |  j  |  } y  t j t t |  d   SWn" t k
 rS t j d |  n Xd S(   s2   Read JSON tag data from file and return as object.s   utf-8s   invalid JSON '%s'N(   R  t   jsont   loadst   unicodeR   R   R   R   (   R   R*   R/   R   R   R8   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s
     c      	   C  s   |  j  t j d | } t |  } g  | d D]G } t | d  j   | d | d | d t | d  j   f ^ q/ | d <| d } t | d  j   | d | d | d t | d  j   f | d <| S(	   s9   Read FluoView mm_header tag from file and return as dict.R*   R  i    i   i   i   i   R  (   R  RA   R  t   recarray2dictRe  Ra  (   R   R*   R/   R   R   t   mmhRY  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    Y
Ec         C  s   |  j  | d d  S(   sA   Read FluoView mm_stamp tag from file and return as numpy.ndarray.R  i   (   R  (   R   R*   R/   R   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  %  s    c         C  s  | d k r | d k s t   i  } | d k r |  j d d |  j | d  } i | d d  d f | d d  d f d	 6} n | rx} t |  D]l } t j d
 |  j d   d }	 |	 d k r |  j d  q n  t |  |	 | d t \ }
 } | | |
 <q Wn  | S(   su   Read MetaMorph STK UIC1Tag from file and return as dict.

    Return empty dictionary if planecount is unknown.

    R   R;  Rl   s   <u4i   Ni    i   Rt  s   <Ii   i   i   i%   i(   i)   RG   (   R   R;  (   i   i   i%   i(   i)   (	   R   R  R  R   R   R  R  t   read_uic_tagR5   (   R   R*   R/   R   R   t
   planecountRL   R  RM   RG  R|  RZ   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  *  s    "4c         C  s   | d k r | d k s t   |  j d d |  j | d  } i | d d  d f | d d  d f d 6| d d  d	 f d
 6| d d  d f d 6| d d  d f d 6| d d  d f d 6S(   s8   Read MetaMorph STK UIC2Tag from file and return as dict.R   Rl   s   <u4i   Ni    i   Rt  i   Rw  i   Ru  i   Ry  i   Rv  (   R   R  R  (   R   R*   R/   RP	  R   R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  B  s    "+c         C  so   | d k r | d k s t   |  j d d |  j | d  } i | d d  d f | d d  d f d 6S(	   s8   Read MetaMorph STK UIC3Tag from file and return as dict.R   Rl   s   <u4i   Ni    i   t   Wavelengths(   R   R  R  (   R   R*   R/   RP	  R   R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  N  s    "c   	      C  s   | d k r | d k s t   i  } xa t r t j d |  j d   d } | d k r\ Pn  t |  | | d t \ } } | | | <q' W| S(   s8   Read MetaMorph STK UIC4Tag from file and return as dict.R;  Rl   s   <Hi   i    RG   (   R   R5   R   R  R  RO	  R4   (	   R   R*   R/   RP	  R   RL   RG  R|  RZ   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  U  s    	c           s  d   f d  } y t  j | \ } } Wn t k
 rJ d | |   f SXt  j d d } | r   j   } | t d f k r |   }	 |	 d k  r | t k r | d f St j d | |	 f  | |	 f S  j	 |	  q n  | d k rd | } |   }
 n| t k r|   }
 n| | k rF| d	  }
 |
 d
 |
 d }
 nS| t
 k rgt
 | d	    }
 n2| t k rt    }
 n| t k r"|   } d
 | k od k  n rt j d |   j |   d
 d  }
 t t |
   }
 q| rd }
 t j d |  qt d |   nw| d k rg  }
 xbt |  D] } |   } d
 | k ogd k  n rt j d |   j |   d
 d  } t t |   } |
 j |  qA| rt j d |  qAt d |   qAWn d | } d | k r	| | } n  d | k rV  j | d  d
 }
 |
 j d d	 k r|
 d |
 d }
 qnC t j |   j t j |    }
 t |
  d k r|
 d
 }
 n  | r  j	 | d  n  | |
 f S(   sg   Read a single UIC tag value from file and return tag name and value.

    UIC1Tags use an offset.

    i   c           s;   t  j d |    j d |    } |  d k r7 | d S| S(   Ns   <%iIi   i   i    (   R   R  R  (   R   RZ   (   R   (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   read_inth  s    #s   _TagId%ii   i   R   s#   invalid offset for uic tag '%s': %iRM   i   i    i
   s   %isis   corrupt string in uic tag '%s's   invalid string size: %is   %ipRl   s   %it   (.Ni   i   (   .i    (   .i   (   RA   R	  R  Rw   R   R-   R{   R   R   R   R}  R	  R   R  R  Re  R   R   R   R(   R  R9   R   R!   (   R   RG  RP	  RG   RR	  R|  R/   R   R   t   offRZ   R<   RM   t   string(    (   R   s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRO	  b  s|    	
	

	'	'
$c         C  s   t  j d |  j d   d } t  j d | |  j |   d d  } t  j d |  j d   \ } } | d k r t  j d |  j d	   } | d | d } nB t  j d |  j d   d } t  j d | |  j |   d } t d
 | d | d |  S(   s:   Read UIC ImagePropertyEx tag from file and return as dict.R   i   i    s   %isis   <IBi   Rt   i   R|  R\  RZ   (   R   R  R  Ru  (   R   R<   R|  R\  t   propRZ   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR	    s    '!#c         C  s  | d k s t   t j d |  j d   \ } } | d k rN t d   n  |  j d d  | t j t j	  j
 k  r g  } d	 } x\ t j	 D]E \ }	 } | t j |  j
 7} | | k r Pn  | j |	 | f  q Wn	 t j	 } |  j | d
 | } t |  } x t j j   D]{ \ }	 }
 |
 d k r3qn  | j d |	 d	  } | d k  r[qn  |  j |  y |
 |   | |	 <Wqt k
 rqXqW| S(   s1   Read CZ_LSMINFO tag from file and return as dict.Rl   s   <IIi   iLI iLI s   invalid CZ_LSMINFO structureii   i    R*   R  (   iLI iLI N(   R   R   R  R  R   R   R.   R/   RA   Rm  R0   R(   R  RM	  R.  R  R-   R3   (   R   R*   R/   R   R   t   magic_numbert   structure_sizet   lsminfoR<   R|  t   readerRG   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s8    !	c         C  s2   t  j d |  j d   d } |  j d d | S(   s>   Read LSM sequence of float pairs from file and return as list.s   <ii   i    s   <2f8R   (   R   R  R  R  (   R   R<   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR-    s    c         C  s2   t  j d |  j d   d } |  j d d | S(   s0   Read LSM positions from file and return as list.s   <Ii   i    s   <2f8R   (   R   R  R  R  (   R   R<   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   read_lsm_positions  s    c         C  sY   t  j d |  j d   \ } } | d d | k rF t j d  g  S|  j d d | S(   s2   Read LSM time stamps from file and return as list.s   <iii   s   invalid LSM TimeStamps blocks   <f8R   (   R   R  R  R   R   R  (   R   R<   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR*    s
    !c         C  s   t  j d |  j d   d } g  } xs | d k r t  j d |  j d   \ } } } t t |  j | d    } | j | | | f  | d 8} q( W| S(   sC   Read LSM events from file and return as list of (time, type, text).s   <IIi   i   i    s   <IdIi   (   R   R  R  Re  R   R(   (   R   R   t   eventst   esizet   etimet   etypet   etext(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR+    s    $c         C  sa  i t  d 6g  d 6g  d 6} |  j   } t j d |  j d   \ } } } } } } | | k rq t j d  | St |  | d <|  j | |  |  j	 d d | d	 j
 | d	 f  }	 |	 j   | d <|  j | |  |  j | |  }
 g  } x\ t |
  d	 k rRt j d
 |
 d	   d } | j t |
 d	 d | !  |
 d	 | }
 q W| | d <| S(   s>   Read LSM ChannelColors structure from file and return as dict.t   MonoR  t
   ColorNamess   <IIIIIIi   s#   invalid LSM ChannelColors structureR  R   i   s   <Ii    i   (   R4   Rw   R   R  R  R   R   R   R   R  R  RB  R!   R(   Re  (   R   RL   R   R<   t   ncolorst   nnamest   coffsett   noffsett   monot   colorst   buffert   names(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR,    s&    -(
c   
      C  s  i  } | g } t  j } t  j d |  j d   d d k rN t j d  | S|  j d  xt r| d |  j d   \ } } } | d	 k r t t |  j |    } n\ | d k r | d
 |  j d   d } n1 | d k r| d |  j d   d } n d } | t j	 k rM| j
 |  t j	 | } g  }	 |	 | | <|	 } n | t j k r| j
 |  i  }	 | j
 |	  |	 } nR | t j k rt j | } | | | <n) | d k r| j   } n | | d | <| s^ Pq^ q^ W| S(   s9   Read LSM ScanInfo structure from file and return as dict.s   <Ii   i    i   s   invalid LSM ScanInfo structurei   s   <IIIi   i   s   <ii   s   <dI    s	   Entry0x%x(   R   R  R  R   R   R5   Re  R   RA   R>  R(   RG  R  t   pop(
   R   t   blockt   blocksR  t   entryR/   R<   RZ   R|  t   newobj(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR)  1  sH    		%	!
		c         C  sp  i  } |  j  t j d | } x+ t j D]  \ } } | | j   | | <q( W| d d k rL|  j  t j d | } | d t d  k r t j d  i  Sxr t j D]g \ } } | j d  r | | j	   j
 d d	 d
 }	 t |	 d d | | <q | | j   | | <q WxY d D]. }
 | d |
 c d <| d |
 c d <qWn  | j d k rlt j d  i  S| S(   s.   Read TVIPS EM-MENU headers and return as dict.R*   R  i   R  I    s   invalid TVIPS v2 magic numberRs  t   utf16t   errorsR  t   nulls    R1  Ri  g    eAt	   PixelSizei   s   unknown TVIPS header version(   R  RA   Rz  RB  R  R   R   R   RX  R   R  R   R  (   R   R*   R/   R   R   RL   t   headerR|  t   typestrR   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  a  s*    c         C  s   i  } i  } t  |  j |   } x | j   D]~ } | j   } | j d  rl i  } | | | d d !<q. n  y | j d  \ }	 }
 Wn t k
 r q. n Xt |
  | |	 <q. W| S(   s0   Read FEI SFEG/HELIOS headers and return as dict.t   [i   iRi   (   Re  R  t
   splitlinesRa  RX  R  R   R  (   R   R*   R/   R   R   RL   t   sectionR8   Rp  R   RZ   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  }  s    c         C  s  i d d 6} d } t |  j |   } x| j   D]t} | j   rV | j   } q5 | ry | j d  \ }	 }
 Wn t k
 r q5 n X|
 j   }
 d } yF |
 j   \ } } t	 | t
 t f  } | | k r | }
 | } n  Wne t k
 rKt	 |
 t
 t f  } | |
 k r| }
 n  |
 d	 k r3t }
 qL|
 d
 k rLt }
 qLn X|	 j   |
 f | | <| r~| | c | f 7<n  d } q5 | d c t	 | t
 t f  f 7<q5 W| S(   s&   Read Zeiss SEM tag and return as dict.R   Ri   t   Not   Offt   Yest   On(    N(   Ry	  Rz	  (   R{	  R|	  (   R-   Re  R  Rw	  t   isupperRb  R  R   Ra  R  R   R  R2   R4   R5   (   R   R*   R/   R   R   RL   R   R8   Rp  R|  RZ   RJ  R  R   t   number(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    sB    			&c         C  sc   |  j  t j d | } | j |  } t |  } | d | d  | d <| d | d  | d <| S(   s7   Read NIH_IMAGE_HEADER tag from file and return as dict.R*   R  R  R  R  (   R  RA   R"  R   RM	  (   R   R*   R/   R   R   Rc   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c         C  s  |  j  d  y t j d |  j d   \ } } | d k sI | d k rR t  n  |  j  d  t j d |  j d   \ } } } } | d k s | d	 k r t  n  Wn t k
 r t d
   n Xt t |  j |  d    } | d k rt |  d d | d  n i  } | | f S(   s;  Read ScanImage BigTIFF v3 static and ROI metadata from open file.

    Return non-varying frame data as dict and ROI group data as JSON.

    The settings can be used to read image data and metadata without parsing
    the TIFF file.

    Raise ValueError if file does not contain valid ScanImage v3 metadata.

    i    s   <2sHi   Rt   i+   i   s   <IIIIii   s   not a ScanImage BigTIFF v3 fileii   Rl   N(
   R   R   R  R  R2   R   t   matlabstr2pyRe  R  R-   (   R   R*   R  t   magict   size0t   size1t
   frame_datat   roi_data(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    !	'*c         C  s  |  j  d  y% i d d 6d d 6|  j d  } Wn t k
 rQ t d   n Xi  } |  j  d  t j | d	 |  j d
   \ } } } } } } }	 }
 |	 d k r t d   n  t |  | d |
 d  | d <| d k r t d   n  |  j  |  t j | d |  j d   \ } } | d k r;t d   n  t j | d | |  j d |   } i | d d d  d 6| d d d  d 6| d d d  d 6| d d d  d 6| d d d  d 6| d <| d k rt d   n  |  j  |  t j | d |  j d   \ } } | d  k r8t d   n  t |  | d | d  | d! <| d" k rot d#   n  |  j  |  t j | d |  j d   \ } } | d$ k rt d#   n  t |  | d | d  | d% <| S(&   s   Read MicroManager non-TIFF settings from open file and return as dict.

    The settings can be used to read image data without parsing the TIFF file.

    Raise ValueError if the file does not contain valid MicroManager metadata.

    i    Rl   Rt   Rm   Ru   i   s   not a MicroManager TIFF filei   t   IIIIIIIIi    i$# s#   invalid MicroManager summary headert   SummaryiCs!   invalid MicroManager index headeri4 t   IIIIIi   Ni   R  i   t   Slicet   Framei   t   Positioni   R  t   IndexMapis#   invalid MicroManager display headeridt   DisplaySettingsi}s$   invalid MicroManager comments headeriet   Comments(   R   R  R  R   R   R  R  R-   (   R   R*   RL   t   index_headert   index_offsett   display_headert   display_offsett   comments_headert   comments_offsett   summary_headert   summary_lengthRt	  R   R8   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    sL    %7%'%%c         C  s   t     d S(   s   Read MetaSeries non-TIFF hint catalog from file.

    Raise ValueError if the file does not contain a valid hint catalog.

    N(   R  (   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   read_metaseries_catalog  s    c      
   C  sX  i d d 6d d 6| g } d g } g  } d   } d   } d   } d	   } d
 d d | f d d d | f d d d | f d d d | f d d d | f d d d | f d d d | f f }	 x |	 D] \ }
 } } } |
 j   |  k r |
 j   }
 n |
 |  k r	q n  | d k r+| d d d  } n  |  |
 } | d k rPt |  } n	 | g } | j | t j | d |   x= | D]5 } | | |  } | j |  | j t |   qWq W| sd! Sd j |  } d j |  } | | } t |  | d <t j | d t |  |  } d d t |  | t f d d t |  d  | t f f S("   s  Return IJMetadata and IJMetadataByteCounts tags from metadata dict.

    The tags can be passed to the TiffWriter.save function as extratags.

    The metadata dict may contain the following keys and values:

        Info : str
            Human-readable information as string.
        Labels : sequence of str
            Human-readable labels for each channel.
        Ranges : sequence of doubles
            Lower and upper values for each channel.
        LUTs : sequence of (3, 256) uint8 ndarrays
            Color palettes for each channel.
        Plot : bytes
            Undocumented ImageJ internal format.
        ROI: bytes
            Undocumented ImageJ internal region of interest format.
        Overlays : bytes
            Undocumented ImageJ internal format.

    t   IJIJRm   t   JIJIRl   i    c         S  s#   |  j  d i d d 6d d 6|  S(   Ns   utf-16t   beRm   t   leRl   (   Rq  (   R8   R*   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   _string9  s    c         S  s   t  j | d t |   |   S(   NRY  (   R   R   R!   (   R8   R*   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   _doubles<  s    c         S  s
   |  j    S(   N(   t   tobytes(   R8   R*   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   _ndarray?  s    c         S  s   |  S(   N(    (   R8   R*   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   _bytesB  s    t   InfoR`  i   t   Labelst   lablt   Rangest   rangt   LUTst   lutst   Plott   plott   ROIs   roi t   Overlayst   overNiRq   R   i  R   i  i   (    (   R-   Rb  R!   R(   R   R   R   R5   (   R1  R*   Rt	  RP  t   bodyR	  R	  R	  R	  t   metadata_typesR   t   mtypeR   RN   R  RZ   R8   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    sN    					
	!
 c         C  s>  d   } d   } d   } d   } i d | f d 6d | f d 6d	 | f d
 6d | f d 6d | f d 6d | f d 6d | f d 6} | j  t d   | j   D   | s t d   n  |  d  d" k r t d   n  | d } | d k  s | d k rt d   n  | d d }	 t j | d |	 |  d d |	 d ! }
 d |	 d } d } i  } x t |
 d d d   |
 d! d d    D] \ } } g  } | j | t |  t	 f  \ } } xO t
 |  D]A } | d! 7} | | | } | j | |  | | !|   | } qW| d! k r&| d n | | | j   <qW| S(#   s   Return IJMetadata tag value as dict.

    The 'Info' string can have multiple formats, e.g. OIF or ScanImage,
    that might be parsed into dicts using the matlabstr2py or
    oiffile.SettingsFile functions.

    c         S  s#   |  j  d i d d 6d d 6|  S(   Ns   utf-16R	  Rm   R	  Rl   (   R  (   R8   R*   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR	  s  s    c         S  s"   t  j | d t |   d |   S(   NRY  i   (   R   R  R!   (   R8   R*   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR	  v  s    c         S  s   t  j |  d  j d d  S(   NR  ii   (   R.   R  R  (   R8   R*   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   _luty  s    c         S  s   |  S(   N(    (   R8   R*   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR	  |  s    R	  R`  R	  R	  R	  R	  R	  R	  t   PlotsR	  R	  s   roi R	  R	  c         s  s.   |  ]$ \ } } | d  d  d  | f Vq d  S(   Ni(    (   R   R  R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>  s    s   no ImageJ metadatai   R	  R	  s   invalid ImageJ metadatai    i   i$  s#   invalid ImageJ metadata header sizei   t   4sINi   i   (   R	  R	  (   R@   Ru  R  R   R   R  R|  R3   Re  Rb  R   R(   Ra  (   R8   RP  R*   R	  R	  R	  R	  R	  t   header_sizet   ntypesRt	  R   t   counterRL   R	  R   R  R|  RN   RM   t   pos1(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  k  sH    				
)6$

*c         C  s   d   } i  } x |  j    D] } y | j d  \ } } Wn t k
 rQ q n X| j   } | j   } x< t t | f D]+ } y | |  } PWqz t k
 r qz Xqz W| | | <q Wd | k r t d   n  | S(   s8  Return metatata from ImageJ image description as dict.

    Raise ValueError if not a valid ImageJ description.

    >>> description = 'ImageJ=1.11a\nimages=510\nhyperstack=true\n'
    >>> imagej_description_metadata(description)  # doctest: +SKIP
    {'ImageJ': '1.11a', 'images': 510, 'hyperstack': True}

    c         S  s   i t  d 6t d 6|  j   S(   Nt   truet   false(   R5   R4   Rb  (   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   _bool  s    Ri   R  s   not a ImageJ image description(   Rw	  R  R2   Ra  R   R  R   (   R-  R	  RL   Rp  R   R   R/   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s&    
	s   1.11ac         K  s  | r t  d   n  t |  d | }  |  d d k } d | g } g  }	 | j d t |  d    | d k r t } |	 j d	  n |	 j d
 t |   |  d d k r | j d |  d  n  | d k r | r d } n  | r| r|	 j d |  n  |  d d k r*| j d |  d  n  |  d d k rn| j d |  d  | d k rn|	 j d  qnn  | d k	 r|	 j d t |   n  x7 | j   D]) \ }
 } |	 j d |
 j   | f  qWd j	 | |	 d g  S(   s5  Return ImageJ image description from data shape.

    ImageJ can handle up to 6 dimensions in order TZCYXS.

    >>> imagej_description((51, 5, 2, 196, 171))  # doctest: +SKIP
    ImageJ=1.11a
    images=510
    channels=2
    slices=5
    frames=51
    hyperstack=true
    mode=grayscale
    loop=false

    s!   ImageJ colormapping not supportedt   rgbii   i   s	   ImageJ=%ss	   images=%iis   hyperstack=trues   hyperstack=%si   i   s   channels=%it	   grayscales   mode=%ss	   slices=%ii    s	   frames=%is
   loop=falses   loop=%ss   %s=%ss   
R   (   i   i   N(
   R  R  R(   R   R-   R5   R   R  Rb  R   (   R9   R	  t
   colormapedR  R  RK   t   loopR#   RL   R(   R   RZ   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s8    	!c         C  s	  t  d   |  D  }  t |   } d | k o9 d k n rM t d   n  | d k rx |  d d k or | d k } n  | r |  d d k r t d	   n  | r | d k r |  d d k r t d
   n  | s |  d d k r d d | |  Sd d | |  d S(   s   Return shape normalized to 6D ImageJ hyperstack TZCYXS.

    Raise ValueError if not a valid ImageJ hyperstack shape.

    >>> imagej_shape((2, 3, 4, 5, 3), False)
    (2, 3, 4, 5, 3, 1)

    c         s  s   |  ] } t  |  Vq d  S(   N(   R   (   R   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>  s    i   i   s1   invalid ImageJ hyperstack: not 2 to 6 dimensionalii   i   i   s*   invalid ImageJ hyperstack: not a RGB images.   invalid ImageJ hyperstack: not a non-RGB imagei   N(   i   i   (   i   i   (   i   (   i   (   i   (   R   R!   R   R-   (   R9   R	  RB  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    	#c         K  s   | j  d |   t j |  S(   s   Return JSON image description from data shape and other meta data.

    Return UTF-8 encoded JSON.

    >>> json_description((256, 256, 3), axes='YXS')  # doctest: +SKIP
    b'{"shape": [256, 256, 3], "axes": "YXS"}'

    R9   (   R@   RJ	  t   dumps(   R9   R1  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    	c         C  s   |  d  d k rC t  d   |  d d !j d  D  } t d |  S|  d  d	 k rp |  d d
 k rp t j |   St d |    d S(   s  Return metatata from JSON formated image description as dict.

    Raise ValuError if description is of unknown format.

    >>> description = '{"shape": [256, 256, 3], "axes": "YXS"}'
    >>> json_description_metadata(description)  # doctest: +SKIP
    {'shape': [256, 256, 3], 'axes': 'YXS'}
    >>> json_description_metadata('shape=(256, 256, 3)')
    {'shape': (256, 256, 3)}

    i   s   shape=c         s  s   |  ] } t  |  Vq d  S(   N(   R   (   R   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>,  s    i   it   ,R9   i   RS  t   }s   invalid JSON image descriptionN(   R   R  Ru  RJ	  RK	  R   (   R-  R9   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    & c         C  sF  |  j  d  s t d   n  | d k r9 d d h } n  i  } | g } t } x|  j   D]} | sv | j   } n  | s q[ n  | d d k r| d d k r%| d =| d } | d	 d !} | r d
 j | |  | | <n  | d  d k r[ t j | | d d } d | _	 | | | <q[ q[ n  t } | d	 d !} | d  d k rQg  } n! | | k rlg  } t
 } n i  } | j |  | | | <q[ n  | r| j |  q[ n  | j d d	  } t |  d	 k rd | | d j   <q[ n  | \ }	 }
 |	 d  d k r"| j d   |
 j   D  q[ t |
 j    | |	 j   <q[ W| S(   sl  Return metatata from FluoView image description as dict.

    The FluoView image description format is unspecified. Expect failures.

    >>> descr = ('[Intensity Mapping]\nMap Ch0: Range=00000 to 02047\n'
    ...          '[Intensity Mapping End]')
    >>> fluoview_description_metadata(descr)
    {'Intensity Mapping': {'Map Ch0: Range': '00000 to 02047'}}

    Rv	  s"   invalid FluoView image descriptions   Region Info (Fields)s   Protocol Descriptioni    is    End]ii   s   
i   s   LUT R/   R  i   Ri   s   RGB c         s  s   |  ] } t  |  Vq d  S(   N(   R   (   R   R	  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>p  s    N(   ii   (   RX  R   R-   R4   Rw	  Ra  R   R.   R  R9   R5   R(   R  R!   R  R  (   R-  t   ignoresectionsRL   t   sectionst   commentRp  Rx	  R|  Rc   R   RZ   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   fluoview_description_metadata4  s^    	
			
  c           s  i  } |  j  d  s | Sx  d D] } |  j | d  }  q  Wx|  j d  D]} | d  d k rh qL n  | j   } | d } | d t j k r y& t j j d j |  d  | d	 <WqL t k
 r d j | d
  | | <qL XqL n  t j | d \ }   t	 | d t
  r#| | d } n g  | D] } | | ^ q*}   t k rh| d d k rhd g } n  t   f d   | D  }   t k rd j |  } n t |  d
 k r| d } n  | | | <qL W| S(   s  Return metatata from Pilatus image description as dict.

    Return metadata from Pilatus pixel array detectors by Dectris, created
    by camserver or TVX software.

    >>> pilatus_description_metadata('# Pixel_size 172e-6 m x 172e-6 m')
    {'Pixel_size': (0.000172, 0.000172)}

    s   # s   #:=,()Ri  s   
i   s     i    s   %Y-%m-%dT%H %M %S.%fR   i   t   nott   NaNc         3  s   |  ] }   |  Vq d  S(   N(    (   R   R  (   R/   (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>  s    (   RX  R  R  RA   R=	  R.  t   strptimeR   R2   R   R  R  R   R{   R!   (   R-  RL   R   Rp  R|  RI  R  R   (    (   R/   s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  v  s<    

	c         C  s   |  j  d  s t d   n  i  } |  j d  } | d j   j d	 d  \ } } | j   | | j   <t |  d k r | S| d j d  } | d j   | d <xC | d D]7 } | j d  \ } } t | j    | | j   <q W| S(
   s   Return metatata from Aperio image description as dict.

    The Aperio image description format is unspecified. Expect failures.

    >>> svs_description_metadata('Aperio Image Library v1.0')
    {'Aperio Image Library': 'v1.0'}

    s   Aperio Image Library s    invalid Aperio image descriptions   
i    i   Rj   R   s    = N(   RX  R   R  Ra  t   rsplitR-   R!   R  (   R-  RL   t   linesR   RZ   R  R\  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   svs_description_metadata  s    	" c         C  s.  |  j    }  |  s g  Sy t |   }  Wn t k
 rG t j d  g  SXg  } x |  j d  D] } i  } x | j d  D] } | j d d  } t |  d k r | \ } } t | j     | | j    <qz | d j    } | rz d | k r| d j |  q| g | d <qz qz W| j |  q^ W| S(   s   Return metadata from MetaMorph image description as list of dict.

    The MetaMorph image description format is unspecified. Expect failures.

    s+   failed to parse MetaMorph image descriptions    s   
R!  i   i    R   (	   Ra  Re  Rg  R   R   R  R!   R  R(   (   R-  RL   RZ  RY  Rp  R|  RZ   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   stk_description_metadata  s.    c           s   |  j  d  s t d   n  d d l m } | j |   } i t d 6t d 6d   d 6    f d	       | i   } d
 | k r | d
 j d d  | d
 <n  | S(   s:   Return metatata from MetaSeries image description as dict.s
   <MetaData>s$   invalid MetaSeries image descriptioni(   R  R  R   c         S  s   t  |  d d  S(   Nt   onRT	  (   t   asbool(   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR     R   R   c           s   x |  D] } | j  } | s8   | i   | | j <q n  d | k r | d } | d } | d } |  k r  | |  | | <q | | | <q q W| S(   Nt   idt   typeRZ   (   R  RT  (   R  RL   t   childR  R   R   R  (   t   parset   types(    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR	    s    	


R  s
   &#13;&#10;s   
(   RX  R   R
  R  R  R  R   R  (   R-  R  R  t   adict(    (   R	  R	  s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c         C  s
   t  |   S(   s9   Return metatata from ScanImage image description as dict.(   R	  (   R-  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR    s    c         C  s:   y t  j |   SWn" t k
 r5 t j d |   n Xd S(   s2   Return metatata from ScanImage artist tag as dict.s   invalid JSON '%s'N(   RJ	  RK	  R   R   R   (   t   artist(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   scanimage_artist_metadata   s    RM   c           sj   d   Sd     y d d l  m  Wn! t k
 rG }   | |  t SX|  |      f d  } | S(   s2   Try replace decorated function by module.function.c         S  s   |  S(   N(    (   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR      R   c         S  sO   | d  k r d } n | t k r* d } n
 | s4 d  St j d |  | f  d  S(   Ns/   
  Functionality might be degraded or be slow.
R   s   %s%s(   R-   R5   R   R   (   R[   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   _warn   s    		i(   t   import_modulec           s   | j  d  \ } } y/  r7  d | d  } n  |  } Wn! t k
 rg }   | |  |  SXy t | |  |  }  } Wn! t k
 r }   | |  |  SX| t    |  j <|  S(   Nt   .t   package(   R  R2   RT   t   globalsRV   (   RN   t   module_functionR   t   modulet   functionR[   t   oldfunc(   R	  R	  R	  t   prefix(    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   decorate   s    (   t	   importlibR	  RN  R  (   R	  R	  R   R	  R[   R	  (    (   R	  R	  R	  R	  s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   _replace_by
   s    		c         C  s[  |  j  } |  j } t |  d k  r3 t d   n  | j d k rQ t d   n  |  j j d k p t j d k o |  j j d k } |  j d  }  | d	  d | d
 |  _  t j	 |  d d	 d d d |  | r | d	  d | d	 |  _  n  t j
 |  d d	  }  t j
 |  d	 d
  }  |  d d d d
  f }  t j |   }  |  j |  }  | |  _  |  S(   s  Decode floating point horizontal differencing.

    The TIFF predictor type 3 reorders the bytes of the image values and
    applies horizontal byte differencing to improve compression of floating
    point images. The ordering of interleaved color channels is preserved.

    Parameters
    ----------
    data : numpy.ndarray
        The image to be decoded. The dtype must be a floating point.
        The shape must include the number of contiguous samples per pixel
        even if 1.

    i   s   invalid data shapet   dfes   not a floating point imageRl   Rk   Ri   R  iiR   R/   R  i.N(   i(   i(   R9   R/   R!   R   RH   R*   R~   t   viewR.   R  t   swapaxest   ascontiguousarray(   R8   R9   R/   t   littleendian(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  1   s(    		!	s   _tifffile.decode_packbitsc         C  s  t  j d d k r t n t } g  } | j } d } y x t r | |  |  d } | d 7} | d k  r | |  | | | ! | | 7} q: | d k r: | |  | | d !d |  | d 7} q: q: WWn t k
 r n Xt  j d d k r d j |  St |  S(   su   Decompress PackBits encoded byte string.

    PackBits is a simple byte-oriented run-length compression scheme.

    i    R   i   i   i  R   (	   R~   R  t   ordR  R  R5   R  R   R   (   t   encodedRN   RL   t   result_extendR   t   n(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRT  Y   s"    		
s   _tifffile.decode_lzwc           s  t    } | d } t j  t j d d k rZ g  t d  D] } t |  ^ q? } n( g  t d  D] } t | g  ^ qg } | j d        f d   } i d d t	 d d	 d d
  f d 6d d t	 d d	 d d
  f d 6d d t	 d  d	 d d
  f d 6d d t	 d! d" d
  f d 6} | d \ }   d   | d k  rdt
 d   n  |   d k rt
 d   n  d } d }	 g  }
 |
 j } x1t r|   }   | 7  | d k s  | k rPn  | d k r>| } | j } d } | d \ }   |   }   | 7  | d k r-Pn  | | |  ng | | k  ri| | } | |	 | d  } n | |	 } | | d  7} | } | |  | |  | d 7} | }	 | | k r| | \ }   qqW| d k rt j d |  n  d j |
  S(#   s+  Decompress LZW (Lempel-Ziv-Welch) encoded TIFF strip (byte string).

    The strip must begin with a CLEAR code and end with an EOI code.

    This implementation of the LZW decoding algorithm is described in (1) and
    is not compatible with old style LZW compressed files like quad-lzw.tif.

    i   i    R   i   c            s     d }   |  |  d !} y  d |  d } Wn6 t  k
 rj  d | d d t |   d } n X|   d K} |  M} |  ?S(   s@   Return integer of 'bitw' bits at 'bitcount' position in encoded.i   i   s   >Ii    s    (   R2   R!   (   R$  R   R   (   t   bitcountR	  t   maskt   shrR  (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt	   next_code   s    
)
i	   i   t   1t   0i   i   i
   i   i  i   i   i  i   i   i  i   s(   strip must be at least 4 characters longs    strip must begin with CLEAR codei  i  i   s&   unexpected end of LZW stream (code %i)R   (   i    i    t	   111111111t
   1111111111t   11111111111t   111111111111t   00000000000000000000(   R!   R   R  R~   R  R   t   chrR   R  R   R   R(   R5   R   R   R   (   R	  t   len_encodedt   bitcount_maxR   t   newtableR	  t   switchbitcht   bitwR   t   oldcodeRL   t   result_appendR  t   table_appendt   lentablet   decodedt   newcode(    (   R	  R	  R	  R	  R  s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR   s   sj    

	((!!! 			
		





s   _tifffile.unpack_intsc           s    d k r t  j |  d  }  t  j |   }  | d r} |  j d | d | d  }  |  d d  d |  f j d  }  n  |  j |  St  j |  }   d k r t  j |  |  S  d k r t d     n  | j d k r t d   n  t   f d   d D  } | | j	 k r,t d   n  | d k rOd t
 |     } n  |   d } | rpd | } n  | d   } t   d d | d	  } d | j } t j }	 | t
 |   d |   | }
 t  j |
 f |  } d } x t |
  D] } | d } |  | | | !} y |	 | |  d } Wn6 t k
 rg|	 | | d | t
 |   d } n X| | d K} | | M} | | ?| | <|   7} | d | d k r| | 7} qqW| S(   s  Decompress byte string to array of integers of any bit size <= 32.

    This Python implementation is slow and only handles itemsizes 1, 2, 4, 8,
    16, 32, and 64.

    Parameters
    ----------
    data : byte str
        Data to decompress.
    dtype : numpy.dtype or str
        A numpy boolean or integer type.
    itemsize : int
        Number of bits per integer.
    runlen : int
        Number of consecutive integers, after which to start at next byte.

    Examples
    --------
    >>> unpack_ints(b'a', 'B', 1)
    array([0, 1, 1, 0, 0, 0, 0, 1], dtype=uint8)
    >>> unpack_ints(b'ab', 'B', 2)
    array([1, 2, 0, 1, 1, 2, 0, 2], dtype=uint8)

    i   s   |Bi   iNi   i    i@   i   i   s   itemsize not supported: %it   bius   invalid dtypec         3  s%   |  ] } d  |   k r | Vq d S(   i   N(    (   R   R   (   R0   (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>   s    s   dtype.itemsize too smalli    R	  R	  Rm   s    (   i   i   i    i@   (   i   i   i   i   i   i    (   i   i   i   i   (   R.   R  t
   unpackbitsR  R  R/   R   R  t   nextR0   R!   R   RH   R   R  R  R   R2   (   R8   R/   R0   R  t	   itembytest   skipbitst   shrbitst   bitmaskt   dtypestrR  R<   RL   R	  R   R$  R   R   (    (   R0   s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR     sV    
(	 
)

s   <Bi   i   c   
        s  t  j    t t  j |       d k oI t  f d   | D  se t d t |    n  t   f d   d D  } t  j |   j	 |  }  t  j
 |  j t |  f  j  } x t |  D] \ } } |  t t  j | | d   ?} | t d d | d	  M} | r j d
 | d | }	 |	 |  j j d
 k rZ| j d  } n  | d	 |	 d d	 | d 9} | d	 |	  j d
 } n  | | d d  | f <q W| j d  S(   s  Return array from byte string containing packed samples.

    Use to unpack RGB565 or RGB555 to RGB888 format.

    Parameters
    ----------
    data : byte str
        The data to be decoded. Samples in each pixel are stored consecutively.
        Pixels are aligned to 8, 16, or 32 bit boundaries.
    dtype : numpy.dtype
        The sample data type. The byteorder applies also to the data stream.
    bitspersample : tuple
        Number of bits for each sample in a pixel.
    rescale : bool
        Upscale samples to the number of bits in dtype.

    Returns
    -------
    result : ndarray
        Flattened array of unpacked samples of native dtype.

    Examples
    --------
    >>> data = struct.pack('BBBB', 0x21, 0x08, 0xff, 0xff)
    >>> print(unpack_rgb(data, '<B', (5, 6, 5), False))
    [ 1  1  1 31 63 31]
    >>> print(unpack_rgb(data, '<B', (5, 6, 5)))
    [  8   4   8 255 255 255]
    >>> print(unpack_rgb(data, '<B', (5, 5, 5)))
    [ 16   8   8 255 255 255]

    i    c         3  s"   |  ] } |   j  d  k Vq d S(   i   N(   R0   (   R   R   (   R/   (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>6!  s    s   sample size not supported: %sc         3  s1   |  ]' } t  j |  j d    k r | Vq d S(   i   N(   R.   R/   R0   (   R   R   (   t   bits(    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>8!  s    t   BHIi   t   0bR	  i   i   Rq   Ni(   R.   R/   R   R%  R  R   R{   R
  R  R*   R  R<   R!   RH   R!  R0   R  R  (
   R8   R/   R  t   rescaleR  RL   R   RZ  R   t   o(    (   R

  R/   s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  !  s$    !($!s   _tifffile.reverse_bitorderc         C  sm   y, |  j  d  } t j t j | d | Wn: t k
 rL |  j t j  St k
 rh t	 d   n Xd S(   sj  Reverse bits in each byte of byte string or numpy array.

    Decode data where pixels with lower column values are stored in the
    lower-order bits of the bytes (FillOrder is LSB2MSB).

    Parameters
    ----------
    data : byte string or ndarray
        The data to be bit reversed. If byte string, a new bit-reversed byte
        string is returned. Numpy arrays are bit-reversed in-place.

    Examples
    --------
    >>> reverse_bitorder(b'\x01\x64')
    b'\x80&'
    >>> data = numpy.array([1, 666], dtype='uint16')
    >>> reverse_bitorder(data)
    >>> data
    array([  128, 16473], dtype=uint16)

    R  R  s   slices of arrays not supportedN(
   R	  R.   t   takeRA   R?	  RQ   t	   translateR>	  R   R  (   R8   R	  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  H!  s    c         C  sL   t  j | |  d d }  t  j |  d |  j  }  | rH t  j |   }  n  |  S(   s  Return palette-colored image.

    The image values are used to index the colormap on axis 1. The returned
    image is of shape image.shape+colormap.shape[0] and dtype colormap.dtype.

    Parameters
    ----------
    image : numpy.ndarray
        Indexes into the colormap.
    colormap : numpy.ndarray
        RGB lookup table aka palette of shape (3, 2**bits_per_sample).
    contig : bool
        If True, return a contiguous array.

    Examples
    --------
    >>> image = numpy.arange(256, dtype='uint8')
    >>> colormap = numpy.vstack([image, image, image]).astype('uint16') * 256
    >>> apply_colormap(image, colormap)[-1]
    array([65280, 65280, 65280], dtype=uint16)

    R   i   i    (   R.   R
  t   rollaxisRB  R	  (   t   imageR,  t   contig(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  h!  s
    c         C  s  t  j } t | |  } | | j k r+ |  S| | j k rZ |  d d d d  d d  f S| | j k r |  d d d d  d d  d d  f S| | j k r |  d d d d  d d d  d d  f S| | j k r t j	 |  d d  S| | j
 k r-t j	 |  d d  d d d d  d d  f S| | j k rtt j	 |  d d  d d d d  d d  d d  f S| | j k rt j	 |  d d  d d d d  d d d  d d  f Sd S(   s+  Return reoriented view of image array.

    Parameters
    ----------
    image : numpy.ndarray
        Non-squeezed output of asarray() functions.
        Axes -3 and -2 must be image length and width respectively.
    orientation : int or str
        One of TIFF.ORIENTATION names or values.

    .Niii(   RA   R  R  R  R  R  R  R  R.   R	  R  R  R  (   R
  t   orientationR  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   reorient!  s$    	 ),/8c         C  s   t  j |   }  g  } g  } g  } x` t |  j |  j |  D]F \ } } } | j | | f  | j | d f  | j | |  q: Wt  j j j	 |  | | d t
 j |  S(   s   Return read-only view into input array with elements repeated.

    Zoom nD image by integer factors using nearest neighbor interpolation
    (box filter).

    Parameters
    ----------
    a : array_like
        Input array.
    repeats : sequence of int
        The number of repetitions to apply along each dimension of input array.

    Example
    -------
    >>> repeat_nd([[1, 2], [3, 4]], (2, 2))
    array([[1, 1, 2, 2],
           [1, 1, 2, 2],
           [3, 3, 4, 4],
           [3, 3, 4, 4]])

    i    t	   writeable(   R.   R"   R|  t   stridesR9   R  R(   t   libt   stride_trickst
   as_stridedR4   R  (   Rc   t   repeatsR  R9   R
  R   R  R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR   !  s    (c         C  si   t  |  t  } | r |  n |  j } t |  | k r: |  Sd | t |  | } | r\ | S|  j |  S(   s  Return image array or shape with at least ndim dimensions.

    Prepend 1s to image shape as necessary.

    >>> reshape_nd(numpy.empty(0), 1).shape
    (0,)
    >>> reshape_nd(numpy.empty(1), 2).shape
    (1, 1)
    >>> reshape_nd(numpy.empty((2, 3)), 3).shape
    (1, 2, 3)
    >>> reshape_nd(numpy.empty((3, 4, 5)), 3).shape
    (3, 4, 5)
    >>> reshape_nd((2, 3), 3)
    (1, 2, 3)

    i   (   i   (   R   R   R9   R!   R  (   t   data_or_shapeRB  t   is_shapeR9   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  !  s    R1  c           sk   t  |   t  |  k r' t d   n  t   f d   t |  |  D   \ }  } t |   d j |  f S(   s   Return shape and axes with single-dimensional entries removed.

    Remove unused dimensions unless their axes are listed in 'skip'.

    >>> squeeze_axes((5, 1, 2, 1, 1), 'TZYXC')
    ((5, 2, 1), 'TYX')

    s)   dimensions of axes and shape do not matchc         3  s5   |  ]+ } | d  d k s) | d   k r | Vq d S(   i    i   N(    (   R   R   (   RX  (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>!  s    R   (   R!   R   R|  R   R   (   R9   R  RX  (    (   RX  s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  !  s    	+t   CTZYXc         C  s   x- | D]% } | | k r t  d |   q q W|  j } x7 t |  D]) } | | k rF | | } d | } qF qF W|  j |  }  |  j g  | D] } | j |  ^ q  }  |  S(   s   Return image with its axes permuted to match specified axes.

    A view is returned if possible.

    >>> transpose_axes(numpy.zeros((2, 3, 4, 5)), 'TYXC', asaxes='CTZYX').shape
    (5, 2, 1, 3, 4)

    s   unknown axis %si   (   i   (   R   R9   R  R  t	   transposeR8  (   R
  R  t   asaxesR  R9   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   transpose_axes!  s    		
+Rn   c         C  s  t  |  } t  |  } t |   t |  k r? t d   n  t |  } t |  } | | k r| t d | | f   n  |  s | r d St d t |  t |   } | r | d | } n  t |  d } d } d }	 g  }
 x | d d d  D] } | | 9} x6 | d k rB| | d k rB| d k rB| d 8} qW| | | k r| |	 | | k r|	 | | 9}	 |
 j |  |  | d 8} q |
 j |  q Wd j t |
 |   S(	   s   Return axes matching new shape.

    Unknown dimensions are labelled 'Q'.

    >>> reshape_axes('YXS', (219, 301, 1), (219, 301))
    'YX'
    >>> reshape_axes('IYX', (12, 219, 301), (3, 4, 219, 1, 301, 1))
    'QQYQXQ'

    s   axes do not match shapes   cannot reshape %s to %sR   i    i   Ni(   i   (   R   R!   R   R   R^  R(   R   R  (   R  R9   t   newshapet   unknownR<   t   newsizet   lendiffR   t   prodnst   prodsRL   t   ns(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  
"  s6    
+$i   c      	   O  s  t  |   } | d k r' t d   n  | d k rM |  d j d | | |  St d   |  D  } | j d d  | f | j j } | j j } t | | |  } | d k r t	 j
   d } n  | d k | j j _ t d t d	 |  d
 | j j j  }	 | |	 | | d  }
 | d k  rMx^ t |   D] \ } } |
 | |  q-Wn4 t j j |    } | j |
 |  t |   Wd QX|	 j   d | j j _ | S(   s   Read data from sequence of TiffPage and stack them vertically.

    Additional parameters are passsed to the TiffPage.asarray function.

    i    s   no pagesi   R  c         s  s!   |  ] } | d  k	 r | Vq d  S(   N(   R-   (   R   RM  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>D"  s    R  i   R<   i   R  c      	   S  sd   |  d k	 r` | j |  j j  |  j d | j d t d t | |  | | <| j |  j j  n  d S(   s!   Read, decode, and copy page data.R  R  R  N(   R-   R  R  R  R"   R  R4   Ru  (   RJ   R8  R  t	   filecacheR  R#   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRN   Q"  s
    N(   R!   R   R"   R
  R-   R  R9   R/   R   t   multiprocessingt	   cpu_countR  R  R  R  R^  R!  t
   concurrentt   futurest   ThreadPoolExecutort   mapR   R  (   RC   R  R  R  R#   R  R  R9   R/   R)
  RN   R   RJ   t   executor(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  7"  s2    
c         C  s  t  |   }  t  |  } t |   t |  k s6 t  d } x t t |  |   D] \ } \ } } | d k r | d k r | | k r | |  | <| | | <n  | d 7} qR | d k r | d k r t d   qR t j d  qR W| d k r d } n  |  |  | |  f S(   s   Return cleaned offsets and byte counts.

    Remove zero offsets and counts. Use to sanitize _offsets and _bytecounts
    tag values for strips or tiles.

    i    i   s   invalid offsets   empty byte count(   R   R!   R   R!  R|  R   R   R   (   RN  t   countsR  R   R
  RD  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  g"  s     (
	i   c         c  s   t  |  } d } x | | k  r g  } | o d } xa | | k  r | | k  r |  j | |  | | }	 | j |  j |	   | |	 7} | d 7} q7 WWd QXx | D] }
 |
 Vq Wq Wd S(   s+   Return iterator over blocks read from file.i    i   N(   R!   R   R(   R  (   R   R  RN  RP  t
   buffersizet   lengthR   R8   R<   t	   bytecountRl	  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  "  s    

s   w+s   .memmapc         C  sM  |  d	 k r t j | |  St |  t  r |  d  d k r t |   d k rW |  d n d	 } t j d | d |  & } t j | d | d | d | SWd	 QXn  t |  t j	  rt
 |  t
 |  j  k r t d
   n  t j | |  j  s t d   n  |  j |  St |  t j  r.t |   }  n  t j |  d | d | d | S(   s  Return numpy array where image data of shape and dtype can be copied.

    The 'out' parameter may have the following values or types:

    None
        An empty array of shape and dtype is created and returned.
    numpy.ndarray
        An existing writable array of compatible dtype and shape. A view of
        the same array is returned after verification.
    'memmap' or 'memmap:tempdir'
        A memory-map to an array stored in a temporary binary file on disk
        is created and returned.
    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. The created memory-mapped array is
        returned.

    i   R   i   R^  t   suffixR9   R/   RK   Ns   incompatible output shapes   incompatible output dtype(   R-   R.   R  R   R{   R!   t   tempfilet   NamedTemporaryFileR   R   R   R9   R   t   can_castR/   R  Rt  Ru  (   R  R9   R/   RK   R5
  t   tempdirR   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR   "  s    "(c           s    f d    d    t  d     f d   } d |  k sN d |  k r i  } x |  j   D] } | j   } | sa | d d k r qa n  | j d	 d
  \   }   j     t   f d   d D  r qa n  | |  |   <qa W| S| |   S(   sE  Return Python object from Matlab string representation.

    Return str, bool, int, float, list (Matlab arrays or cells), or
    dict (Matlab structures) types.

    Use to access ScanImage metadata.

    >>> matlabstr2py('1')
    1
    >>> matlabstr2py("['x y z' true false; 1 2.0 -3e4; NaN Inf @class]")
    [['x y z', True, False], [1, 2.0, -30000.0], [nan, inf, '@class']]
    >>> d = matlabstr2py("SI.hChannels.channelType = {'stripe' 'stripe'}\n"
    ...                  "SI.hChannels.channelsActive = 2")
    >>> d['SI.hChannels.channelType']
    ['stripe', 'stripe']

    c           s   d g } x t  r   |   \ } } | d  k r4 Pn  | d k rP | j d  nE | d k rl | j d  n) | d k r | j d  n | j |  |  | }  q W| j d  | S(   NRv	  t   ;t   ](   R;
  Rv	  (   Rv	  Rv	  (   R;
  R;
  (   R5   R-   R  R(   (   R   t   tokensR   R   (   t
   next_token(    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   lex"  s    		c         S  s  t  |   } | d k r d	 Sd } x* | | k  rN |  | d k rN | d 7} q% W| | k re d  | f S|  | d k r |  | | d f S|  | d k r | d } x* | | k  r |  | d k r | d 7} q W|  | | d !| d f S|  | d k rG| d } x* | | k  r-|  | d k r-| d 7} qW|  | | d !| d f S| } x* | | k  ry|  | d k ry| d 7} qPW|  | | !| f S(
   Ni    Ri  i   s   {[;]}t   'Rl   Rm   s    {[;]}(   Ni    (   R!   R-   (   R   R3
  R   R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR=
  "  s0    


c           s    j        s   St    d k r` y t    SWq` t k
 r\ | rX t    n    SXn    d d k r | r   d d k s d   d d !k r t    n    d d !S  d d k r | r   d d k s d   d d !k r t    n    S| r't   f d   d D  r't    n    d d	 k r;  S  d k rKt S  d k r[t S  d  d k rt j	 g    d d !j
 d  D] } t |  ^ q j   S  d  d k rt j g    d d !j
 d  D] } t |  ^ q j   Sd   k sd   k r0y t    SWq0t k
 r,q0Xn  y t    SWn t k
 rQn Xy t    SWn# t k
 r| rt    qn X  S(   Ni   i    R?
  iRl   Rm   c         3  s   |  ] } |   k Vq d  S(   N(    (   R   R   (   R   (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>#  s    s    ';[]{}t   @R	  R5   R	  R4   i   s   zeros(R	  i   s   ones(R	  R[   (   R	  R5   (   R	  R4   (   Ra  R!   R   R2   R   R   R5   R4   R.   R  R  RB  t   onesR  (   R   t   failR   (    (   R   s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRZ   "  sZ    ))"<<c           s9  |  j    }  y  |  d t SWn t k
 r3 n Xg  } } | g } x   |   D] } | d k r| g  } | j |  qT | d k r | j   } t |  d k r t | d t t f  r | d } n  | d } | j |  qT | j  |   qT Wt |  d k r5t | d t t f  r5| d } n  | S(   NRB
  s   [{s   ]}i   i    i(	   Ra  R5   R   R(   Rk	  R!   R   R   R{   (   R   RL   t   add2t   levelsR   R   (   R>
  RZ   (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR	  *#  s*    
	+
+s   s   
i    t   %Ri   i   c         3  s   |  ] } |   k Vq d  S(   N(    (   R   R   (   R  (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>L#  s    s	    ';[]{}<>(   R4   Rw	  Ra  R  R   (   RU	  R	  RY  Rp  R  (    (   R  R>
  R=
  RZ   s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR	  "  s"    	0s    c         C  s'   |  j  |  } | d k  r |  S|  |  S(   s   Return string truncated at first null character.

    Clean NULL terminated C strings. For unicode strings use null='\0'.

    >>> stripnull(b'string\x00')
    b'string'
    >>> stripnull('string\x00', null='\0')
    'string'

    i    (   R   (   RU	  Rr	  R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR   S#  s    c         C  s_   t  |   } xD | rL | d 8} d t |  |  k  o@ d k  n r Pq q Wd } |  | d  S(   s   Return string truncated at last byte that is 7-bit ASCII.

    Clean NULL separated and terminated TIFF strings.

    >>> stripascii(b'string\x00string\n\x01\x00')
    b'string\x00string\n'
    >>> stripascii(b'\x00')
    b''

    i   i   i   i(   R!   t   byte2int(   RU	  R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRf  b#  s    	
&R	  u   trueR	  u   falsec         C  s?   |  j    j   }  |  | k r" t S|  | k r2 t St    d S(   sd   Return string as bool if possible, else raise TypeError.

    >>> asbool(b' False ')
    False

    N(   Ra  Rb  R5   R4   R   (   RZ   R	  R	  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR	  x#  s    c      	   C  sd   | d k r! t t t t f } n  x< | D]4 } y | |   SWq( t t t t f k
 r[ q( Xq( W|  S(   s   Return argument as one of types if possible.

    >>> astype('42')
    42
    >>> astype('3.14')
    3.14
    >>> astype('True')
    True
    >>> astype(b'Neee-Wom')
    'Neee-Wom'

    N(	   R-   R   R  R	  Re  R   RQ   R   t   UnicodeEncodeError(   RZ   R	  t   typ(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  #  s    i   c         C  sM   |  | k  r d |  Sx2 d
 D]* } |  d }  |  | k  r d |  | f Sq Wd	 S(   s   Return file size as string from byte size.

    >>> format_size(1234)
    '1234 B'
    >>> format_size(12345678901)
    '11.50 GiB'

    s   %i Bt   KiBt   MiBt   GiBt   TiBt   PiBg      @s   %.2f %sN(   RI
  RJ
  RK
  RL
  RM
  (    (   R<   t	   thresholdRJ  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR   #  s    	
c         C  s   |  S(   sO   Single argument identity function.

    >>> identityfunc('arg')
    'arg'

    (    (   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  #  s    c          O  s   d S(   s<   Null function.

    >>> nullfunc('arg', kwarg='kwarg')

    N(    (   R  R#   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   nullfunc#  s    c         C  s.   y t  |   |  SWn t k
 r) |  f SXd S(   s{   Return tuple containing value if value is not a sequence.

    >>> sequence(1)
    (1,)
    >>> sequence([1])
    [1]

    N(   R!   R   (   RZ   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  #  s
    	
c         C  s%   d } x |  D] } | | 9} q W| S(   s   Return product of sequence of numbers.

    Equivalent of functools.reduce(operator.mul, iterable, 1).
    Multiplying numpy integers might overflow.

    >>> product([2**8, 2**30])
    274877906944
    >>> product([])
    1

    i   (    (   t   iterablet   prodR   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR   #  s    c           s.     f d   } t  j d    t |  d | S(   s   Return human sorted list of strings.

    E.g. for sorting file names.

    >>> natural_sorted(['f1', 'f2', 'f10'])
    ['f1', 'f2', 'f10']

    c           s;   g  t  j   |   D]$ } | j   r1 t |  n | ^ q S(   N(   Rz  R  t   isdigitR   (   R   R   (   t   numbers(    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   sortkey#  s    s   (\d+)R   (   Rz  R{  R  (   RP
  RT
  (    (   RS
  s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR   #  s    	iZ
 c         C  s   | t  j |   S(   s   Return datetime object from timestamp in Excel serial format.

    Convert LSM time stamps.

    >>> excel_datetime(40237.029999999795)
    datetime.datetime(2010, 2, 28, 0, 43, 11, 999982)

    (   R.  t	   timedelta(   t	   timestampt   epoch(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   excel_datetime#  s    	c         C  sd  |  d k r d S|  d } | d k rV t j | d d  } | d | | d 7} n  | | d k rk d n d } t j | d	 d
  } t j d
 |  } t j | | d  } | | t j d |  } | | d k  r d n d }	 | |	 d k r d n d }
 t | d  \ } } t | d  \ } } t | d  \ } } t j |
 |	 | | | | |  S(   s   Return datetime from days since 1/1/4713 BC and ms since midnight.

    Convert Julian dates according to MetaMorph.

    >>> julian_datetime(2451576, 54362783)
    datetime.datetime(2000, 2, 2, 15, 6, 2, 783)

    iOD i   i# g   @}<Ag    @i   i  i  gfffff^@g     v@gaTR'>@g      +@i   g      @il  ik  i  i<   Ni`  i6 i`  (   R-   t   matht   truncR  R.  (   t	   juliandayt
   milisecondRc   R	  RD  R   RY  R[   t   dayt   montht   yeart   hourt   minutet   second(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR}   $  s$    	
c         C  sP   |  d k s |  t  j k r t Si d d 6d d 6} | j |  |   | t  j k S(   sc   Return if byteorder matches the system's byteorder.

    >>> byteorder_isnative('=')
    True

    Ri   Rm   R}  Rl   Rk   (   R~   R*   R5   R3   (   R*   R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   byteorder_isnative"$  s    c         C  s   i  } x t  |  j j |   D]i \ } } | d  \ } } | d d k r] t t |   } n | j d k  r{ | j   } n  | | | <q W| S(   s   Return numpy.recarray as dict.i   i   R  (   R|  R/   t   descrRe  R   RB  RB  (   t   recarrayRL   Rd
  RZ   R|  R/   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRM	  /$  s    "c           sf   d d l  m } d   | r/ | \   n  d           f d     | j |    S(   s   Return XML as dict.

    >>> xml2dict('<?xml version="1.0" ?><root attr="name"><key>1</key></root>')
    {'root': {'key': 1, 'attr': 'name'}}

    i(   R  R   c         S  s@   x9 t  t t f D]( } y | |   SWq t k
 r7 q Xq W|  S(   N(   R   R  R	  R2   (   RZ   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  J$  s    c   	        st  |  j  }  r( | j d d  d } n  i |  j r: i  n d  | 6} t |   } | r t j t  } xK t  |  D]: } x1 | j   D]# \ } } | | j	   |   q Wqu Wi   f d   | j   D | 6} n  |  j r| | j
    f d   |  j j   D  n  |  j rp|  j j   } | s9|  j r]| rm  |  | |  d <qmqp  |  | | <n  | S(   NR	  i   ic           sG   i  |  ]= \ } } t  |  d  k r4   | d  n	   |  |  q S(   i   i    (   R!   (   R   R  R  (   R  (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys
   <dictcomp>_$  s   	c         3  s+   |  ]! \ } }  |   |  f Vq d  S(   N(    (   R   R  R  (   R  t   at(    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>b$  s    RZ   (   RT  R	  R  R-   R   R  t   defaultdictR/
  R  R(   R@   R  Ra  (	   R   R   RY  t   childrent   ddt   dcR  R  R  (   R  Rf
  t
   etree2dictt   sanitizeR]  (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRk
  S$  s*    		0	(   R
  R  R  (   Rk  Rl
  R	  R  (    (   R  Rf
  Rk
  Rl
  R]  s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR   =$  s    
		iK   i   is   ...c      	     s  t  |   } | d k  s0 | d k  s0 | d k  r4 d S| d k r d } t | | t  |  d | |  } | d k  r{ d Sd }	 nw d t  d |  } t | | t  | d  d | |  } | d k  r d Sd | t  | d  } | d | d }	 | d k s| d k r| } n> d t |  k  o9d k  n rZt t j | |   } n  | d k  rs| | 7} n  | d k s|	 d k rd |  |  f g }
 d } d } d | } n | d k s|	 | k rd |  f g }
 n | d k r| |	 | } | |  | f g }
 n | | k s)| d k  rI| | } d |  |  f g }
 nU | | } | | | d } d |  |  f | | | d f | | |  | | f g }
 t |  } g  } x$|
 D]\ } }  |  d k r| j |  qn  t	 j
 |   } t j d	 d
 |   } x t d t  |   |  D] } | d | d | | d !  | d k r\| | | n | } | d j   f d   t d d | d  D  7} | d | t  |  7} | | | | | !7} | j |  qWqWd j |  } t j d d k r| j d  } n  | S(   s   Return hexdump representation of byte string.

    >>> hexdump(binascii.unhexlify('49492a00080000000e00fe0004000100'))
    '49 49 2a 00 08 00 00 00 0e 00 fe 00 04 00 01 00 II*.............'

    i   i   R   i   s   %%0%ix: s   %xi   i    s   [^\x20-\x7f]R	  Ri  c         3  s    |  ] }   | | d  !Vq d S(   i   N(    (   R   R   (   RE  (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>$  s    s   
R   N(   R!   R#  R-   t   absR   RY
  t   floorR  R(   t   binasciit   hexlifyRz  t   subR   R   R~   t   version_infoR  (   R   RX  R[  t   snipatR  t   ellipsisR<   t   addrt   bytesperlinet   nlinesRm	  R$  t   endt   end1t   end2RL   t   hexstrt   strstrR   R  (    (   RE  s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   hexdumpo$  sx    $		 		"

 3c           s   |  j    }  t |   d k  r" t St j d d k r y |  j   SWn t k
 rV n Xy |  j d  j   SWq t k
 r q Xn0 |  j   r t Sd   t	   f d   |  D  Sd S(   s   Return if all characters in string are printable.

    >>> isprintable('abc')
    True
    >>> isprintable(b'')
    False

    i   i    i   s   utf-8sd   0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ 	
c         3  s   |  ] } |   k Vq d  S(   N(    (   R   R   (   t	   printable(    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>$  s    N(
   Ra  R!   R5   R~   Rr
  t   isprintableR2   R  t   isalnumR  (   RU	  (    (   R~
  s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR
  $  s     	c         C  s   x5 d
 d d d d f D] \ } } |  j  | |  }  q W| ry x8 d d d d d f D] \ } } |  j  | |  }  qT Wn  |  j   S(   s)   Return string with compressed whitespace.s   
s   
s   s   

s   	Ri  s     s   [ Rv	  (   s   
s   
(   s   s   
(   s   

s   
(   s   	Ri  (   s     Ri  (   s   
Ri  (   s   [ Rv	  (   s     Ri  (   s     Ri  (   s     Ri  (   R  Ra  (   RU	  t   compactRc   RD  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   clean_whitespace$  s    	c         C  s   y d d l  j } t |  t  s3 |  j d  }  n  | j t j |    }  | j |  d t	 d t	 d |  j
 j }  t |   }  WnA t k
 r t |  t  r t |   }  n  |  j d d  }  n X|  j d	 d
  j d d
  S(   s   Return pretty formatted XML.iNs   utf-8t   pretty_printt   xml_declarationt   encodings   ><s   >
<s     Ri  s   	(   t
   lxml.etreeR  R   R   Rq  R	  Rc  Rd  R   R5   t   docinfoR
  Re  R2   R  (   Rk  R  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   pformat_xml$  s    iO   c         C  s  | d k s | d k  r! d } n  | d k s9 | d k  rB d } n  t j   } t j d d d |  t |  t  r&|  d  j   d k r | d k r |  d	 |  }  qt |   }  nb t |  t  rt	 |   r t
 |   }  t |   }  qt j |   t |  d
 | d | d d Sn  |  j   }  nm t |  t j  rG|  j   }  nL d d l } t j d d k rli  n t d |  } | j |  d
 | | }  t j |   | d k rt |  d t }  |  |  St |  j    } t |  | k rd j | | d  d g | | d  }  n  |  S(   sc   Return pretty formatted representation of object as string.

    Whitespace might be altered.

    i   i   i   RN
  id   t	   linewidthi   s   <?xmli   RX  R[  R  iNi    i   R
  s   
s   ...(   s   <?xmls   <?xml(   R-   R.   t   get_printoptionst   set_printoptionsR   R   Rb  R
  R   R
  Re  R
  R}
  t   rstripR  t   pprintR~   Rr
  Ru  R_  R5   R   Rw	  R!   R   (   R   RX  R[  R
  t   npoptR
  t   argl(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR_  $  s>    		(.g      ?c         C  sZ  | d k r- t |  t  r$ d } q- d } n  t |  } |  j   } g  } x| D]} | d k rw | j |  qR n  t |  } | | k r | j |   qR n  | }	 |	 d k s |	 d k r | }	 n> d t |	  k  o d k  n rt t j	 | |	   }	 n  |	 d k  r5|	 | 7}	 |	 d k  r5d }	 q5n  | d k sQ| | d k  r|	 d k rr| j |  |  q)| j |  |   qR |	 d k r| j | |  | |  qR |	 | k s| | d k  r| j |  | |  |  qR | | | }
 |	 |
 d } | |
 } | j |  |  | |  |  qR Wt |  t  rId j
 |  Sd j
 |  Sd S(	   sc   Return string cut to specified length.

    >>> snipstr('abcdefghijklmnop', 8)
    'abc...op'

    s   ...u   …i   i    i   i   s   
N(   R-   R   R   R!   Rw	  R(   Rm
  R   RY
  Rn
  R   (   RU	  RX  Rs
  Rt
  R]	  Rw	  RL   Rp  t   linelenR  t   splitlenRy
  Rz
  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR]  "%  sN    			"

!c         C  s\   y |  |  SWnG t  k
 rW y |  | j   SWqX t  k
 rS t d |   qX Xn Xd S(   s   Return enum member from its name or value.

    >>> enumarg(TIFF.PHOTOMETRIC, 2)
    <PHOTOMETRIC.RGB: 2>
    >>> enumarg(TIFF.PHOTOMETRIC, 'RGB')
    <PHOTOMETRIC.RGB: 2>

    s   invalid argument %sN(   R2   R  R   (   R  R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  \%  s    	c         O  s   i  } x2 | D]* } | |  k r |  | | | <|  | =q q WxH | j    D]: \ } } | |  k rx |  | | | <|  | =qH | | | <qH W| S(   sX  Return dict with keys from keys|keyvals and values from kwargs|keyvals.

    Existing keys are deleted from kwargs.

    >>> kwargs = {'one': 1, 'two': 2, 'four': 4}
    >>> kwargs2 = parse_kwargs(kwargs, 'two', 'three', four=None, five=5)
    >>> kwargs == {'one': 1}
    True
    >>> kwargs2 == {'two': 2, 'four': 4, 'five': 5}
    True

    (   R  (   R#   R  t	   keyvaluesRL   R   RZ   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR   n%  s    
c         K  s:   x3 | j    D]% \ } } | |  k r | |  | <q q Wd S(   s   Update dict with keys and values if keys do not already exist.

    >>> kwargs = {'one': 1, }
    >>> update_kwargs(kwargs, one=None, two=2)
    >>> kwargs == {'one': 1, 'two': 2}
    True

    N(   R  (   R#   R
  R   RZ   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   update_kwargs%  s    	t   jhoves   More than 50 IFDsc         C  s   d d l  } | j | |  d d g  } d | k r xv | j   D]e } | j   } | j d  r@ | d j d  } x* | D] } | | k r{ Pq{ q{ Wt |   Pq@ q@ Wn  d S(   s2  Validate TIFF file using jhove -m TIFF-hul.

    Raise ValueError if jhove outputs an error message unless the message
    contains one of the strings in 'ignore'.

    JHOVE does not support bigtiff or more than 50 IFDs.

    See `JHOVE TIFF-hul Module <http://jhove.sourceforge.net/tiff-hul.html>`_

    iNs   -ms   TIFF-huls   ErrorMessage: i   t   utf8(   t
   subprocesst   check_outputRw	  Ra  RX  R  R   (   RI   R
  R  R
  R  Rp  t   errorR   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   validate_jhove%  s    i   c         C  s  | r t  n t } | d k r' |  } n | j   d k rB d } n  | rU | d 7} n  | d d d d t t j   } t |   	} | j s | d | d t t d   n  | j	 d	 } | j
 } | j } | j }	 t |  |	 j }
 | d
 t j   |  | d | | |	 t |
  f d t | j j d  sKt d   n  | d d d d t t j   } | d | d | d | d f } | r| | d | d | d	 | d f } n  d d t |  | } t j | d d |	 } t j | d | d | d	 | d f d |	 } t | j  } x<t | d	  D]*} x!t | d  D]} xt | d  D] } x. t | d  D] } t |  j   | | <qWx t | d	  D] } x t | d  D] } | d | | d	 | d | d	  | | d | d | d  f | (| rF| j | | | | | | f  n  | d d d d t qWqWqpWqYWqBW| d t j   |  Wd QXd S(   s   Convert [MP]TZCYX LSM file to series of BIN files.

    One BIN file containing 'ZCYX' data are created for each position, time,
    and tile. The position, time, and tile indices are encoded at the end
    of the filenames.

    t   nones*   _(z%ic%iy%ix%i)_m%%ip%%it%%03iy%%ix%%i.bins   
Opening LSM file... Rx
  R   R$  s   
s   not a LSM filei    s   %.3f ss5   Image
  axes:  %s
  shape: %s
  dtype: %s
  size:  %st   TZCYXs   not a *TZCYX LSM files#   Copying image from LSM to BIN filesiiiii   i   i   R/   i   .R	  s    %.3f sN(   i   (   t   print_RO
  R-   Rb  R5   Rg  R   R  R   RF   R9   R  R/   R   R0   R   R"  R!   R.   R  t   iterRC   R   R
  R"   R  (   t   lsmfilet   binfileR(  t   verboset
   start_timeRd   RF   R9   R  R/   R<   RK  R8   R  RC   Ra  RM  R   RO  RN  R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   lsm2bin%  s^    						 $)(	%#*R  i`   io   i   c           s  | dQ k }  j  j d k r' t } n  | rr  j d dR k p_  j d k o_  j d dS k rr t } d } n   j    | dT k r t  d   n t  d    j   d k  r t d
   n d k r d  t } n | r0 j d dU k r0t	 j
  d d   t	 j
  d d   n | r j d  j d d k  r j d  j d d k  r j d d k  rt	 j
  d d   t	 j
  d d   n  | o j d dV k }  | rd n d 8 | r d d |  d |  d |  f  n  d d |  d |  f  | d k r{| r{ j   } | d k ri d ? n   j d   n j  j d k r| o j  j d k s| d k ry+ t t j t j  j   d    } Wq&t k
 r  j  j d } q&Xn" t | t  s& j  j d } n  d | } | r>| d k  rS d | > n | d k rp | d ? n   j d   q>n  j  j d k r j   } | r>| d k r> j  j d k r j d    |  q |  q>nK  j  j d k rd } n0  j  j d k r>t	 j     j   } n  | s+| d k rY| } n  | d k r+ j  j d k rt	 j  j   j } t	 j   } | | k rt	 j  | k  } qn   j  j d k rt	 j  j   j } t	 j   } | | k r%t	 j  | k  } q%q(d } q+n  t j d }  d k r| j d d d d d  d! d | j d" | d# dW d& t d' d( d) d*   y  j j  j! j" |  Wn t k
 rn X| rt# | j$    n d } | j% d+ d,  d d- d. | d, d/ d0 d1 d2 d3 d4 d5 d6  n  | j& |
  }
 | rly t' | d7  } Wn t( k
 rUn X| j" | d! d8 n  | d k r j  j d9 k rd: } n-  j  j d; k s| d k rd< } n d= } | d	 k r| d> 7} qn  | j) t	 j*  dX  j    d? | d@ | dA | dB | |  | s0| j+   n       f dC   } dD   } | |
 _, |  _- |  _.  rt/ dY    d  t0   j   g   g  t1   D]d } | j2 | j3 dE d, | d dF dG g  dH | d  j | d d d' dI dJ dK  j | ^ q} x | D] } t | _4 qW|      f dL        f dM        f dN  }  j j5 dO |  x6 t6 |  D]% \ } } | j7 |  f dP   qWn   |
  f S(Z   s  Plot n-dimensional images using matplotlib.pyplot.

    Return figure, subplot and plot axis.
    Requires pyplot already imported C{from matplotlib import pyplot}.

    Parameters
    ----------
    bitspersample : int or None
        Number of bits per channel in integer RGB images.
    photometric : {'MINISWHITE', 'MINISBLACK', 'RGB', or 'PALETTE'}
        The color space of the image data.
    title : str
        Window and subplot title.
    figure : matplotlib.figure.Figure (optional).
        Matplotlib to use for plotting.
    subplot : int
        A matplotlib.pyplot.subplot axis.
    maxdim : int
        maximum image width and length.
    kwargs : optional
        Arguments for matplotlib.pyplot.imshow.

    R  RD  ii   i   i   iR  R  s   not an imagei    ii   i   .NR  i   R   t   uii   R   g      ?RY  R   R   s   matplotlib.pyplott   fontt   familys
   sans-serift   weightt   normalR<   t   dpit   figsizeg$@g333333@t   frameont	   facecolors   1.0t	   edgecolort   wt   bottomgQ?t   topg\(\?t   leftg?t   rightgffffff?t   hspaceg?t   wspaceg        s   Windows-1252i   R   t   grayt   buft   viridist   coolwarmt   _rt   vmint   vmaxRI	  t   interpolationc           s   t  |  d  }  t  | d  } yG  rK d   d | |  f  | |  f Sd  | |  f | |  f SWn t k
 r{ d SXd  S(   Ng      ?s   %s @ %s [%4i, %4i]i   s   %s @ [%4i, %4i]R   (   R   R  (   R   RN  (   t   curaxdatt   currentR8   t   dims(    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   format_coord&  s    c         S  s   d S(   NR   (    (   Rr  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR
  &  s    g      ?g333333?g?s   Dimension %is   0.5t   valfmts
   %%.0f [%i]c           s{   | t  |   j     d < j   d  x< t | |   D]+ \ } } t | _ | j |  t | _ q; W j j	   d  S(   Ni   (
   R   R  t   set_dataR|  R4   t   eventsont   set_valR5   t   canvast   draw(   R
  t   slidersR8   t   ctrlR8  (   R
  t   figureR
  (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt	   set_image&  s    	c           s   t  t |    }  |   d <|  | | k r0 d  S|  | j | k rL d }  n  |  d k  rl | j | d }  n  |  | | < |  d  S(   Ni    i   (   R   t   roundR9   (   R8  R   R8   R
  (   R
  R
  (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt
   on_changed&  s    
	
c           s<  |  j  }   d } t |  d k r5  | |  n| d k rY  | | d |  n | d k r}  | | d |  n | d k r | t | j  d k r d n | d   d <n | d k r | d k r t | j  d n | d   d <nC | d k r | j | d |  n | d	 k r8 d |  n  d  S(
   Ni    t
   0123456789R
  i   R
  t   upt   downRx
  t   home(   R   R{   R!   R9   (   Rr  R8   R
  R   R   (   R
  R
  (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   on_keypressed&  s     	
00t   key_press_eventc           s     |  |  S(   N(    (   R  Rc   (   R
  (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR   &  R   (   R  (   i   i   (   i   i   (   R  R  N(   i   i   (   i   i   (   g$@g333333@(   i    (   i    (8   R/   R  R4   R9   RB  R  R-   R  R   R.   R	  R^  R  R0   R   RY
  t   ceilt   logR2   R   R  RH   t   absolutet   iinfoR#  t   finfoR~   t   modulest   rcR
  R5   R
  t   managert   windowt   titleR!   Rw	  t   subplots_adjustt   subplotRL	  R   R   t
   atleast_2dt   colorbarR
  t   get_cursor_datat   format_cursor_dataR   R   R   t   SliderR  t   drawont   mpl_connectR!  R
  (   R8   R
  R
  R
  RI	  R  R&  R
  R
  R
  R
  t   maxdimR#   Rs  t   datamaxt   dtmint   pyplotR<   R
  R
  R   R
  t   sliderR
  R
  (    (   R
  R
  R8   R
  R
  R
  R
  R
  s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR   %  s    	#			%+%+
		%		#				t
 c          C  s   t  j d }  |  j   d S(   s)   Block the GUI. For use as skimage plugin.s   matplotlib.pyplotN(   R~   R
  t   show(   R
  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt	   _app_show&  s    c          K  s   y  d d l  m } d d l } Wn' t k
 rI d d l m } m } n X|   } | j   | j   | j |    } | j	   | S(   s4   Return file name(s) from Tkinter's file open dialog.i(   t   TkN(   R
  t
   filedialog(
   t   TkinterR
  t   tkFileDialogRN  t   tkinterR
  t   withdrawR@   t   askopenfilenamet   destroy(   R#   R
  R
  R  t	   filenames(    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR
  &  s    	


c           s  t  t j d d ! d k  r; t d  t d t j  d S|  d k rS t j }  n  d d l } | j d d	 d
 d d d t  } | j	 } | d d d d d d d d d d | d d d d d d d d d d | d d d d d d t
 d d | d  d d! d d d d" d d# | d$ d d% d& d' d d( d d) | d* d d+ d d d d, d d- | d. d d/ d d d d d d0 | d1 d d2 d d d d d d3 | d4 d d5 d d d t
 d d6 | d7 d d8 d d d t
 d d9 | d: d; d d< d d d d= | d> d? d d@ d d | j   \ }   dA j      | j rid d l } | j dB | j  d S  st dC dD dE t j      s| j dF  qn  t   f dG   dH D  rt j        st dI  d S  d   n  | j st dJ dK dA n  t j   } y t   dL | j } Wn< t k
 rl} | j rO  qmt dM |  t j d  n X| j st dN t j   | dO  n  | j rt | _ n  g  }	 | j  d k r| j st dP dK dA n  dQ   }
 t j   } yw| j! d k r-| j" dR | j!  | | j! d f g }	 n| j# d k r}| j" d | j#  |
 | j# | j# j$  | j# | j# f g }	 n g  }	 x t% | j# | j    D] \ } } y6 |	 j& | j" d |  |
 | j$  | j# | f  Wqt' k
 r9} |	 j& d |
 | j(  d f  | j r  q:t dS | | f dK dT qXqW| j sft dN t j   | dO  n  Wqt k
 r} | j r  qt |  qXn  | j st   t t j) | d< t* | j+   t   n  | j,   |	 r| j  d k ry- d d l- } | j. dU  d dV l- m/ } Wn$ t0 k
 rG} t1 j2 dW |  qXx|	 D]\ } } } | d k rpqOn  | j3 | j4 } } dX | j5 k ry- t6 j7 | | t  | j5 dX j8  k  } Wqt' k
 rqXn  | j9 r6y | j: dY } | j: dZ } Wn t; k
 rq6X| | k r6| j3 | j4 } } q6n  | rdd[ t< |  t< |  t< |  f } n d\ t< |  t< |  f } d] } | j= da k rt j> | j=  j? } n  t@ | dC | d/ | d2 | d^ | jA d_ | d` | jB d+ | jC qOW| jD   n  d S(b   s!   Command line usage main function.i    i   g@s2   This script requires Python version 2.7 or better.s   This is Python version %siNt   usages   usage: %prog [options] pathR-  s!   Display image data in TIFF files.R  s	   %%prog %ss   -ps   --paget   destRJ   R	  R   t   defaultt   helps   display single pages   -ss   --seriesRF   s%   display series of pages of same shapes   --nomultifilet   nomultifilet   actiont
   store_trues*   do not read OME series from multiple filess	   --noplotst   noplotsi   s   maximum number of plotss
   --interpolt   interpolt   metavart   INTERPOLt   bilinears   image interpolation methods   --dpiR
  i`   s   plot resolutions   --vminR
  s   minimum value for colormappings   --vmaxR
  s   maximum value for colormappings   --debugt   debugs   raise exception on failuress	   --doctestt   doctests   runs the docstring exampless   -vs   --detailRW  i   s   -qs   --quiett   quietRi  t   optionflagsR
  s   Select a TIFF filet	   filetypess   No file specifiedc         3  s   |  ] } |   k Vq d  S(   N(    (   R   R   (   R  (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>#'  s    s   ?*s   no files match the patterns   
Reading file structure...Rx
  R   s   
s   %.3f msg     @@s   Reading image data... c         S  s   t  d   |  D  S(   Nc         s  s!   |  ] } | d  k	 r | Vq d  S(   N(   R-   (   R   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pys	   <genexpr>B'  s    (   R
  (   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   notnoneA'  s    R   s   
Series %i failed: %s... R   t   TkAgg(   R
  s   failed to import matplotlib.
%sR"  R  R  s   %s
%s
%ss   %s
 %sR  R  R&  R
  (   i   (E   R  R~   R  t   printR-   t   argvt   optparset   OptionParsert   __version__t
   add_optionR4   t
   parse_argsR   R  t   testmodt   ELLIPSISR
  RA   Rb  R
  R   R   R  Rg  R   R
  R2   R  t   exitR   R5   t   norgbR
  RJ   R"   RF   R  R!  R(   R   RC   RZ  R   RW  Ru  t
   matplotlibt   useR
  RN  R   R   R
  R
  R   R.   R#  RZ   R{  R  R   R{   R&  R  R|  R   R  R
  R
  R
  (   R	  R
  t   parsert   optt   settingsR  R$  R&   R[   R  R  R   R   R  R
  t   imgRJ   RF   R
  R
  R
  R&  (    (   R  s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   main&  s   
			
						#		#		"

'	(		c          O  s9   | j  d t  } t |  |   | r5 t j j   n  d S(   s"   Print function with flush support.R$  N(   Rk	  R4   R  R~   t   stdoutR$  (   R  R#   R$  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR
  '  s    c         C  s   |  S(   s   Return string from bytes.(    (   RD  R
  Rq	  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRe  '  s    c         C  s   |  S(   s   Return bytes from string.(    (   R   R
  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  '  s    c         C  s
   t  |   S(   s   Return value of byte as int.(   R	  (   RD  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRF
  '  s    R}   c           B  s   e  Z RS(    (   RV   R]   (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR}   '  s   t   strictc         C  sU   | d k	 r |  j | |  Sy |  j d |  SWn t k
 rP |  j d |  SXd S(   s)   Return unicode string from encoded bytes.s   utf-8t   cp1252N(   R-   R  Rg  (   RD  R
  Rq	  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRe  '  s    R  c         C  s   |  j  |  S(   s!   Return bytes from unicode string.(   Rq  (   R   R
  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyR  '  s    c         C  s   |  S(   s   Return value of byte as int.(    (   RD  (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyRF
  '  s    t   __main__(   R^   t
   __future__R    R   R~   R  Rc  Rz  R   RY
  RJ  Rg  RJ	  R  R   Rt  R   Ro
  R6
  R.  R  R  R*
  t   concurrent.futuresR,
  R.   R  t   __docformat__t   __all__R   R-   R   R   RR  R
   R   R   R  RY  R  R  R  R   R	   R  R  R  RA   RD	  R  R  R  Rb  RH	  Rc  R  R  R  R  R  R  R  R  RO	  R	  R  R-  R[	  R*  R+  R,  R)  R  R  R  R  R  R  R	  R  R  R  R4   R  R  R  R  R	  R  R	  R	  R  R  R	  t   __package__R	  R  RT  R   R  R5   R  R  R  R
  R   R  R  R!
  R  R  R  R  R   R	  R   Rf  R	  R  R   R  RO
  R  R   R   t   fromordinalRX
  R}  Rc
  RM	  R   R}
  R
  R
  R
  R_  R]  R  R   R
  R
  R
  R   R
  R
  R  Rr
  R   t   longR  R
  Re  R  RF
  R|   R}   R{   R   R   RL	  R  RV   R  (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/_tifffile.pyt   <module>k  sj  		0!DN        ~    |} %2       j				
											^		&			
			0			&	
		8	
	M	:	"	1		B	,		!	!		'	(V	I5 	!	"	-0	$			
					"		2J		/:			A							