U
    f»{j‡  ã                   @   sV   d Z ddlZddlZddlmZ ddlZddlmZm	Z	 dd„ Z
dd„ Zej ¡  dS )zƒView the 3-Layers BEM model using Freeview.

Examples
--------
.. code-block:: console

    $ mne freeview_bem_surfaces -s sample

é    N)Úrun_subprocessÚget_subjects_dirc                 C   sj  t |dd�}| dkrtdƒ‚t || ¡}t |¡s@td |¡ƒ‚tj ¡ }| |d< ||d< d|krjt	d	ƒ‚t |d
¡}t |d¡}t |d¡}|dkrÔt |d¡}t |d|  ¡}t |d|  ¡}	t |d|  ¡}
n8|dkrèt |d¡}t |d¡}t |d¡}	t |d¡}
dg}|d|g7 }|dd|
 g7 }|dd|	 g7 }|dd| g7 }t
||tjd� tdƒ dS )a  View 3-Layers BEM model with Freeview.

    Parameters
    ----------
    subject : string
        Subject name
    subjects_dir : string
        Directory containing subjects data (Freesurfer SUBJECTS_DIR)
    method : string
        Can be 'flash' or 'watershed'.
    T)Zraise_errorNzsubject argument is None.z8Wrong path: '{}'. Check subjects-dir orsubject argument.ÚSUBJECTZSUBJECTS_DIRZFREESURFER_HOMEz.The FreeSurfer environment needs to be set up.ÚmriZbemzT1.mgzZ	watershedz%s_outer_skin_surfacez%s_outer_skull_surfacez%s_inner_skull_surfaceZflashzouter_skin.surfzouter_skull.surfzinner_skull.surfZfreeviewz--volumez	--surfacez%s:color=red:edgecolor=redz %s:color=yellow:edgecolor=yellowz*%s:color=255,170,127:edgecolor=255,170,127)ÚenvÚstdoutz[done])r   Ú
ValueErrorÚopÚjoinÚisdirÚformatÚosÚenvironÚcopyÚRuntimeErrorr   Úsysr   Úprint)ÚsubjectÚsubjects_dirÚmethodZsubject_dirr   Zmri_dirZbem_dirr   Z
outer_skinZouter_skullZinner_skullÚcmd© r   úe/var/www/html/bwave/python/venv/lib/python3.8/site-packages/mne/commands/mne_freeview_bem_surfaces.pyÚfreeview_bem_surfaces   sF    
ÿ
ÿr   c                  C   sŽ   ddl m}  | tƒ}tj d¡}tƒ }|jdddd|d� |jd	d
dd|d� |jddddd� | ¡ \}}|j	}|j
}|j}t|||ƒ dS )zRun command.r   )Úget_optparserr   z-sz	--subjectr   zSubject name)ÚdestÚhelpÚdefaultz-dz--subjects-dirr   zSubjects directoryz-mz--methodr   zAMethod used to generate the BEM model. Can be flash or watershed.)r   r   N)Zmne.commands.utilsr   Ú__file__r   r   Úgetr   Ú
add_optionÚ
parse_argsr   r   r   r   )r   Úparserr   r   ÚoptionsÚargsr   r   r   r   ÚrunO   s(    
 ÿ
 ÿ
ÿr%   )Ú__doc__r   r   Úos.pathÚpathr	   ZmneZ	mne.utilsr   r   r   r%   ÚutilsZrun_command_if_mainr   r   r   r   Ú<module>   s   :