3
dn                 @   sl  d Z ddlZddlm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mZ G d	d
 d
eZG dd deZG dd de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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/d0 d0eZ"G d1d2 d2eZ#G d3d4 d4eZ$G d5d6 d6eZ%G d7d8 d8eZ&G d9d: d:eZ'G d;d< d<eZ(G d=d> d>eZ)G d?d@ d@eZ*G dAdB dBeZ+G dCdD dDeZ,G dEdF dFeZ-G dGdH dHeZ.G dIdJ dJeZ/dS )KzANTs' utilities.    N)warn   )traits	isdefinedTraitedSpecFileStrInputMultiObject)CopyHeaderInterface   )ANTSCommandInputSpecANTSCommandc            S   @   s,  e Zd ZejddddddZeddd	gd
dddZejdddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYddddZd[QZ	edddedd\d]Z
ejedd^edfdd_d`Zedgddad`ZejdddbdcZddS )hImageMathInputSpec   Tr   z%dzdimension of output image)
usedefaultpositionargstrdescr   z%sop1z%s_mathszoutput image file)r   r   name_sourcename_templater   keep_extensionmZvm+zv+-zv-/^maxexpZ	addtozeroZoveraddabstotalZmeanZvtotalZDecisionZNegZProjectGZMDZMEZMOZMCZGDZGEZGOGCZExtractContoursZ	TranslateZ4DTensorTo3DTensorZExtractVectorComponentZTensorColorZTensorFAZTensorFADenominatorZTensorFANumeratorZTensorMeanDiffusionZTensorRadialDiffusionZTensorAxialDiffusionZTensorEigenvalueZTensorToVectorZTensorToVectorComponentZ
TensorMaskZByteZCorruptImageDZMaurerDistanceZExtractSliceZ	FillHolesZConvolveZFiniteZFlattenImageZGetLargestComponentZGradZRescaleImageZWindowImageZNeighborhoodStatsZReplicateDisplacementZReplicateImage
LabelStatsZ	LaplacianZCannyZ	LipschitzZMTRZ	NormalizePadImageZSigmoidImageZSharpenZUnsharpMaskZPValueImageZReplaceVoxelValueSetTimeSpacingSetTimeSpacingWarpstackZThresholdAtMeanTriPlanarViewZTruncateImageIntensityzmathematical operations)	mandatoryr   r   r   zfirst operator)existsr*   r   r   r   )r+   zsecond operator)r   r   r   z$Additional parameters to the commandzCcopy headers of the original image into the output (corrected) file)r   r   N)__name__
__module____qualname__r   Int	dimensionr   output_imageEnum	operationr   Eitherr   Zop2argsBoolcopy_header r;   r;   >/tmp/pip-build-7vycvbft/nipype/nipype/interfaces/ants/utils.pyr   	   s   r   c               @   s   e Zd ZedddZdS )ImageMathOuputSpecTzoutput image file)r+   r   N)r/   r0   r1   r   r4   r;   r;   r;   r<   r=   }   s   r=   c                   sH   e Zd ZdZd ZeZeZddiZ	dZ
 fd	d
Zdd Zdd Z  ZS )	ImageMathaK  
    Operations over images.

    Examples
    --------
    >>> ImageMath(
    ...     op1='structural.nii',
    ...     operation='+',
    ...     op2='2').cmdline
    'ImageMath 3 structural_maths.nii + structural.nii 2'

    >>> ImageMath(
    ...     op1='structural.nii',
    ...     operation='Project',
    ...     op2='1 2').cmdline
    'ImageMath 3 structural_maths.nii Project structural.nii 1 2'

    >>> ImageMath(
    ...     op1='structural.nii',
    ...     operation='G',
    ...     op2='4').cmdline
    'ImageMath 3 structural_maths.nii G structural.nii 4'

    >>> ImageMath(
    ...     op1='structural.nii',
    ...     operation='TruncateImageIntensity',
    ...     op2='0.005 0.999 256').cmdline
    'ImageMath 3 structural_maths.nii TruncateImageIntensity structural.nii 0.005 0.999 256'

    By default, Nipype copies headers from the first input image (``op1``)
    to the output image.
    For some operations, as the ``PadImage`` operation, the header cannot be copied from inputs to
    outputs, and so ``copy_header`` option is automatically set to ``False``.

    >>> pad = ImageMath(
    ...     op1='structural.nii',
    ...     operation='PadImage')
    >>> pad.inputs.copy_header
    False

    While the operation is set to ``PadImage``,
    setting ``copy_header = True`` will have no effect.

    >>> pad.inputs.copy_header = True
    >>> pad.inputs.copy_header
    False

    For any other operation, ``copy_header`` can be enabled/disabled normally:

    >>> pad.inputs.operation = "ME"
    >>> pad.inputs.copy_header = True
    >>> pad.inputs.copy_header
    True

    r4   r   r%   r$   r&   r'   r)   c                sL   t t| jf | | jj| jkr(d| j_| jj| jd | jj| j	d d S )NFr6   r:   )
