3
do                 @   s  d dl jZddlmZ ddlmZmZmZm	Z	m
Z
mZmZ G dd deZG dd	 d	e	ZG d
d deZG dd deZG dd de	ZG dd deZG dd deZG dd de	ZG dd deZG dd deZG dd de	ZG dd deZG dd deZG d d! d!e	ZG d"d# d#eZG d$d% d%eZG d&d' d'e	ZG d(d) d)eZG d*d+ d+eZG d,d- d-e	Z G d.d/ d/eZ!G d0d1 d1eZ"G d2d3 d3e	Z#G d4d5 d5eZ$G d6d7 d7eZ%G d8d9 d9e	Z&G d:d; d;eZ'G d<d= d=eZ(G d>d? d?e	Z)G d@dA dAeZ*G dBdC dCeZ+G dDdE dEe	Z,G dFdG dGeZ-G dHdI dIeZ.G dJdK dKe	Z/G dLdM dMeZ0G dNdO dOeZ1G dPdQ dQe	Z2G dRdS dSeZ3dS )T    N   )split_filename   )CommandLineInputSpecCommandLinetraitsTraitedSpecFileInputMultiPath	isdefinedc               @   s  e Zd Zedddd(ddZeddd)ddZejddd	d
dddZej	ej
ddddd	ddZej	ej
ddd	d	d	ddZejddddddddddd
ZejddddddddddddZejdddddd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Zejd%d	d&dZd'S )*MRConvertInputSpecTz%sr   zvoxel-order data filename)existsargstr	mandatorypositiondesc   zOutput filename)genfiler   r   r   r   z	-coord %sz"Extract data only at the coordinates specified. This option specifies the Axis. Must be used in conjunction with extract_at_coordinate.)r   r   r   ,z"Extract data only at the coordinates specified. This option specifies the coordinates. Must be used in conjunction with extract_at_axis. Three comma-separated numbers giving the size of each voxel in mm.)r   sepr   minlenmaxlenr   z-vox %szBThree comma-separated numbers giving the size of each voxel in mm.Zniifloatcharshortintlongdoublez
-output %szI"i.e. Bfloat". Can be "char", "short", "int", "long", "float" or "double"Zmif)r   r   Z
usedefaultzspecify the layout of the data in memory. The actual layout produced will depend on whether the output image format can support it.z	-scale %dmmz&Apply scaling to the intensity values.)r   r   Zunitsr   z%Apply offset to the intensity values.z-zeroz!Replace all NaN values with zero.z-prszQAssume that the DW gradients are specified in the PRS frame (Siemens DICOM only).N)__name__
__module____qualname__r	   in_fileout_filenamer   EnumZextract_at_axisListFloatZextract_at_coordinateZ
voxel_dimsZoutput_datatype	extensionZlayoutZresampleZoffset_biasBoolZreplace_NaN_with_zeroZprs r+   r+   E/tmp/pip-build-7vycvbft/nipype/nipype/interfaces/mrtrix/preprocess.pyr      s   r   c               @   s   e Zd ZedddZdS )MRConvertOutputSpecTz%path/name of 4D volume in voxel order)r   r   N)r!   r"   r#   r	   	convertedr+   r+   r+   r,   r-   q   s   r-   c               @   s4   e Zd ZdZdZeZeZdd Z	dd Z
dd Zd	S )
	MRConverta  
    Perform conversion between different file types and optionally extract a subset of the input image.

    If used correctly, this program can be a very useful workhorse.
    In addition to converting images between different formats, it can
    be used to extract specific studies from a data set, extract a specific
    region of interest, flip the images, or to scale the intensity of the images.

    Example
    -------

    >>> import nipype.interfaces.mrtrix as mrt
    >>> mrconvert = mrt.MRConvert()
    >>> mrconvert.inputs.in_file = 'dwi_FA.mif'
    >>> mrconvert.inputs.out_filename = 'dwi_FA.nii'
    >>> mrconvert.run()                                 # doctest: +SKIP
    Z	mrconvertc             C   sN   | j  j }| jj|d< t|d s8tj| j |d< ntj|d |d< |S )Nr.   )output_specgetinputsr%   r   opabspath_gen_outfilename)selfoutputsr+   r+   r,   _list_outputs   s    zMRConvert._list_outputsc             C   s   |dkr| j  S d S d S )Nr%   )r5   )r6   namer+   r+   r,   _gen_filename   s    zMRConvert._gen_filenamec             C   s<   t | jj\}}}t| jjr(| jj}n|d | jj }|S )Nz_mrconvert.)r   r2   r$   r   r%   r)   )r6   _r9   outnamer+   r+   r,   r5      s
    
