3
d                 @   sh   d Z ddlmZmZmZmZ ddlmZ ddlmZ G dd deZ	G dd	 d	eZ
G d
d deZdS )zX
The QT1 module of niftyfit, which wraps the Multi-Echo T1 fitting methods
in NiftyFit.
   )TraitedSpecFiletraitsCommandLineInputSpec   )NiftyFitCommand)get_custom_pathc               @   sX  e Zd ZdZdZeddedddZedgdd	d
dZedgddddZdZedgddedZ	edgddddZ
dZedgddedZedgddddZedg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d,Zejed-d.d/Zd0Zejejejed1d2d(Zd3Zejed4d5d(Zejd6d7d8d(Zejejejejd9d:d;d(Zejd<d=d>d(Zejd?d@dAd(ZejdBdCdDd(ZejejdEdFdGdHdIZ eddJdKdLZ!eddMdNdLZ"ejdOdPdQZ#ejdRdSdQZ$ejdTdUdQZ%ejejdVdWdHdXZ&dYZeddZedLZ'd[Zedd\edLZ(edd]d^d_Z)ejd`dadQZ*ejdbdcdQZ+ejdddedQZ,dfS )gFitQt1InputSpeczInput Spec for FitQt1.z.Filename of the 4D Multi-Echo T1 source image.r   Tz
-source %s)positionexistsdescargstr	mandatorysource_filez%s_t1map.nii.gzz	-t1map %sz0Filename of the estimated output T1 map (in ms).)Zname_sourceZname_templater   r   z%s_m0map.nii.gzz	-m0map %sz'Filename of the estimated input M0 map.z5Filename of the estimated output multi-parameter map.z%s_mcmap.nii.gzz	-mcmap %sz%s_comp.nii.gzz-comp %sz1Filename of the estimated multi-component T1 map.z=Filename of the error map (symmetric matrix, [Diag,OffDiag]).z%s_error.nii.gzz	-error %sz%s_syn.nii.gzz-syn %sz#Filename of the synthetic ASL data.z%s_res.nii.gzz-res %sz#Filename of the model fit residualsr   zFilename of image mask.z-mask %s)r
   r   r   r      zFilename of parameter prior.z	-prior %szTE Echo Time [0ms!].z-TE %f   )r   r   r
   zTR Repetition Time [10s!].z-TR %f   z6Number of components to fit [1] (currently IR/SR only)   z-nc %d)r   r
   r   z;Set LM parameters (initial value, decrease rate) [100,1.2].z	-lm %f %f   z1Use Gauss-Newton algorithm [Levenberg-Marquardt].z-gn   zFit to single slice number.z	-slice %d	   zFit to single voxel only.z-voxel %d %d %d
   zNLSQR iterations [100].z	-maxit %d   z&Saturation Recovery fitting [default].z-SR   z%Inversion Recovery fitting [default].z-IR      z'Inversion times for T1 data [1s,2s,5s].z-TIs %s )r
   r   r   sepz
-TIlist %sz$Filename of list of pre-defined TIs.)r   r   r   z
-T1list %sz#Filename of list of pre-defined T1sz Minimum tissue T1 value [400ms].z	-T1min %f)r   r   z!Maximum tissue T1 value [4000ms].z	-T1max %fzSpoiled Gradient Echo fittingz-SPGRzFlip anglesz	-flips %s)r   r   r   z2Filename of list of pre-defined flip angles (deg).z-fliplist %sz:Filename of B1 estimate for fitting (or include in prior).z	-b1map %sz(Filename of mc samples (ascii text file)z	-mcout %s)r   r   r   z Number of samples to keep [100].z-mcsamples %dz%Number of iterations to run [10,000].z-mcmaxit %dz(Fraction of iterations to accept [0.23].z-acceptance %fN)-__name__
__module____qualname____doc__r   r   r   
t1map_file
m0map_file
mcmap_file	comp_file
error_filesyn_fileres_filemaskZpriorr   ZFloatZte_valueZtr_valueZIntZnb_compTupleZlm_valZBoolZgn_flagZslice_noZvoxelZmaxitZsr_flagZir_flagListZtisZtis_listZt1_listZt1minZt1maxZspgrZflipsZ
flips_listZb1mapZmcoutZ	mcsamplesZmcmaxitZ
acceptance r,   r,   @/tmp/pip-build-7vycvbft/nipype/nipype/interfaces/niftyfit/qt1.pyr	      s   

r	   c               @   s^   e Zd ZdZeddZeddZdZeedZeddZ	dZeedZ
eddZed	dZd
S )FitQt1OutputSpeczOutput Spec for FitQt1.z/Filename of the estimated output T1 map (in ms))r   zFilename of the m0 mapz4Filename of the estimated output multi-parameter mapz1Filename of the estimated multi-component T1 map.z<Filename of the error map (symmetric matrix, [Diag,OffDiag])z"Filename of the synthetic ASL dataz#Filename of the model fit residualsN)r   r   r    r!   r   r"   r#   r   r$   r%   r&   r'   r(   r,   r,   r,   r-   r.      s   





r.   c               @   s(   e Zd ZdZedddZeZeZ	dZ
dS )FitQt1a  Interface for executable fit_qt1 from Niftyfit platform.

    Use NiftyFit to perform Qt1 fitting.

    T1 Fitting Routine (To inversion recovery or spgr data).
    Fits single component T1 maps in the first instance.

    `Source code <https://cmiclab.cs.ucl.ac.uk/CMIC/NiftyFit-Release>`_

    Examples
    --------

    >>> from nipype.interfaces.niftyfit import FitQt1
    >>> fit_qt1 = FitQt1()
    >>> fit_qt1.inputs.source_file = 'TI4D.nii.gz'
    >>> fit_qt1.cmdline
    'fit_qt1 -source TI4D.nii.gz -comp TI4D_comp.nii.gz -error TI4D_error.nii.gz -m0map TI4D_m0map.nii.gz -mcmap TI4D_mcmap.nii.gz -res TI4D_res.nii.gz -syn TI4D_syn.nii.gz -t1map TI4D_t1map.nii.gz'

    Zfit_qt1ZNIFTYFITDIR)Zenv_dirZ_fit_qt1N)r   r   r    r!   r   Z_cmdr	   Z
input_specr.   Zoutput_spec_suffixr,   r,   r,   r-   r/      s
   r/   N)r!   baser   r   r   r   r   Zniftyreg.baser   r	   r.   r/   r,   r,   r,   r-   <module>   s    