superr>   __init__inputsr6   _no_copy_header_operationr:   Zon_trait_change_operation_update_copyheader_update)selfrA   )	__class__r;   r<   r@      s
    zImageMath.__init__c             C   s   | j j| jkrd| j _d S )NF)rA   r6   rB   r:   )rE   r;   r;   r<   rC      s    zImageMath._operation_updatec             C   s6   | j jr2| j j| jkr2td| j j d d| j _d S )Nz+copy_header cannot be updated to True with z as operation.F)rA   r:   r6   rB   r   )rE   r;   r;   r<   rD      s
    zImageMath._copyheader_update)r%   r$   r&   r'   r)   )r/   r0   r1   __doc___cmdr   
input_specr=   output_spec_copy_header_maprB   r@   rC   rD   __classcell__r;   r;   )rF   r<   r>      s   7    r>   c            	   @   s   e Zd ZejddddddZeddddd	d
ZedddgddddZej	ej
ejdddejejejejejejejdddddZejdddddZejdddgddZejddddgdZdS ) ResampleImageBySpacingInputSpecr   Tr   z%dzdimension of output image)r   r   r   r   r   z%szinput image file)r+   r*   r   r   r   input_imagez%s_resampledzoutput image file)r   r   r   r   r   r   )Zminlenmaxlen   zoutput spacing)r   r   r*   r   F   zsmooth before resampling)r   r   r      apply_smoothingz$addvox pads each dimension by addvox)r   r   requiresr   znn interpolationaddvox)r   r   r   rT   Nr.   )r/   r0   r1   r   r2   r3   r   rN   r4   r7   ListFloatTupleout_spacingr9   rS   rU   Z	nn_interpr;   r;   r;   r<   rM      s8   rM   c               @   s   e Zd ZedddZdS ) ResampleImageBySpacingOutputSpecTzresampled file)r+   r   N)r/   r0   r1   r   r4   r;   r;   r;   r<   rZ     s   rZ   c                   s,   e Zd ZdZd ZeZeZ fddZ	  Z
S )ResampleImageBySpacinga~  
    Resample an image with a given spacing.

    Examples
    --------
    >>> res = ResampleImageBySpacing(dimension=3)
    >>> res.inputs.input_image = 'structural.nii'
    >>> res.inputs.output_image = 'output.nii.gz'
    >>> res.inputs.out_spacing = (4, 4, 4)
    >>> res.cmdline  #doctest: +ELLIPSIS
    'ResampleImageBySpacing 3 structural.nii output.nii.gz 4 4 4'

    >>> res = ResampleImageBySpacing(dimension=3)
    >>> res.inputs.input_image = 'structural.nii'
    >>> res.inputs.output_image = 'output.nii.gz'
    >>> res.inputs.out_spacing = (4, 4, 4)
    >>> res.inputs.apply_smoothing = True
    >>> res.cmdline  #doctest: +ELLIPSIS
    'ResampleImageBySpacing 3 structural.nii output.nii.gz 4 4 4 1'

    >>> res = ResampleImageBySpacing(dimension=3)
    >>> res.inputs.input_image = 'structural.nii'
    >>> res.inputs.output_image = 'output.nii.gz'
    >>> res.inputs.out_spacing = (0.4, 0.4, 0.4)
    >>> res.inputs.apply_smoothing = True
    >>> res.inputs.addvox = 2
    >>> res.inputs.nn_interp = False
    >>> res.cmdline  #doctest: +ELLIPSIS
    'ResampleImageBySpacing 3 structural.nii output.nii.gz 0.4 0.4 0.4 1 2 0'

    c                sH   |dkr4t || jjkr tddjdd |D }tt| j|||S )NrY   z-out_spacing dimensions should match dimension c             S   s   g | ]}d | qS )z%gr;   ).0dr;   r;   r<   