zMRConvert._gen_outfilenameN)r!   r"   r#   __doc___cmdr   
input_specr-   r0   r8   r:   r5   r+   r+   r+   r,   r/   u   s   	r/   c            	   @   s   e Zd ZeedddddddZeddd	dd
d dZeddddZej	ej
dddddddZej	ej
ddddddZeddddZejddddZejddddZdS )!DWI2TensorInputSpecT)r   z%sr   zDiffusion-weighted images)r   r   r   r   z%s_tensor.mifr$   tensorzOutput tensor filenamer   )Zname_templateZname_sourceZoutput_namer   r   r   z-grad %szEncoding file supplied as a 4xN text file with each line is in the format [ X Y Z b ], where [ X Y Z ] describe the direction of the applied gradient, and b gives the b-value in units (1000 s/mm^2). See FSL2MRTrix())r   r   r   z-ignoreslices %s zRequires two values (i.e. [34 1] for [Slice Volume] Ignores the image slices specified when computing the tensor. Slice here means the z coordinate of the slice to be ignored.)r   r   r   r   r   r   z-ignorevolumes %sznRequires two values (i.e. [2 5 6] for [Volumes] Ignores the image volumes specified when computing the tensor.)r   r   r   r   r   z-mask %szFOnly perform computation within the specified binary brain mask image.)r   r   r   z-quietz7Do not display information messages or progress status.z-debugzDisplay debugging messages.Nr   r    )r!   r"   r#   r
   r	   r$   r%   encoding_filer   r'   IntZignore_slice_by_volumeZignore_volumesmaskr*   quietdebugr+   r+   r+   r,   r@      sR   	r@   c               @   s   e Zd ZedddZdS )DWI2TensorOutputSpecTz*path/name of output diffusion tensor image)r   r   N)r!   r"   r#   r	   rA   r+   r+   r+   r,   rH      s   rH   c               @   s   e Zd ZdZdZeZeZdS )
DWI2Tensora  
    Converts diffusion-weighted images to tensor images.

    Example
    -------

    >>> import nipype.interfaces.mrtrix as mrt
    >>> dwi2tensor = mrt.DWI2Tensor()
    >>> dwi2tensor.inputs.in_file = 'dwi.mif'
    >>> dwi2tensor.inputs.encoding_file = 'encoding.txt'
    >>> dwi2tensor.cmdline
    'dwi2tensor -grad encoding.txt dwi.mif dwi_tensor.mif'
    >>> dwi2tensor.run()                                   # doctest: +SKIP
    Z
dwi2tensorN)	r!   r"   r#   r=   r>   r@   r?   rH   r0   r+   r+   r+   r,   rI      s   rI   c               @   sN   e Zd ZeddddddZedddddZejd	dd
dZejddddZ	dS )Tensor2VectorInputSpecTz%sr   zDiffusion tensor image)r   r   r   r   r   r   zOutput vector filename)r   r   r   r   z-quietz7Do not display information messages or progress status.)r   r   r   z-debugzDisplay debugging messages.Nr   r    )
r!   r"   r#   r	   r$   r%   r   r*   rF   rG   r+   r+   r+   r,   rJ     s   rJ   c               @   s   e Zd ZedddZdS )Tensor2VectorOutputSpecTzIthe output image of the major eigenvectors of the diffusion tensor image.)r   r   N)r!   r"   r#   r	   vectorr+   r+   r+   r,   rK     s   rK   c               @   s4   e Zd ZdZdZeZeZdd Z	dd Z
dd Zd	S )
Tensor2VectoraG  
    Generates a map of the major eigenvectors of the tensors in each voxel.

    Example
    -------

    >>> import nipype.interfaces.mrtrix as mrt
    >>> tensor2vector = mrt.Tensor2Vector()
    >>> tensor2vector.inputs.in_file = 'dwi_tensor.mif'
    >>> tensor2vector.run()                             # doctest: +SKIP
    Ztensor2vectorc             C   sN   | j  j }| jj|d< t|d s8tj| j |d< ntj|d |d< |S )NrL   )r0   r1   r2   r%   r   r3   r4   r5   )r6   r7   r+   r+   r,   r8   -  s    zTensor2Vector._list_outputsc             C   s   |dkr| j  S d S d S )Nr%   )r5   )r6   r9   r+   r+   r,   r:   6  s    zTensor2Vector._gen_filenamec             C   s   t | jj\}}}|d S )Nz_vector.mif)r   r2   r$   )r6   r;   r9   r+   r+   r,   r5   <  s    zTensor2Vector._gen_outfilenameN)r!   r"   r#   r=   r>   rJ   r?   rK   r0   r8   r:   r5   r+   r+   r+   r,   rM     s   	rM   c               @   sN   e Zd ZeddddddZedddddZejd	dd
