3
d                 @   s,   d Z ddlZddlmZ dd Zdd ZdS )	zGrab documentation from spm.    N   )matlabc             C   s@   t jdd}tjjt}d|| f }||j_|j }t	|j
jS )a  Grab the SPM documentation for the given SPM task named `task_name`

    Parameters
    ----------
    task_name : string
        Task name for which we are grabbing documentation.  Example
        task names are ``Realign: Estimate & Reslice``, ``Normalise:
        Estimate & Write``.

    See Also
    --------
    spm_flat_config.m : This function can print out all the possible
        task names.

    F)Zresource_monitorzaddpath('%s');spm_get_doc('%s'))r   ZMatlabCommandospathdirname__file__inputsZscript_linesrun_strip_headerZruntimestdout)Z	task_namecmdcwdZmcmdout r   7/tmp/pip-build-7vycvbft/nipype/nipype/utils/spm_docs.pygrab_doc
   s    r   c             C   s   d}d}y| j |}W n, tk
rB } ztd|W Y dd}~X nX |t|7 }|d7 }| |d } y| j |}W n tk
r   t| }Y nX | d| S )zStrip Matlab header and splash info off doc.

    Searches for the tag 'NIPYPE' in the doc and returns everyting after that.

    ZNIPYPEz,This docstring was not generated by Nipype!
N   )index
ValueErrorIOErrorlen)dochdrZcruftr   er   r   r   r
   &   s    r
   )__doc__r   Z
interfacesr   r   r
   r   r   r   r   <module>   s   