<listcomp>1  s    z6ResampleImageBySpacing._format_arg.<locals>.<listcomp>)lenrA   r3   
ValueErrorjoinr?   r[   _format_arg)rE   nameZ
trait_specvalue)rF   r;   r<   rc   ,  s
    z"ResampleImageBySpacing._format_arg)r/   r0   r1   rG   rH   rM   rI   rZ   rJ   rc   rL   r;   r;   )rF   r<   r[     s
   r[   c            	   @   s   e Zd ZejddddddZeddddd	d
ZedddgddddZej	dddddgddgddZ
ejddddZeddgdddZejdddgddZejdddgd dZejdd!ddgd"d#Zejd$d%ddgd&d#Zejdddd'd(Zd)S )*ThresholdImageInputSpecr   Tr   z%dzdimension of output image)r   r   r   r   r   z%szinput image file)r+   r*   r   r   r   rN   z%s_resampledzoutput image file)r   r   r   r   r   r   ZOtsuZKmeansrP   num_thresholdsth_lowth_highz)whether to run Otsu / Kmeans thresholding)r   r   rT   xorr   rQ   znumber of thresholds)r   r   r   zinput mask for Otsu, Kmeans)r+   rT   r   r   z%fmodezlower threshold)r   r   rj   r   zupper thresholdrR   zinside value)r   r   rT   r   r      zoutside valuezCcopy headers of the original image into the output (corrected) file)r*   r   r   N)r/   r0   r1   r   r2   r3   r   rN   r4   r5   rk   rg   Z
input_maskrW   rh   ri   Zinside_valueZoutside_valuer9   r:   r;   r;   r;   r<   rf   6  sJ   rf   c               @   s   e Zd ZedddZdS )ThresholdImageOutputSpecTzresampled file)r+   r   N)r/   r0   r1   r   r4   r;   r;   r;   r<   rm   i  s   rm   c               @   s$   e Zd ZdZd ZeZeZddiZ	dS )ThresholdImagea8  
    Apply thresholds on images.

    Examples
    --------
    >>> thres = ThresholdImage(dimension=3)
    >>> thres.inputs.input_image = 'structural.nii'
    >>> thres.inputs.output_image = 'output.nii.gz'
    >>> thres.inputs.th_low = 0.5
    >>> thres.inputs.th_high = 1.0
    >>> thres.inputs.inside_value = 1.0
    >>> thres.inputs.outside_value = 0.0
    >>> thres.cmdline  #doctest: +ELLIPSIS
    'ThresholdImage 3 structural.nii output.nii.gz 0.500000 1.000000 1.000000 0.000000'

    >>> thres = ThresholdImage(dimension=3)
    >>> thres.inputs.input_image = 'structural.nii'
    >>> thres.inputs.output_image = 'output.nii.gz'
    >>> thres.inputs.mode = 'Kmeans'
    >>> thres.inputs.num_thresholds = 4
    >>> thres.cmdline  #doctest: +ELLIPSIS
    'ThresholdImage 3 structural.nii output.nii.gz Kmeans 4'

    r4   rN   N)
r/   r0   r1   rG   rH   rf   rI   rm   rJ   rK   r;   r;   r;   r<   rn   m  s
   rn   c               @   s  e Zd ZejddddddZejdddd	dZeddd
