3
d                 @   s   d Z ddlZddl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dS )zEThe ants visualisation module provides basic functions based on ITK.
    N   )TraitedSpecFiletraits   )ANTSCommandANTSCommandInputSpecc               @   s   e Zd Zejdd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ejdddd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$Zej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+d,Zejd-ddd.d,Zd/S )0 ConvertScalarImageToRGBInputSpec   r   z%dTzimage dimension (2 or 3)r   )argstr
usedefaultdesc	mandatorypositionz%sz$Main input is a 3-D grayscale image.r   )r   existsr   r   r   z
rgb.nii.gzzrgb output image)r   r   r   r   none)r   z
mask image)r   r   r   defaultr   ZgreyZredZgreenZblueZcopperZjetZhsvZspringZsummerZautumnZwinterZhotZcoolZ	overunderZcustomzSelect a colormap   )r   r   r   r   zcustom color map file   zminimum input   zmaximum input      )r   r   r      	   N)__name__
__module____qualname__r   EnumZ	dimensionr   input_imageStroutput_imageZEither
mask_imageZcolormapZcustom_color_map_fileIntZminimum_inputZmaximum_inputZminimum_RGB_outputZmaximum_RGB_output r#   r#   F/tmp/pip-build-7vycvbft/nipype/nipype/interfaces/ants/visualization.pyr	      sh   
r	   c               @   s   e Zd ZedddZdS )!ConvertScalarImageToRGBOutputSpecTzconverted RGB image)r   r   N)r   r   r   r   r    r#   r#   r#   r$   r%   J   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 )ConvertScalarImageToRGBa  
    Convert scalar images to RGB.

    Examples
    --------
    >>> from nipype.interfaces.ants.visualization import ConvertScalarImageToRGB
    >>> converter = ConvertScalarImageToRGB()
    >>> converter.inputs.dimension = 3
    >>> converter.inputs.input_image = 'T1.nii.gz'
    >>> converter.inputs.colormap = 'jet'
    >>> converter.inputs.minimum_input = 0
    >>> converter.inputs.maximum_input = 6
    >>> converter.cmdline
    'ConvertScalarImageToRGB 3 T1.nii.gz rgb.nii.gz none jet none 0 6 0 255'

    c                s   t t| j|||S )N)superr&   _format_arg)selfoptspecval)	__class__r#   r$   r(   d   s    z#ConvertScalarImageToRGB._format_argc             C   s*   | j  j }tjjtj | jj|d< |S )Nr    )_outputsgetospathjoingetcwdinputsr    )r)   outputsr#   r#   r$   _list_outputsg   s    z%ConvertScalarImageToRGB._list_outputs)r   r   r   __doc___cmdr	   
input_specr%   output_specr(   r6   __classcell__r#   r#   )r-   r$   r&   N   s   r&   c               @   s   e Zd ZedddddZedddddZedddd	Zejd
ddZ	ej
dddddZej
dddZejdddZej
dddZej
dddZej
dddZejdddZdS )CreateTiledMosaicInputSpecz-i %sTz$Main input is a 3-D grayscale image.)r   r   r   r   z-r %szrAn optional Rgb image can be added as an overlay.It must have the same imagegeometry as the input grayscale image.z-x %sz)Specifies the ROI of the RGB voxels used.)r   r   r   z-a %.2fzTIf an Rgb image is provided, render the overlay using the specified alpha parameter.)r   r   z
output.pngz-o %sz.The output consists of the tiled mosaic image.)r   r   r   z-t %sa  The tile geometry specifies the number of rows and columnsin the output image. For example, if the user specifies "5x10", then 5 rows by 10 columns of slices are rendered. If R < 0 and C > 0 (or vice versa), the negative value is selectedbased on direction.z-d %dzwSpecifies the direction of the slices. If no direction is specified, the direction with the coarsest spacing is chosen.z-p %sa  argument passed to -p flag:[padVoxelWidth,<constantValue=0>][lowerPadding[0]xlowerPadding[1],upperPadding[0]xupperPadding[1],constantValue]The user can specify whether to pad or crop a specified voxel-width boundary of each individual slice. For this program, cropping is simply padding with negative voxel-widths.If one pads (+), the user can also specify a constant pad value (default = 0). If a mask is specified, the user can use the mask to define the region, by using the keyword "mask" plus an offset, e.g. "-p mask+3".z-s %szoNumber of slices to increment Slice1xSlice2xSlice3[numberOfSlicesToIncrement,<minSlice=0>,<maxSlice=lastSlice>]z-f %sZflipXxflipYz-gZ	doPermuteN)r   r   r   r   r   Z	rgb_imager!   r   ZFloatZalpha_valuer   r    Ztile_geometryr"   	directionZpad_or_cropZslicesZ
flip_sliceZBoolZpermute_axesr#   r#   r#   r$   r<   m   sD   r<   c               @   s   e Zd ZedddZdS )CreateTiledMosaicOutputSpecTz
image file)r   r   N)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 )CreateTiledMosaica  The program CreateTiledMosaic in conjunction with ConvertScalarImageToRGB
    provides useful functionality for common image analysis tasks. The basic
    usage of CreateTiledMosaic is to tile a 3-D image volume slice-wise into
    a 2-D image.

    Examples
    --------

    >>> from nipype.interfaces.ants.visualization import CreateTiledMosaic
    >>> mosaic_slicer = CreateTiledMosaic()
    >>> mosaic_slicer.inputs.input_image = 'T1.nii.gz'
    >>> mosaic_slicer.inputs.rgb_image = 'rgb.nii.gz'
    >>> mosaic_slicer.inputs.mask_image = 'mask.nii.gz'
    >>> mosaic_slicer.inputs.output_image = 'output.png'
    >>> mosaic_slicer.inputs.alpha_value = 0.5
    >>> mosaic_slicer.inputs.direction = 2
    >>> mosaic_slicer.inputs.pad_or_crop = '[ -15x -50 , -15x -30 ,0]'
    >>> mosaic_slicer.inputs.slices = '[2 ,100 ,160]'
    >>> mosaic_slicer.cmdline
    'CreateTiledMosaic -a 0.50 -d 2 -i T1.nii.gz -x mask.nii.gz -o output.png -p [ -15x -50 , -15x -30 ,0] -r rgb.nii.gz -s [2 ,100 ,160]'
    c             C   s*   | j  j }tjjtj | jj|d< |S )Nr    )r.   r/   r0   r1   r2   r3   r4   r    )r)   r5   r#   r#   r$   r6      s    zCreateTiledMosaic._list_outputsN)
r   r   r   r7   r8   r<   r9   r>   r:   r6   r#   r#   r#   r$   r?      s
   r?   )r7   r0   baser   r   r   r   r   r	   r%   r&   r<   r>   r?   r#   r#   r#   r$   <module>   s   ?L