3
d !                 @   s   d dl jZddlmZmZmZmZmZ ddl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dS )    N   )traitsTraitedSpecFileInputMultiObject	isdefined   )MRTrix3BaseInputSpecMRTrix3Basec               @   sr   e Zd ZeddddddZeddddddd	Zedd
ddZejdddddddZ	ej
ddddZedddZdS )FitTensorInputSpecTz%sr   zinput diffusion weighted images)existsargstr	mandatorypositiondesczdti.mifr   z!the output diffusion tensor image)r   r   r   
usedefaultr   z-mask %szEonly perform computation within the specified binary brain mask image)r   r   r   Z	nonlinearZ	loglinearZsechZricianz
-method %sz)select method used to perform the fitting)r   r   z-regularisation %fz0.3.13zspecify the strength of the regularisation term on the magnitude of the tensor elements (default = 5000). This only applies to the non-linear methods)r   Zmax_verr   z-predicted_signal %szvspecify a file to contain the predicted signal from the tensor fits. This can be used to calculate the residual signalN)__name__
__module____qualname__r   in_fileout_fileZin_maskr   EnummethodFloatZreg_termpredicted_signal r   r   C/tmp/pip-build-7vycvbft/nipype/nipype/interfaces/mrtrix3/reconst.pyr      s>   r   c               @   s"   e Zd ZedddZeddZdS )FitTensorOutputSpecTzthe output DTI file)r   r   z$Predicted signal from fitted tensors)r   N)r   r   r   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 )	FitTensora  
    Convert diffusion-weighted images to tensor images


    Example
    -------

    >>> import nipype.interfaces.mrtrix3 as mrt
    >>> tsr = mrt.FitTensor()
    >>> tsr.inputs.in_file = 'dwi.mif'
    >>> tsr.inputs.in_mask = 'mask.nii.gz'
    >>> tsr.inputs.grad_fsl = ('bvecs', 'bvals')
    >>> tsr.cmdline                               # doctest: +ELLIPSIS
    'dwi2tensor -fslgrad bvecs bvals -mask mask.nii.gz dwi.mif dti.mif'
    >>> tsr.run()                                 # doctest: +SKIP
    Z
dwi2tensorc             C   s@   | j  j }tj| jj|d< t| jjr<tj| jj|d< |S )Nr   r   )output_specgetopabspathinputsr   r   r   )selfoutputsr   r   r   _list_outputsY   s
    zFitTensor._list_outputsN)