dZejddddZ	dS )$Tensor2FractionalAnisotropyInputSpecTz%sr   zDiffusion tensor image)r   r   r   r   r   r   z%Output Fractional Anisotropy filename)r   r   r   r   z-quietz7Do not display information messages or progress status.)r   r   r   z-debugzDisplay debugging messages.Nr   r    )
r!   r"   r#   r	   r$   r%   r   r*   rF   rG   r+   r+   r+   r,   rN   A  s    rN   c               @   s   e Zd ZedddZdS )%Tensor2FractionalAnisotropyOutputSpecTzIthe output image of the major eigenvectors of the diffusion tensor image.)r   r   N)r!   r"   r#   r	   FAr+   r+   r+   r,   rO   W  s   rO   c               @   s4   e Zd ZdZdZeZeZdd Z	dd Z
dd Zd	S )
Tensor2FractionalAnisotropyaA  
    Generates a map of the fractional anisotropy in each voxel.

    Example
    -------

    >>> import nipype.interfaces.mrtrix as mrt
    >>> tensor2FA = mrt.Tensor2FractionalAnisotropy()
    >>> tensor2FA.inputs.in_file = 'dwi_tensor.mif'
    >>> tensor2FA.run()                                 # doctest: +SKIP
    Z	tensor2FAc             C   sN   | j  j }| jj|d< t|d s8tj| j |d< ntj|d |d< |S )NrP   )r0   r1   r2   r%   r   r3   r4   r5   )r6   r7   r+   r+   r,   r8   o  s    z)Tensor2FractionalAnisotropy._list_outputsc             C   s   |dkr| j  S d S d S )Nr%   )r5   )r6   r9   r+   r+   r,   r:   x  s    z)Tensor2FractionalAnisotropy._gen_filenamec             C   s   t | jj\}}}|d S )Nz_FA.mif)r   r2   r$   )r6   r;   r9   r+   r+   r,   r5   ~  s    z,Tensor2FractionalAnisotropy._gen_outfilenameN)r!   r"   r#   r=   r>   rN   r?   rO   r0   r8   r:   r5   r+   r+   r+   r,   rQ   ^  s   	rQ   c               @   sN   e Zd ZeddddddZedddddZejd	dd
dZejddddZ	dS )!Tensor2ApparentDiffusionInputSpecTz%sr   zDiffusion tensor image)r   r   r   r   r   r   z%Output Fractional Anisotropy filename)r   r   r   r   z-quietz7Do not display information messages or progress status.)r   r   r   z-debugzDisplay debugging messages.Nr   r    )
r!   r"   r#   r	   r$   r%   r   r*   rF   rG   r+   r+   r+   r,   rR     s    rR   c               @   s   e Zd ZedddZdS )"Tensor2ApparentDiffusionOutputSpecTzIthe output image of the major eigenvectors of the diffusion tensor image.)r   r   N)r!   r"   r#   r	   ADCr+   r+   r+   r,   rS     s   rS   c               @   s4   e Zd ZdZdZeZeZdd Z	dd Z
dd Zd	S )
Tensor2ApparentDiffusionaN  
    Generates a map of the apparent diffusion coefficient (ADC) in each voxel

    Example
    -------

    >>> import nipype.interfaces.mrtrix as mrt
    >>> tensor2ADC = mrt.Tensor2ApparentDiffusion()
    >>> tensor2ADC.inputs.in_file = 'dwi_tensor.mif'
    >>> tensor2ADC.run()                                # doctest: +SKIP
    Z