dZ	eddddZ
eddddZeddgddZejdddejdejdddejddddfZejedddd Zejejd!d"d#ejd$ddd%d&dd'd(Zejddd)d*gd+d,Zejejd-ejd.ddddd/d0dZejejejejejejejejejejejejd1d2d3d4Zejejd5d6d7d8ejd9ejd5d:d7d8dd;d<dZed=dd>d?dZd@S )AAIInputSpecr   r   Tz-d %dzdimension of output image)r   r   r   Fz-v %dzenable verbosityz5Image to which the moving_image should be transformed)r+   r*   r   z-Image that will be transformed to fixed_imagez-x %szfixed mage mask)r+   r   r   fixed_image_maskzmoving mage mask)r+   rT   r   ZMattesr"   ZMI    ZRegularRandomNoneg?g        g      ?)re   lowhighz-m %szthe metric(s) to use.)r   r*   r   ZAffineZRigidZ
Similarityg?)re   rt   Zexclude_lowz	-t %s[%g]z'Several transform options are available)r   r   r   z-p %dZblobszalign using principal axes)r   r   rj   r      gQ?z
-s [%g,%g]zsearch factorz-g %szTranslation search grid in mmz2.3.0)r   r   Zmin_verr   i'  
   )rt   ru   re   gư>d   z-c [%d,%g,%d]convergencezinitialization.matz-o %szoutput file nameN)r/   r0   r1   r   r5   r3   r9   verboser   fixed_imagemoving_imagerp   moving_image_maskr2   RangeZmetric_traitrX   metricZ	transformprincipal_axesrW   search_factorr7   search_gridry   output_transformr;   r;   r;   r<   ro     sn   ro   c               @   s   e Zd ZedddZdS )AIOuputSpecTzoutput file name)r+   r   N)r/   r0   r1   r   r   r;   r;   r;   r<   r     s   r   c                   sB   e Zd ZdZdZeZeZd fdd	Z	 fddZ
dd	 Z  ZS )AIa  
    Calculate the optimal linear transform parameters for aligning two images.

    Examples
    --------
    >>> AI(
    ...     fixed_image='structural.nii',
    ...     moving_image='epi.nii',
    ...     metric=('Mattes', 32, 'Regular', 1),
    ... ).cmdline
    'antsAI -c [10,1e-06,10] -d 3 -m Mattes[structural.nii,epi.nii,32,Regular,1]
    -o initialization.mat -p 0 -s [20,0.12] -t Affine[0.1] -v 0'

    >>> AI(fixed_image='structural.nii',
    ...    moving_image='epi.nii',
    ...    metric=('Mattes', 32, 'Regular', 1),
    ...    search_grid=(12, (1, 1, 1)),
    ... ).cmdline
    'antsAI -c [10,1e-06,10] -d 3 -m Mattes[structural.nii,epi.nii,32,Regular,1]
    -o initialization.mat -p 0 -s [20,0.12] -g [12.0,1x1x1] -t Affine[0.1] -v 0'

    ZantsAIr   c                s8   t t| j||}dtjj|jtjj| jj	i| _
|S )Nr   )r?   r   _run_interfaceospathrb   cwdbasenamerA   r   _output)rE   ZruntimeZcorrect_return_codes)rF   r;   r<   r     s    zAI._run_interfacec                s   |dkr0d| }|j | jj| jjd}|j| S |dkrfd|d djdd	 |d
 D f }|j| S |dkrt| jjr|jd|| jjf  S tt	| j
|||S )Nr   z)%s[{fixed_image},{moving_image},%d,%s,%g])r{   r|   r   z[%s,%s]r   xc             s   s   | ]}d | V  qdS )z%gNr;   )r]   vr;   r;   r<   	<genexpr>  s    z!AI._format_arg.<locals>.<genexpr>r   rp   )formatrA   r{   r|   r   rb   r   r}   r?   r   rc   )rE   optspecvalZfmtval)rF   r;   r<   rc     s    
$
zAI._format_argc             C   s
   t | dS )Nr   )getattr)rE   r;   r;   r<   _list_outputs  s    zAI._list_outputsr   )r   )r/   r0   r1   rG   rH   ro   rI   r   rJ   r   rc   r   rL   r;   r;   )rF   r<   r     s   