r   r   r   __doc___cmdr   
input_specr   r!   r(   r   r   r   r   r    C   s
   r    c               @   s   e Zd Zejd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d0ddddZ	edd1ddZ
edddd2ddZedd3ddZedddd4ddZeddddZejejd d!d"d#Zeejdgdd$d d%d&Zedd'd(dZed)d*d+Zd,S )5EstimateFODInputSpeccsdmsmt_csdz%s   TzFOD algorithm)r   r   r   r      zinput DWI image)r   r   r   r   r      zWM response text filezwm.mif   zoutput WM ODF)r   r   r   r   r      zGM response text file)r   r   r   zgm.mif   zoutput GM ODF)r   r   r   r   r   zCSF response text filezcsf.mifr   zoutput CSF ODFz-mask %sz
mask image)r   r   r   ,z	-shell %sz&specify one or more dw gradient shells)sepr   r   z-lmax %sztmaximum harmonic degree of response function - single value for single-shell response, list for multi-shell response)valuer   r   r6   r   z-directions %szspecify the directions over which to apply the non-negativity constraint (by default, the built-in 300 direction set is used). These should be supplied as a text file containing the [ az el ] pairs for the directions.z-predicted_signal %sa  specify a file to contain the predicted signal from the FOD estimates. This can be used to calculate the residual signal.Note that this is only valid if algorithm == 'msmt_csd'. For single shell reconstructions use a combination of SHConv and SH2Amp instead.)r   r   Niiir   r   )r   r   r   r   r   	algorithmr   r   Zwm_txtwm_odfZgm_txtgm_odfZcsf_txtcsf_odfZ	mask_fileListr   shellr   Intmax_shZin_dirsr   r   r   r   r   r,   a   sX   r,   c               @   s:   e Zd ZedddZedddZedddZeddZdS )	EstimateFODOutputSpecz%szoutput WM ODF)r   r   zoutput GM ODFzoutput CSF ODFzoutput predicted signal)r   N)r   r   r   r   r<   r=   r>   r   r   r   r   r   rC      s   rC   c               @   s$   e Zd ZdZdZeZeZdd Z	dS )EstimateFODa  
    Estimate fibre orientation distributions from diffusion data using spherical deconvolution

    .. warning::

       The CSD algorithm does not work as intended, but fixing it in this interface could break
       existing workflows. This interface has been superseded by
       :py:class:`.ConstrainedSphericalDecomposition`.

    Example
    -------

    >>> import nipype.interfaces.mrtrix3 as mrt
    >>> fod = mrt.EstimateFOD()
    >>> fod.inputs.algorithm = 'msmt_csd'
    >>> fod.inputs.in_file = 'dwi.mif'
    >>> fod.inputs.wm_txt = 'wm.txt'
    >>> fod.inputs.grad_fsl = ('bvecs', 'bvals')
    >>> fod.cmdline
    'dwi2fod -fslgrad bvecs bvals -lmax 8 msmt_csd dwi.mif wm.txt wm.mif gm.mif csf.mif'
    >>> fod.run()  # doctest: +SKIP
    Zdwi2fodc             C   s   | j  j }tj| jj|d< t| jjr<tj| jj|d< t| jjrZtj| jj|d< t| jj	r| jj
dkrztdtj| jj	|d< |S )Nr<   r=   r>   r.   zH'predicted_signal' option can only be used with the 'msmt_csd' algorithmr   )r!   r"   r#   r$   r%   r<   r   r=   r>   r   r;   	Exception)r&   r'   r   r   r   r(      s    zEstimateFOD._list_outputsN)
r   r   r   r)   r*   r,   r+   rC   r!   r(   r   r   r   r   rD      s
   rD   c               @   s:   e Zd ZeddddZeddddZeejddd	d
Z	dS )*ConstrainedSphericalDeconvolutionInputSpecz%sr4   zoutput GM ODF)r   r   r   r   zoutput CSF ODFz-lmax %sr5   ztmaximum harmonic degree of response function - single value for single-shell response, list for multi-shell response)r   r6   r   Nr:   r   )
r   r   r   r   r=   r>   r   r   rA   rB   r   r   r   r   rF      s   rF   c               @   s   e Zd ZdZeZdS )!ConstrainedSphericalDeconvolutionaq  
    Estimate fibre orientation distributions from diffusion data using spherical deconvolution

    This interface supersedes :py:class:`.EstimateFOD`.
    The old interface has contained a bug when using the CSD algorithm as opposed to the MSMT CSD
    algorithm, but fixing it could potentially break existing workflows. The new interface works
    the same, but does not populate the following inputs by default:

    * ``gm_odf``
    * ``csf_odf``
    * ``max_sh``

    Example
    -------

    >>> import nipype.interfaces.mrtrix3 as mrt
    >>> fod = mrt.ConstrainedSphericalDeconvolution()
    >>> fod.inputs.algorithm = 'csd'
    >>> fod.inputs.in_file = 'dwi.mif'
    >>> fod.inputs.wm_txt = 'wm.txt'
    >>> fod.inputs.grad_fsl = ('bvecs', 'bvals')
    >>> fod.cmdline
    'dwi2fod -fslgrad bvecs bvals csd dwi.mif wm.txt wm.mif'
    >>> fod.run()  # doctest: +SKIP
    N)r   r   r   r)   rF   r+   r   r   r   r   rG      s   rG   )os.pathpathr#   baser   r   r   r   r   r	   r
   r   r   r    r,   rC   rD   rF   rG   r   r   r   r   <module>   s   
3H-