tensor2ADCc             C   sN   | j  j }| jj|d< t|d s8tj| j |d< ntj|d |d< |S )NrT   )r0   r1   r2   r%   r   r3   r4   r5   )r6   r7   r+   r+   r,   r8     s    z&Tensor2ApparentDiffusion._list_outputsc             C   s   |dkr| j  S d S d S )Nr%   )r5   )r6   r9   r+   r+   r,   r:     s    z&Tensor2ApparentDiffusion._gen_filenamec             C   s   t | jj\}}}|d S )Nz_ADC.mif)r   r2   r$   )r6   r;   r9   r+   r+   r,   r5     s    z)Tensor2ApparentDiffusion._gen_outfilenameN)r!   r"   r#   r=   r>   rR   r?   rS   r0   r8   r:   r5   r+   r+   r+   r,   rU     s   	rU   c               @   sT   e Zd ZeedddddddZeddddd	Zejd
dddZ	ejddddZ
dS )MRMultiplyInputSpecT)r   z%sr   zInput images to be multiplied)r   r   r   r   r   zOutput image filename)r   r   r   r   z-quietz7Do not display information messages or progress status.)r   r   r   z-debugzDisplay debugging messages.Nr   r    )r!   r"   r#   r
   r	   in_filesr%   r   r*   rF   rG   r+   r+   r+   r,   rV     s   rV   c               @   s   e Zd ZedddZdS )MRMultiplyOutputSpecTz&the output image of the multiplication)r   r   N)r!   r"   r#   r	   out_filer+   r+   r+   r,   rX     s   rX   c               @   s4   e Zd ZdZdZeZeZdd Z	dd Z
dd Zd	S )

MRMultiplya  
    Multiplies two images.

    Example
    -------

    >>> import nipype.interfaces.mrtrix as mrt
    >>> MRmult = mrt.MRMultiply()
    >>> MRmult.inputs.in_files = ['dwi.mif', 'dwi_WMProb.mif']
    >>> MRmult.run()                                             # doctest: +SKIP
    Zmrmultc             C   sN   | j  j }| jj|d< t|d s8tj| j |d< ntj|d |d< |S )NrY   )r0   r1   r2   r%   r   r3   r4   r5   )r6   r7   r+   r+   r,   r8     s    zMRMultiply._list_outputsc             C   s   |dkr| j  S d S d S )Nr%   )r5   )r6   r9   r+   r+   r,   r:     s    zMRMultiply._gen_filenamec             C   s   t | jjd \}}}|d S )Nr   z_MRMult.mif)r   r2   rW   )r6   r;   r9   r+   r+   r,   r5     s    zMRMultiply._gen_outfilenameN)r!   r"   r#   r=   r>   rV   r?   rX   r0   r8   r:   r5   r+   r+   r+   r,   rZ     s   	rZ   c               @   sD   e Zd ZeedddddddZejddd	d
Zejdddd
Z	dS )MRTrixViewerInputSpecT)r   z%sr   zInput images to be viewed)r   r   r   r   z-quietr   z7Do not display information messages or progress status.)r   r   r   z-debugzDisplay debugging messages.Nr   )
r!   r"   r#   r
   r	   rW   r   r*   rF   rG   r+   r+   r+   r,   r[     s   r[   c               @   s   e Zd ZdS )MRTrixViewerOutputSpecN)r!   r"   r#   r+   r+   r+   r,   r\     s   r\   c               @   s$   e Zd ZdZdZeZeZdd Z	dS )MRTrixViewera  
    Loads the input images in the MRTrix Viewer.

    Example
    -------

    >>> import nipype.interfaces.mrtrix as mrt
    >>> MRview = mrt.MRTrixViewer()
    >>> MRview.inputs.in_files = 'dwi.mif'
    >>> MRview.run()                                    # doctest: +SKIP
    Zmrviewc             C   s   d S )Nr+   )r6   r+   r+   r,   r8   &  s    zMRTrixViewer._list_outputsN)
r!   r"   r#   r=   r>   r[   r?   r\   r0   r8   r+   r+   r+   r,   r]     s
   r]   c               @   s   e Zd ZeddddddZdS )MRTrixInfoInputSpecTz%sr   zInput images to be read)r   r   r   r   r   Nr   )r!   r"   r#   r	   r$   r+   r+   r+   r,   r^   *  s   r^   c               @   s   e Zd ZdS )MRTrixInfoOutputSpecN)r!   r"   r#   r+   r+   r+   r,   r_   4  s   r_   c               @   s$   e Zd ZdZdZeZeZdd Z	dS )