r   c               @   sJ   e Zd ZejdddddddZeddd	d
dZeedddddddZ	dS )AverageAffineTransformInputSpecr   r   z%dTr   zimage dimension (2 or 3))r   r*   r   r   z%sr   z5Outputfname.txt: the name of the resulting transform.)r+   ztransforms to averageN)
r/   r0   r1   r   r5   r3   r   output_affine_transformr	   
transformsr;   r;   r;   r<   r     s   r   c               @   s   e Zd ZedddZdS ) AverageAffineTransformOutputSpecTzaverage transform file)r+   r   N)r/   r0   r1   r   affine_transformr;   r;   r;   r<   r   2  s   r   c                   s4   e Zd ZdZd ZeZeZ fddZ	dd Z
  ZS )AverageAffineTransforma  
    Examples
    --------
    >>> from nipype.interfaces.ants import AverageAffineTransform
    >>> avg = AverageAffineTransform()
    >>> avg.inputs.dimension = 3
    >>> avg.inputs.transforms = ['trans.mat', 'func_to_struct.mat']
    >>> avg.inputs.output_affine_transform = 'MYtemplatewarp.mat'
    >>> avg.cmdline
    'AverageAffineTransform 3 MYtemplatewarp.mat trans.mat func_to_struct.mat'

    c                s   t t| j|||S )N)r?   r   rc   )rE   r   r   r   )rF   r;   r<   rc   H  s    z"AverageAffineTransform._format_argc             C   s$   | j  j }tjj| jj|d< |S )Nr   )_outputsgetr   r   abspathrA   r   )rE   outputsr;   r;   r<   r   K  s    z$AverageAffineTransform._list_outputs)r/   r0   r1   rG   rH   r   rI   r   rJ   rc   r   rL   r;   r;   )rF   r<   r   6  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dZejdddddZ	e
eddd	ddddZdS )AverageImagesInputSpecr   r   z%dTr   zimage dimension (2 or 3))r   r*   r   r   zaverage.niiz%sr   Fz the name of the resulting image.)r   r   r   Z
hash_filesr   zmNormalize: if true, the 2nd image is divided by its mean. This will select the largest image to average into.)r+   zFimage to apply transformation to (generally a coregistered functional)N)r/   r0   r1   r   r5   r3   r   output_average_imager9   	normalizer	   Zimagesr;   r;   r;   r<   r   S  s(   r   c               @   s   e Zd ZedddZdS )AverageImagesOutputSpecTzaverage image file)r+   r   N)r/   r0   r1   r   r   r;   r;   r;   r<   r   o  s   r   c                   s4   e Zd ZdZd ZeZeZ fddZ	dd Z
  ZS )AverageImagesa|  
    Examples
    --------
    >>> from nipype.interfaces.ants import AverageImages
    >>> avg = AverageImages()
    >>> avg.inputs.dimension = 3
    >>> avg.inputs.output_average_image = "average.nii.gz"
    >>> avg.inputs.normalize = True
    >>> avg.inputs.images = ['rc1s1.nii', 'rc1s1.nii']
    >>> avg.cmdline
    'AverageImages 3 average.nii.gz 1 rc1s1.nii rc1s1.nii'
    c                s   t t| j|||S )N)r?   r   rc   )rE   r   r   r   )rF   r;   r<   rc     s    zAverageImages._format_argc             C   s$   | j  j }tjj| jj|d< |S )Nr   )r   r   r   r   realpathrA   r   )rE   r   r;   r;   r<   r     s    zAverageImages._list_outputs)r/   r0   r1   rG   rH   r   rI   r   rJ   rc   r   rL   r;   r;   )rF   r<   r   s  s   r   c               @   sb   e Zd ZejdddddddZedddd	d
