σ
;c]c           @` s²   d  Z  d d l m Z m Z m Z d d l m Z d d l m Z m	 Z	 d& a d   Z d' Z e d( Z d  e f d!     YZ d" Z e d# e d$ j e  d%  Z e j e  d& S()   s,    Storage of image data in multiple formats.
i    (   t   absolute_importt   print_functiont   divisioni   (   t   formats(   t   Formatt
   has_modulec           C` s|   y" d d  l  a t j a t j a WnS t k
 rw y" d d  l a t j a t j	 a Wqx t k
 rs t d   qx Xn Xt S(   Ni    s΄   itk could not be found. Please try   python -m pip install itk or   python -m pip install simpleitk or refer to   https://itkpythonpackage.readthedocs.io/ for further instructions.(
   t   itkt   _itkt   imreadt   _read_functiont   imwritet   _write_functiont   ImportErrort	   SimpleITKt	   ReadImaget
   WriteImage(    (    (    s8   lib/python2.7/site-packages/imageio/plugins/simpleitk.pyt   load_lib   s    			s   .gipls   .ipls   .mhas   .mhds   .nhdrt   niat   hdrs   .nrrds   .niis   .vtkt   hdf5t   lsmt   mnct   mnc2t   mght   pics   .bmps   .jpegs   .jpgs   .pngs   .tiffs   .tifs   .dicoms   .dcms   .gdcmt	   ItkFormatc           B` sR   e  Z d  Z d   Z d   Z d e j f d     YZ d e j f d     YZ RS(   s   The ItkFormat uses the ITK or SimpleITK library to support a range of
    ITK-related formats. It also supports a few common formats that are
    also supported by the freeimage plugin (e.g. PNG and JPEG).

    This format requires the ``itk`` or ``SimpleITK`` package.

    Parameters for reading
    ----------------------
    None.

    Parameters for saving
    ---------------------
    None.

    c         C` s<   | j  t k r t St d  s+ t d  r8 | j  t k Sd  S(   Ns   itk.ImageIOBaseR   (   t	   extensiont   ITK_FORMATSt   TrueR   t   ALL_FORMATS(   t   selft   request(    (    s8   lib/python2.7/site-packages/imageio/plugins/simpleitk.pyt	   _can_read\   s    c         C` s<   | j  t k r t St d  s+ t d  r8 | j  t k Sd  S(   Ns   itk.ImageIOBaseR   (   R   R   R   R   R   (   R   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/simpleitk.pyt
   _can_writef   s    t   Readerc           B` s5   e  Z d    Z d   Z d   Z d   Z d   Z RS(   c         K` s,   t  s t   n  t |  j j    |  _ d  S(   N(   R   R   R	   R   t   get_local_filenamet   _img(   R   t   kwargs(    (    s8   lib/python2.7/site-packages/imageio/plugins/simpleitk.pyt   _openo   s    
c         C` s   d S(   Ni   (    (   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/simpleitk.pyt   _get_lengtht   s    c         C` s   d  S(   N(    (   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/simpleitk.pyt   _closew   s    c         C` s7   | d k r! d } t  |   n  t j |  j  i  f S(   Ni    s.   Index out of range while reading from itk file(   t
   IndexErrorR   t   GetArrayFromImageR$   (   R   t   indext	   error_msg(    (    s8   lib/python2.7/site-packages/imageio/plugins/simpleitk.pyt	   _get_dataz   s    c         C` s   d } t  |   d  S(   Ns5   The itk plugin does not support meta data, currently.(   t   RuntimeError(   R   R+   R,   (    (    s8   lib/python2.7/site-packages/imageio/plugins/simpleitk.pyt   _get_meta_data   s    (   t   __name__t
   __module__R&   R'   R(   R-   R/   (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/simpleitk.pyR"   n   s
   					t   Writerc           B` s,   e  Z d    Z d   Z d   Z d   Z RS(   c         C` s   t  s t   n  d  S(   N(   R   R   (   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/simpleitk.pyR&      s    c         C` s   d  S(   N(    (   R   (    (    s8   lib/python2.7/site-packages/imageio/plugins/simpleitk.pyR(      s    c         C` s)   t  j |  } t | |  j j    d  S(   N(   R   t   GetImageFromArrayR   R   R#   (   R   t   imt   metat   _itk_img(    (    s8   lib/python2.7/site-packages/imageio/plugins/simpleitk.pyt   _append_data   s    c         C` s   d } t  |   d  S(   Ns5   The itk plugin does not support meta data, currently.(   R.   (   R   R5   R,   (    (    s8   lib/python2.7/site-packages/imageio/plugins/simpleitk.pyt   set_meta_data   s    (   R0   R1   R&   R(   R7   R8   (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/simpleitk.pyR2      s   			(   R0   R1   t   __doc__R    R!   R   R"   R2   (    (    (    s8   lib/python2.7/site-packages/imageio/plugins/simpleitk.pyR   K   s
   	
	s:   Insight Segmentation and Registration Toolkit (ITK) formatR   t    t   iIvVN(   s   .gipls   .ipls   .mhas   .mhds   .nhdrR   R   s   .nrrds   .niis   .vtkR   R   R   R   R   R   R   (	   s   .bmps   .jpegs   .jpgs   .pngs   .tiffs   .tifs   .dicoms   .dcms   .gdcm(   R9   t
   __future__R    R   R   t    R   t   coreR   R   t   NoneR   R   R   R   R   t   titlet   joint   formatt
   add_format(    (    (    s8   lib/python2.7/site-packages/imageio/plugins/simpleitk.pyt   <module>   sH   	                        O