MRTrixInfoa,  
    Prints out relevant header information found in the image specified.

    Example
    -------

    >>> import nipype.interfaces.mrtrix as mrt
    >>> MRinfo = mrt.MRTrixInfo()
    >>> MRinfo.inputs.in_file = 'dwi.mif'
    >>> MRinfo.run()                                    # doctest: +SKIP
    Zmrinfoc             C   s   d S )Nr+   )r6   r+   r+   r,   r8   I  s    zMRTrixInfo._list_outputsN)
r!   r"   r#   r=   r>   r^   r?   r_   r0   r8   r+   r+   r+   r,   r`   8  s
   r`   c               @   s`   e Zd ZeddddddZeddddddZedddd	d
ZeddddddZej	dddZ
dS ) GenerateWhiteMatterMaskInputSpecTz%sr   zDiffusion-weighted images)r   r   r   r   r   r   zBinary brain maskr   z$Output WM probability image filename)r   r   r   r   z-grad %szGradient encoding, supplied as a 4xN text file with each line is in the format [ X Y Z b ], where [ X Y Z ] describe the direction of the applied gradient, and b gives the b-value in units (1000 s/mm^2). See FSL2MRTrixz
-margin %szqSpecify the width of the margin on either side of the image to be used to estimate the noise level (default = 10))r   r   Nr   r    )r!   r"   r#   r	   r$   Zbinary_maskout_WMProb_filenamerC   r   r(   Znoise_level_marginr+   r+   r+   r,   ra   M  s,   ra   c               @   s   e Zd ZedddZdS )!GenerateWhiteMatterMaskOutputSpecTWMprobabilitymap)r   r   N)r!   r"   r#   r	   re   r+   r+   r+   r,   rd   k  s   rd   c               @   s4   e Zd ZdZdZeZeZdd Z	dd Z
dd Zd	S )
GenerateWhiteMatterMaskad  
    Generates a white matter probability mask from the DW images.

    Example
    -------

    >>> import nipype.interfaces.mrtrix as mrt
    >>> genWM = mrt.GenerateWhiteMatterMask()
    >>> genWM.inputs.in_file = 'dwi.mif'
    >>> genWM.inputs.encoding_file = 'encoding.txt'
    >>> genWM.run()                                     # doctest: +SKIP
    Zgen_WM_maskc             C   s"   | j  j }tj| j |d< |S )Nre   )r0   r1   r3   r4   r5   )r6   r7   r+   r+   r,   r8     s    z%GenerateWhiteMatterMask._list_outputsc             C   s   |dkr| j  S d S d S )Nrc   )r5   )r6   r9   r+   r+   r,   r:     s    z%GenerateWhiteMatterMask._gen_filenamec             C   s   t | jj\}}}|d S )Nz_WMProb.mif)r   r2   r$   )r6   r;   r9   r+   r+   r,   r5     s    z(GenerateWhiteMatterMask._gen_outfilenameN)r!   r"   r#   r=   r>   ra   r?   rd   r0   r8   r:   r5   r+   r+   r+   r,   rf   o  s   rf   c               @   sl   e Zd ZeddddddZedddddZej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dS )ErodeInputSpecTz%sr   zInput mask image to be eroded)r   r   r   r   r   r   zOutput image filename)r   r   r   r   z	-npass %sz!the number of passes (default: 1))r   r   z-dilatez$Perform dilation rather than erosion)r   r   r   z-quietz7Do not display information messages or progress status.z-debugzDisplay debugging messages.Nr   r    )r!   r"   r#   r	   r$   r%   r   rD   Znumber_of_passesr*   ZdilaterF   rG   r+   r+   r+   r,   rg     s"   