dZejeddej	dddddZ
edddddZdS )MultiplyImagesInputSpecr   r   z%dTr   zimage dimension (2 or 3))r   r*   r   r   z%sr   zimage 1)r   r+   r*   r   r   )r+   z image 2 or multiplication weightz4Outputfname.nii.gz: the name of the resulting image.N)r/   r0   r1   r   r5   r3   r   Zfirst_inputr7   rW   Zsecond_inputoutput_product_imager;   r;   r;   r<   r     s    r   c               @   s   e Zd ZedddZdS )MultiplyImagesOutputSpecTzaverage image file)r+   r   N)r/   r0   r1   r   r   r;   r;   r;   r<   r     s   r   c                   s4   e Zd ZdZd ZeZeZ fddZ	dd Z
  ZS )MultiplyImagesam  
    Examples
    --------
    >>> from nipype.interfaces.ants import MultiplyImages
    >>> test = MultiplyImages()
    >>> test.inputs.dimension = 3
    >>> test.inputs.first_input = 'moving2.nii'
    >>> test.inputs.second_input = 0.25
    >>> test.inputs.output_product_image = "out.nii"
    >>> test.cmdline
    'MultiplyImages 3 moving2.nii 0.25 out.nii'
    c                s   t t| j|||S )N)r?   r   rc   )rE   r   r   r   )rF   r;   r<   rc     s    zMultiplyImages._format_argc             C   s$   | j  j }tjj| jj|d< |S )Nr   )r   r   r   r   r   rA   r   )rE   r   r;   r;   r<   r     s    zMultiplyImages._list_outputs)r/   r0   r1   rG   rH   r   rI   r   rJ   rc   r   rL   r;   r;   )rF   r<   r     s   r   c               @   sl   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jdd	ddddZ	ejdd	ddddZ
dS )'CreateJacobianDeterminantImageInputSpecr   r   z%dTr   zimage dimension (2 or 3))r   r*   r   r   z%sr   zdeformation transformation file)r   r+   r*   r   r   zoutput filenamezreturn the log jacobian)r   r   r   rP   zreturn the geometric jacobianN)r/   r0   r1   r   r5   ZimageDimensionr   ZdeformationFieldoutputImageZdoLogJacobianZuseGeometricr;   r;   r;   r<   r     s   r   c               @   s   e Zd ZedddZdS )(CreateJacobianDeterminantImageOutputSpecTzjacobian image)r+   r   N)r/   r0   r1   r   jacobian_imager;   r;   r;   r<   r     s   r   c                   s4   e Zd ZdZd ZeZeZ fddZ	dd Z
  ZS )CreateJacobianDeterminantImagea  
    Examples
    --------
    >>> from nipype.interfaces.ants import CreateJacobianDeterminantImage
    >>> jacobian = CreateJacobianDeterminantImage()
    >>> jacobian.inputs.imageDimension = 3
    >>> jacobian.inputs.deformationField = 'ants_Warp.nii.gz'
    >>> jacobian.inputs.outputImage = 'out_name.nii.gz'
    >>> jacobian.cmdline
    'CreateJacobianDeterminantImage 3 ants_Warp.nii.gz out_name.nii.gz'
    c                s   t t| j|||S )N)r?   r   rc   )rE   r   r   r   )rF   r;   r<   rc     s    z*CreateJacobianDeterminantImage._format_argc             C   s$   | j  j }tjj| jj|d< |S )Nr   )r   r   r   r   r   rA   r   )rE   r   r;   r;   r<   r     s    z,CreateJacobianDeterminantImage._list_outputs)r/   r0   r1   rG   rH   r   rI   r   rJ   rc   r   rL   r;   r;   )rF   r<   r     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d
ZeddddddZ	ej
ddddddZejddddddddZejddddddZejddddddZdS ) AffineInitializerInputSpecr   r   Tr   z%sr3   )r   r   r   r   r   zreference image)r+   r*   r   r   r   zmoving imageztransform.matzoutput transform fileg      .@rP   z%fz&increments (degrees) for affine searchg        g      ?g?rQ   z"search this arc +/- principal axes)re   r   r   r   r   FrR   z%dzLwhether the rotation is searched around an initial principal axis alignment.rw   rl   z` determines if a local optimization is run at each search point for the set number of iterationsN)r/   r0   r1   r   r5   r3   r   r{   r|   out_filerW   r   r~   Zradian_fractionr9   r   r2   Zlocal_searchr;   r;   r;   r<   r     sL   r   c               @   s   e Zd ZeddZdS )AffineInitializerOutputSpeczoutput transform file)r   N)r/   r0   r1   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 )AffineInitializeray  
    Initialize an affine transform (as in antsBrainExtraction.sh)

    >>> from nipype.interfaces.ants import AffineInitializer
    >>> init = AffineInitializer()
    >>> init.inputs.fixed_image = 'fixed1.nii'
    >>> init.inputs.moving_image = 'moving1.nii'
    >>> init.cmdline
    'antsAffineInitializer 3 fixed1.nii moving1.nii transform.mat 15.000000 0.100000 0 10'

    ZantsAffineInitializerc             C   s   dt jj| jjiS )Nr   )r   r   r   rA   r   )rE   r;   r;   r<   r   B  s    zAffineInitializer._list_outputsN)
