3
d2                 @   sd   d Z ddlmZmZmZmZmZmZmZ ddl	Z	G dd deZ
G dd deZG d	d
 d
eZdS )zThis commandline module provides classes for interfacing with the
`ICA-AROMA.py <https://github.com/maartenmennes/ICA-AROMA>`__ command line tool.
   )TraitedSpecCommandLineInputSpecCommandLineFile	Directorytraits	isdefined    Nc            
   @   s   e Zd ZedddddddgddZeddd	d
gddZeddddddZeddd
gddZe	j
dddZe	jdddZeddddZeddd
gddZeddd
gddZedddd
gd dZe	jd!d"d#d$ddd%d&dZd'S )(ICA_AROMAInputSpecTz-feat %sin_filemat_filefnirt_warp_filemotion_parameterszvIf a feat directory exists and temporal filtering has not been run yet, ICA_AROMA can use the files in this directory.)exists	mandatoryargstrxordescz-i %sfeat_dirzvolume to be denoisedoutz-o %szoutput directory)Z
usedefaultr   r   r   z-m %szpath/name volume mask)r   r   r   r   z-dim %dzODimensionality reduction when running MELODIC (defualt is automatic estimation))r   r   z-tr %.3fzhTR in seconds. If this is not specified the TR will be extracted from the header of the fMRI nifti file.z
-meldir %sz9path to MELODIC directory if MELODIC has already been run)r   r   r   z
-affmat %szpath/name of the mat-file describing the affine registration (e.g. FSL FLIRT) of the functional data to structural space (.mat file)z-warp %szFile name of the warp-file describing the non-linear registration (e.g. FSL FNIRT) of the structural data to MNI152 space (.nii.gz)z-mc %szmotion parameters filenonaggraggrbothnoz-den %sa  Type of denoising strategy:
-no: only classification, no denoising
-nonaggr (default): non-aggresssive denoising, i.e. partial component regression
-aggr: aggressive denoising, i.e. full component regression
-both: both aggressive and non-aggressive denoising (two outputs)N)__name__
__module____qualname__r   r   r   r   out_dirmaskr   ZIntZdimZFloatZTRZmelodic_dirr   r   r   Enumdenoise_type r!   r!   =/tmp/pip-build-7vycvbft/nipype/nipype/interfaces/fsl/aroma.pyr
      sf   
r
   c               @   s0   e Zd ZedddZedddZedddZdS )ICA_AROMAOutputSpecTz*if generated: aggressively denoised volume)r   r   z.if generated: non aggressively denoised volumezdirectory contains (in addition to the denoised files): melodic.ica + classified_motion_components + classification_overview + feature_scores + melodic_ic_mni)N)r   r   r   r   aggr_denoised_filenonaggr_denoised_filer   r   r!   r!   r!   r"   r#   b   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 )	ICA_AROMAa  
    Interface for the ICA_AROMA.py script.

    ICA-AROMA (i.e. 'ICA-based Automatic Removal Of Motion Artifacts') concerns
    a data-driven method to identify and remove motion-related independent
    components from fMRI data. To that end it exploits a small, but robust
    set of theoretically motivated features, preventing the need for classifier
    re-training and therefore providing direct and easy applicability.

    See link for further documentation: https://github.com/rhr-pruim/ICA-AROMA

    Example
    -------

    >>> from nipype.interfaces.fsl import ICA_AROMA
    >>> from nipype.testing import example_data
    >>> AROMA_obj = ICA_AROMA()
    >>> AROMA_obj.inputs.in_file = 'functional.nii'
    >>> AROMA_obj.inputs.mat_file = 'func_to_struct.mat'
    >>> AROMA_obj.inputs.fnirt_warp_file = 'warpfield.nii'
    >>> AROMA_obj.inputs.motion_parameters = 'fsl_mcflirt_movpar.txt'
    >>> AROMA_obj.inputs.mask = 'mask.nii.gz'
    >>> AROMA_obj.inputs.denoise_type = 'both'
    >>> AROMA_obj.inputs.out_dir = 'ICA_testout'
    >>> AROMA_obj.cmdline  # doctest: +ELLIPSIS
    'ICA_AROMA.py -den both -warp warpfield.nii -i functional.nii -m mask.nii.gz -affmat func_to_struct.mat -mc fsl_mcflirt_movpar.txt -o .../ICA_testout'
    zICA_AROMA.pyc                s.   |dkr|j tjj| S tt| j|||S )Nr   )r   ospathabspathsuperr&   _format_arg)selfnameZ
trait_specvalue)	__class__r!   r"   r+      s    zICA_AROMA._format_argc             C   sh   | j  j }tjj| jj|d< |d }| jjd	krFtjj|d|d< | jjd
krdtjj|d|d< |S )Nr   r   r   zdenoised_func_data_aggr.nii.gzr$   r   z!denoised_func_data_nonaggr.nii.gzr%   )r   r   )r   r   )	output_specgetr'   r(   r)   inputsr   r    join)r,   outputsr   r!   r!   r"   _list_outputs   s    zICA_AROMA._list_outputs)r   r   r   __doc__Z_cmdr
   Z
input_specr#   r0   r+   r5   __classcell__r!   r!   )r/   r"   r&   q   s   r&   )r6   baser   r   r   r   r   r   r   r'   r
   r#   r&   r!   r!   r!   r"   <module>   s
   $	N