rg   c               @   s   e Zd ZedddZdS )ErodeOutputSpecTzthe output image)r   r   N)r!   r"   r#   r	   rY   r+   r+   r+   r,   rh     s   rh   c               @   s4   e Zd ZdZdZeZeZdd Z	dd Z
dd Zd	S )
Erodea  
    Erode (or dilates) a mask (i.e. binary) image

    Example
    -------

    >>> import nipype.interfaces.mrtrix as mrt
    >>> erode = mrt.Erode()
    >>> erode.inputs.in_file = 'mask.mif'
    >>> erode.run()                                     # doctest: +SKIP
    Zerodec             C   sN   | j  j }| jj|d< t|d s8tj| j |d< ntj|d |d< |S )NrY   )r0   r1   r2   r%   r   r3   r4   r5   )r6   r7   r+   r+   r,   r8     s    zErode._list_outputsc             C   s   |dkr| j  S d S d S )Nr%   )r5   )r6   r9   r+   r+   r,   r:     s    zErode._gen_filenamec             C   s   t | jj\}}}|d S )Nz
_erode.mif)r   r2   r$   )r6   r;   r9   r+   r+   r,   r5     s    zErode._gen_outfilenameN)r!   r"   r#   r=   r>   rg   r?   rh   r0   r8   r:   r5   r+   r+   r+   r,   ri     s   	ri   c               @   s   e Zd ZeddddddZedddddZejd	d
dZej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ZdS )ThresholdInputSpecTz%sr   z!The input image to be thresholded)r   r   r   r   r   r   zThe output binary image mask.)r   r   r   r   z-abs %sz.Specify threshold value as absolute intensity.)r   r   z-percent %szQSpecify threshold value as a percentage of the peak intensity in the input image.z-invertzInvert output binary mask)r   r   r   z-nanz Replace all zero values with NaNz-quietz7Do not display information messages or progress status.z-debugzDisplay debugging messages.Nr   r    )r!   r"   r#   r	   r$   r%   r   r(   Zabsolute_threshold_valueZpercentage_threshold_valuer*   invertZreplace_zeros_with_NaNrF   rG   r+   r+   r+   r,   rj     s*   
rj   c               @   s   e Zd ZedddZdS )ThresholdOutputSpecTzThe output binary image mask.)r   r   N)r!   r"   r#   r	   rY   r+   r+   r+   r,   rl     s   rl   c               @   s4   e Zd ZdZdZeZeZdd Z	dd Z
dd Zd	S )
	Thresholda'  
    Create bitwise image by thresholding image intensity.

    By default, the threshold level is determined using a histogram analysis
    to cut out the background. Otherwise, the threshold intensity can be
    specified using command line options.
    Note that only the first study is used for thresholding.

    Example
    -------

    >>> import nipype.interfaces.mrtrix as mrt
    >>> thresh = mrt.Threshold()
    >>> thresh.inputs.in_file = 'wm_mask.mif'
    >>> thresh.run()                                             # doctest: +SKIP
    	thresholdc             C   sN   | j  j }| jj|d< t|d s8tj| j |d< ntj|d |d< |S )NrY   )r0   r1   r2   r%   r   r3   r4   r5   )r6   r7   r+   r+   r,   r8     s    zThreshold._list_outputsc             C   s   |dkr| j  S d S d S )Nr%   )r5   )r6   r9   r+   r+   r,   r:     s    zThreshold._gen_filenamec             C   s   t | jj\}}}|d S )Nz_thresh.mif)r   r2   r$   )r6   r;   r9   r+   r+   r,   r5     s    zThreshold._gen_outfilenameN)r!   r"   r#   r=   r>   rj   r?   rl   r0   r8   r:   r5   r+   r+   r+   r,   rm     s   	rm   c               @   sN   e Zd ZeddddddZedddddZejd	dd
