3
d/                 @   s   d Z ddlZddlmZmZmZmZmZmZ ddl	m
Z
 ddlmZ dd	d
dddddddddddddddddddgZG dd deZG d d! d!eZG d"d# d#eZdS )$zRPETPVC is a toolbox for partial volume correction in positron emission tomography.    N   )TraitedSpecCommandLineInputSpecCommandLineFile	isdefinedtraits   )fname_presuffix)BibTeXZGTMZIYzIY+RLzIY+VCZLABBEz	LABBE+MTCzLABBE+MTC+RLzLABBE+MTC+VCz	LABBE+RBVzLABBE+RBV+RLzLABBE+RBV+VCZMGzMG+RLzMG+VCZMTCzMTC+RLzMTC+VCZRBVzRBV+RLzRBV+VCZRLVCc               @   s   e Zd ZedddddZedddddZed	ddd
dZeje	ddddZ
ejddddZejddddZejddddZejdddddZejdddddZejdddddZejdddd dZejd!d"dd#dZd$S )%PETPVCInputSpeczPET image fileTz-i %s)descexists	mandatoryargstrzOutput fileFz-o %s)r   ZgenfileZ
hash_filesr   zMask image filez-m %sz-p %sa  Desired PVC method:

    * Geometric transfer matrix -- ``GTM``
    * Labbe approach -- ``LABBE``
    * Richardson-Lucy -- ``RL``
    * Van-Cittert -- ``VC``
    * Region-based voxel-wise correction -- ``RBV``
    * RBV with Labbe -- ``LABBE+RBV``
    * RBV with Van-Cittert -- ``RBV+VC``
    * RBV with Richardson-Lucy -- ``RBV+RL``
    * RBV with Labbe and Van-Cittert -- ``LABBE+RBV+VC``
    * RBV with Labbe and Richardson-Lucy -- ``LABBE+RBV+RL``
    * Multi-target correction -- ``MTC``
    * MTC with Labbe -- ``LABBE+MTC``
    * MTC with Van-Cittert -- ``MTC+VC``
    * MTC with Richardson-Lucy -- ``MTC+RL``
    * MTC with Labbe and Van-Cittert -- ``LABBE+MTC+VC``
    * MTC with Labbe and Richardson-Lucy -- ``LABBE+MTC+RL``
    * Iterative Yang -- ``IY``
    * Iterative Yang with Van-Cittert -- ``IY+VC``
    * Iterative Yang with Richardson-Lucy -- ``IY+RL``
    * Muller Gartner -- ``MG``
    * Muller Gartner with Van-Cittert -- ``MG+VC``
    * Muller Gartner with Richardson-Lucy -- ``MG+RL``

)r   r   r   z1The full-width at half maximum in mm along x-axisz-x %.4f)r   r   r   z1The full-width at half maximum in mm along y-axisz-y %.4fz1The full-width at half maximum in mm along z-axisz-z %.4fzPrints debug informationz-d)r   
usedefaultdefault_valuer   zNumber of iterations
   z-n %d)r   r   r   r   z"Number of deconvolution iterationsz-k %dzAlpha valueg      ?z-a %.4fzStopping criteriong{Gz?z-s %.4fN)__name__
__module____qualname__r   in_fileout_fileZ	mask_filer   Enumpvc_methodspvcZFloatZfwhm_xZfwhm_yZfwhm_zZBooldebugZIntZn_iterZn_deconvalphaZ	stop_crit r   r   :/tmp/pip-build-7vycvbft/nipype/nipype/interfaces/petpvc.pyr   ,   sJ   r   c               @   s   e Zd ZeddZdS )PETPVCOutputSpeczOutput file)r   N)r   r   r   r   r   r   r   r   r    r!   x   s   r!   c               @   sJ   e Zd ZdZeZeZdZe	dddgdgZ
dd ZdddZdd Zd	S )PETPVCa  Use PETPVC for partial volume correction of PET images.

    PETPVC ([1]_, [2]_) is a software from the Nuclear Medicine Department
    of the UCL University Hospital, London, UK.

    Examples
    --------
    >>> from ..testing import example_data
    >>> #TODO get data for PETPVC
    >>> pvc = PETPVC()
    >>> pvc.inputs.in_file   = 'pet.nii.gz'
    >>> pvc.inputs.mask_file = 'tissues.nii.gz'
    >>> pvc.inputs.out_file  = 'pet_pvc_rbv.nii.gz'
    >>> pvc.inputs.pvc = 'RBV'
    >>> pvc.inputs.fwhm_x = 2.0
    >>> pvc.inputs.fwhm_y = 2.0
    >>> pvc.inputs.fwhm_z = 2.0
    >>> outs = pvc.run() #doctest: +SKIP

    References
    ----------
    .. [1] K. Erlandsson, I. Buvat, P. H. Pretorius, B. A. Thomas, and B. F. Hutton,
           "A review of partial volume correction techniques for emission tomography
           and their applications in neurology, cardiology and oncology," Phys. Med.
           Biol., vol. 57, no. 21, p. R119, 2012.
    .. [2] https://github.com/UCL/PETPVC

    Zpetpvca  @article{0031-9155-61-22-7975,author={Benjamin A Thomas and Vesna Cuplov and Alexandre Bousse and Adriana Mendes and Kris Thielemans and Brian F Hutton and Kjell Erlandsson},title={PETPVC: a toolbox for performing partial volume correction techniques in positron emission tomography},journal={Physics in Medicine and Biology},volume={61},number={22},pages={7975},url={http://stacks.iop.org/0031-9155/61/i=22/a=7975},doi={https://doi.org/10.1088/0031-9155/61/22/7975},year={2016},}z*PETPVC software implementation publicationimplementation)entrydescriptiontagsc             C   sd   | j  j }| jj|d< t|d sL| jjj }| j| jjdj	|d|d< t
jj|d |d< |S )Nr   z_{}_pvc)suffix)output_specgetinputsr   r   r   lower
_gen_fnamer   formatospathabspath)selfoutputsmethod_namer   r   r    _list_outputs   s    zPETPVC._list_outputsNT.nii.gzc             C   sn   |dkr"d| j  }|d7 }t||dkr2tj }|rN|rJdj||f}n|}|dkrZd}t||d|d}|S )a  Generate a filename based on the given parameters.

        The filename will take the form: cwd/basename<suffix><ext>.
        If change_ext is True, it will use the extentions specified in
        <instance>intputs.output_type.

        Parameters
        ----------
        basename : str
            Filename to base the new filename on.
        cwd : str
            Path to prefix to the new filename. (default is os.getcwd())
        suffix : str
            Suffix to add to the `basename`.  (defaults is '' )
        change_ext : bool
            Flag to change the filename extension to the given `ext`.
            (Default is False)

        Returns
        -------
        fname : str
            New filename based on given parameters.

         z,Unable to generate filename for command %s. zbasename is not set!NF)r'   Zuse_extnewpath)cmd
ValueErrorr.   getcwdjoinr
   )r1   basenamecwdr'   Z
change_extextmsgfnamer   r   r    r,      s    
zPETPVC._gen_fnamec             C   s   |dkr| j  d S d S )Nr   )r4   )r1   namer   r   r    _gen_filename   s    zPETPVC._gen_filename)NNTr5   )r   r   r   __doc__r   Z
input_specr!   r(   Z_cmdr   Z_referencesr4   r,   rB   r   r   r   r    r"   |   s   
*r"   )rC   r.   baser   r   r   r   r   r   Zutils.filemanipr
   Zexternal.duer   r   r   r!   r"   r   r   r   r    <module>   s:    L