r/   r0   r1   rG   rH   r   rI   r   rJ   r   r;   r;   r;   r<   r   1  s
   r   c               @   s^   e Zd ZejdddddddZedd	d
gddddZeddddZe	edddddddZ
dS )ComposeMultiTransformInputSpecr   r   z%dTr   zimage dimension (2 or 3))r   r   r   r   z%sr   r   z%s_composedz$the name of the resulting transform.)r   r   r   r   r   r   z9Reference image (only necessary when output is warpfield))r   r   r   )r+   ztransforms to average)r   r*   r   r   N)r/   r0   r1   r   r5   r3   r   r   Zreference_imager	   r   r;   r;   r;   r<   r   F  s&   r   c               @   s   e Zd ZedddZdS )ComposeMultiTransformOutputSpecTzComposed transform file)r+   r   N)r/   r0   r1   r   r   r;   r;   r;   r<   r   `  s   r   c               @   s   e Zd ZdZd ZeZeZdS )ComposeMultiTransforma  
    Take a set of transformations and convert them to a single transformation matrix/warpfield.

    Examples
    --------
    >>> from nipype.interfaces.ants import ComposeMultiTransform
    >>> compose_transform = ComposeMultiTransform()
    >>> compose_transform.inputs.dimension = 3
    >>> compose_transform.inputs.transforms = ['struct_to_template.mat', 'func_to_struct.mat']
    >>> compose_transform.cmdline
    'ComposeMultiTransform 3 struct_to_template_composed.mat
    struct_to_template.mat func_to_struct.mat'

    N)	r/   r0   r1   rG   rH   r   rI   r   rJ   r;   r;   r;   r<   r   d  s   r   c            	   @   s^   e Zd ZejdddddddZedd	dd
dZeddddddddZej	dgdddddZ
dS )LabelGeometryInputSpecr   r   z%dTr   zimage dimension (2 or 3))r   r   r   r   z%sr   z3label image to use for extracting geometry measures)r   r   r*   r   z[]zAIntensity image to extract values from. This is an optional input)re   r+   r   r*   r   r   r   label_imagez%s.csvzname of output file)r   r   r   r   r   N)r/   r0   r1   r   r5   r3   r   r   Zintensity_imager   output_filer;   r;   r;   r<   r   y  s*   r   c               @   s   e Zd ZedddZdS )LabelGeometryOutputSpecTzCSV file of geometry measures)r+   r   N)r/   r0   r1   r   r   r;   r;   r;   r<   r     s   r   c               @   s   e Zd ZdZdZeZeZdS )LabelGeometrya1  
    Extracts geometry measures using a label file and an optional image file

    Examples
    --------
    >>> from nipype.interfaces.ants import LabelGeometry
    >>> label_extract = LabelGeometry()
    >>> label_extract.inputs.dimension = 3
    >>> label_extract.inputs.label_image = 'atlas.nii.gz'
    >>> label_extract.cmdline
    'LabelGeometryMeasures 3 atlas.nii.gz [] atlas.csv'

    >>> label_extract.inputs.intensity_image = 'ants_Warp.nii.gz'
    >>> label_extract.cmdline
    'LabelGeometryMeasures 3 atlas.nii.gz ants_Warp.nii.gz atlas.csv'

    ZLabelGeometryMeasuresN)	r/   r0   r1   rG   rH   r   rI   r   rJ   r;   r;   r;   r<   r     s   r   )0rG   r   warningsr   baser   r   r   r   r   r	   Zmixinsr
   r   r   r   r=   r>   rM   rZ   r[   rf   rm   rn   ro   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r;   r;   r;   r<   <module>   sL    t\&/3 Q=3