dZejddddZ	dS )MedianFilter3DInputSpecTz%sr   zInput images to be smoothed)r   r   r   r   r   r   zOutput image filename)r   r   r   r   z-quietz7Do not display information messages or progress status.)r   r   r   z-debugzDisplay debugging messages.Nr   r    )
r!   r"   r#   r	   r$   r%   r   r*   rF   rG   r+   r+   r+   r,   ro     s   ro   c               @   s   e Zd ZedddZdS )MedianFilter3DOutputSpecTzthe output image)r   r   N)r!   r"   r#   r	   rY   r+   r+   r+   r,   rp   2  s   rp   c               @   s4   e Zd ZdZdZeZeZdd Z	dd Z
dd Zd	S )
MedianFilter3Da  
    Smooth images using a 3x3x3 median filter.

    Example
    -------

    >>> import nipype.interfaces.mrtrix as mrt
    >>> median3d = mrt.MedianFilter3D()
    >>> median3d.inputs.in_file = 'mask.mif'
    >>> median3d.run()                                  # doctest: +SKIP
    Zmedian3Dc             C   sN   | j  j }| jj|d< t|d s8tj| j |d< ntj|d |d< |S )NrY   )r0   r1   r2   r%   r   r3   r4   r5   )r6   r7   r+   r+   r,   r8   G  s    zMedianFilter3D._list_outputsc             C   s   |dkr| j  S d S d S )Nr%   )r5   )r6   r9   r+   r+   r,   r:   P  s    zMedianFilter3D._gen_filenamec             C   s   t | jj\}}}|d S )Nz_median3D.mif)r   r2   r$   )r6   r;   r9   r+   r+   r,   r5   V  s    zMedianFilter3D._gen_outfilenameN)r!   r"   r#   r=   r>   ro   r?   rp   r0   r8   r:   r5   r+   r+   r+   r,   rq   6  s   	rq   c               @   s   e Zd ZeedddddddZeddd dd	Zejd
dddZ	edddddZ
ejddd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ddddZejddddZejddddZdS )!MRTransformInputSpecT)r   z%sr   zInput images to be transformed)r   r   r   r   r   zOutput image)r   r   r   r   z-inversez.Invert the specified transform before using it)r   r   r   z
-linear %sa  Specify a linear transform to apply, in the form of a 3x4 or 4x4 ascii file. Note the standard reverse convention is used, where the transform maps points in the template image to the moving image. Note that the reverse convention is still assumed even if no -template image is supplied.)r   r   r   r   z-replacezareplace the current transform by that specified, rather than applying it to the current transformz-transform %sz8The transform to apply, in the form of a 4x4 ascii file.z-template %sz>Reslice the input image to match the specified template image.z-reference %szin case the transform supplied maps from the input image onto a reference image, use this option to specify the reference. Note that this implicitly sets the -replace option.z-flipxa+  assume the transform is supplied assuming a coordinate system with the x-axis reversed relative to the MRtrix convention (i.e. x increases from right to left). This is required to handle transform matrices produced by FSL's FLIRT command. This is only used in conjunction with the -reference option.z-quietz7Do not display information messages or progress status.z-debugzDisplay debugging messages.Nr   r    )r!   r"   r#   r
   r	   rW   r%   r   r*   rk   Zlinear_transformZreplace_transformZtransformation_fileZtemplate_imageZreference_imageZflip_xrF   rG   r+   r+   r+   r,   rr   [  sX   rr   c               @   s   e Zd ZedddZdS )MRTransformOutputSpecTz&the output image of the transformation)r   r   N)r!   r"   r#   r	   rY   r+   r+   r+   r,   rs     s   rs   c               @   s4   e Zd ZdZdZeZeZdd Z	dd Z
dd Zd	S )
MRTransformz
    Apply spatial transformations or reslice images

    Example
    -------

    >>> MRxform = MRTransform()
    >>> MRxform.inputs.in_files = 'anat_coreg.mif'
    >>> MRxform.run()                                   # doctest: +SKIP
    Zmrtransformc             C   sN   | j  j }| jj|d< t|d s8tj| j |d< ntj|d |d< |S )NrY   )r0   r1   r2   r%   r   r3   r4   r5   )r6   r7   r+   r+   r,   r8     s    zMRTransform._list_outputsc             C   s   |dkr| j  S d S d S )Nr%   )r5   )r6   r9   r+   r+   r,   r:     s    zMRTransform._gen_filenamec             C   s   t | jjd \}}}|d S )Nr   z_MRTransform.mif)r   r2   rW   )r6   r;   r9   r+   r+   r,   r5     s    zMRTransform._gen_outfilenameN)r!   r"   r#   r=   r>   rr   r?   rs   r0   r8   r:   r5   r+   r+   r+   r,   rt     s   
	rt   )4os.pathpathr3   Zutils.filemanipr   baser   r   r   r   r	   r
   r   r   r-   r/   r@   rH   rI   rJ   rK   rM   rN   rO   rQ   rR   rS   rU   rV   rX   rZ   r[   r\   r]   r^   r_   r`   ra   rd   rf   rg   rh   ri   rj   rl   rm   ro   rp   rq   rr   rs   rt   r+   r+   r+   r,   <module>   sR   
$^/E%%%%
"%*%=