U
    f»{jö-  ã                   @   sb   d Z ddlmZmZmZ edddddddddddddœdd„ƒZedd	d
„ƒZG dd„ deƒZdS )z'Convenience functions for opening GUIs.é   )ÚverboseÚ
get_configÚwarnFTN)Úorient_to_surfaceÚscale_by_distanceÚmark_insideÚinteractionÚscaleÚadvanced_renderingÚhead_insideÚ
fullscreenÚshowÚblockr   c                C   sT  | df|df|df|df|||dœ}|  ¡ D ]@\}}t|tƒrP|d |d k}n|dk	}|r,td|› d�ƒ q,tƒ }|dkrŒ| d	d
¡d
k}|	dkr¤| dd
¡d
k}	|dkr¼| dd
¡d
k}|dkrÐ| dd¡}|dkrì| dd
¡ ¡ d
k}|dk�r| dd¡}|dk�r| dd¡}|dk�rHd|k�r6|d }nd|k�rH|d }|dk�rb| dd¡d
k}|dk�r|| dd¡d
k}|dk�r’| dd¡}|dk�r¬| dd¡d
k}|dk�rÂ| dd¡}|dk�rÜ| dd¡d
k}t|ƒ}t|ƒ}t	|ƒ}t	|ƒ}t|ƒ}dd l
m} dd!lm} |�r*d }}|||||	|||||
||f|||||d"�S )#aã  Coregister an MRI with a subject's head shape.

    The GUI can be launched through the command line interface:

    .. code-block::  bash

        $ mne coreg

    or using a python interpreter as shown in :ref:`tut-source-alignment`.

    Parameters
    ----------
    tabbed : bool
        Combine the data source panel and the coregistration panel into a
        single panel with tabs.
    split : bool
        Split the main panels with a movable splitter (good for QT4 but
        unnecessary for wx backend).
    width : int | None
        Specify the width for window (in logical pixels).
        Default is None, which uses ``MNE_COREG_WINDOW_WIDTH`` config value
        (which defaults to 800).
    inst : None | str
        Path to an instance file containing the digitizer data. Compatible for
        Raw, Epochs, and Evoked files.
    subject : None | str
        Name of the mri subject.
    %(subjects_dir)s
    guess_mri_subject : bool
        When selecting a new head shape file, guess the subject's name based
        on the filename and change the MRI subject accordingly (default True).
    height : int | None
        Specify a height for window (in logical pixels).
        Default is None, which uses ``MNE_COREG_WINDOW_WIDTH`` config value
        (which defaults to 400).
    head_opacity : float | None
        The opacity of the head surface in the range [0., 1.].
        Default is None, which uses ``MNE_COREG_HEAD_OPACITY`` config value
        (which defaults to 1.).
    head_high_res : bool | None
        Use a high resolution head surface.
        Default is None, which uses ``MNE_COREG_HEAD_HIGH_RES`` config value
        (which defaults to True).
    trans : str | None
        The transform file to use.
    scrollable : bool
        Make the coregistration panel vertically scrollable (default True).
    orient_to_surface : bool | None
        If True (default), orient EEG electrode and head shape points
        to the head surface.

        .. versionadded:: 0.16
    scale_by_distance : bool | None
        If True (default), scale the digitization points by their
        distance from the scalp surface.

        .. versionadded:: 0.16
    mark_inside : bool | None
        If True (default), mark points inside the head surface in a
        different color.

        .. versionadded:: 0.16
    %(interaction_scene_none)s
        Defaults to ``'terrain'``.

        .. versionadded:: 0.16
        .. versionchanged:: 1.0
           Default interaction mode if ``None`` and no config setting found
           changed from ``'trackball'`` to ``'terrain'``.
    scale : float | None
        The scaling for the scene.

        .. versionadded:: 0.16
    advanced_rendering : bool
        Use advanced OpenGL rendering techniques (default True).
        For some renderers (such as MESA software) this can cause rendering
        bugs.

        .. versionadded:: 0.18
    head_inside : bool
        If True (default), add opaque inner scalp head surface to help occlude
        points behind the head.

        .. versionadded:: 0.23
    %(fullscreen)s
        Default is None, which uses ``MNE_COREG_FULLSCREEN`` config value
        (which defaults to False).

        .. versionadded:: 1.1
    show : bool
        Show the GUI if True.
    block : bool
        Whether to halt program execution until the figure is closed.
    %(verbose)s

    Returns
    -------
    frame : instance of CoregistrationUI
        The coregistration frame.

    Notes
    -----
    Many parameters (e.g., ``head_opacity``) take None as a parameter,
    which means that the default will be read from the MNE-Python
    configuration file (which gets saved when exiting).

    Step by step instructions for the coregistrations are shown below:

    .. youtube:: uK4n5g6DBcg
    FT)ÚtabbedÚsplitÚ
scrollabler   Úguess_mri_subjectr	   r
   é    é   NzThe parameter zD is not supported with the pyvistaqt 3d backend. It will be ignored.ZMNE_COREG_GUESS_MRI_SUBJECTÚtrueZMNE_COREG_HEAD_HIGH_RESZMNE_COREG_ADVANCED_RENDERINGZMNE_COREG_HEAD_OPACITYgš™™™™™é?ZMNE_COREG_HEAD_INSIDEZMNE_COREG_WINDOW_WIDTHi   ZMNE_COREG_WINDOW_HEIGHTiX  ZSUBJECTS_DIRZMNE_COREG_SUBJECTS_DIRZMNE_COREG_ORIENT_TO_SURFACEÚ ZMNE_COREG_SCALE_BY_DISTANCEZMNE_COREG_INTERACTIONZterrainZMNE_COREG_MARK_INSIDEZMNE_COREG_SCENE_SCALEg{®GázÄ?ZMNE_COREG_FULLSCREENr   )ÚMNE_3D_BACKEND_TESTING©ÚCoregistrationUI)Z	info_fileÚsubjectÚsubjects_dirZhead_resolutionÚhead_opacityZorient_glyphsr   r   ÚtransÚsizer   r   r   r   r   )ÚitemsÚ
isinstanceÚtupler   r   ÚgetÚlowerÚfloatÚboolÚintZviz.backends.rendererr   Ú_coregr   )r   r   ÚwidthÚinstr   r   r   Úheightr   Zhead_high_resr   r   r   r   r   r   r	   r
   r   r   r   r   r   Zunsupported_paramsÚkeyÚvalZto_raiseÚconfigr   r   © r.   úO/var/www/html/bwave/python/venv/lib/python3.8/site-packages/mne/gui/__init__.pyÚcoregistration
   s¦    xù	
 ÿÿÿÿ







ÿ

ÿ



         úr0   c	              
   C   sf   ddl m}	 ddlm}
 ddlm} | ¡ }|dkr>|dgƒ}|
| |||||||d	�}|rb|	|ƒ |S )
a4  Locate intracranial electrode contacts.

    Parameters
    ----------
    %(info_not_none)s
    %(trans_not_none)s
    aligned_ct : path-like | nibabel.spatialimages.SpatialImage
        The CT image that has been aligned to the Freesurfer T1. Path-like
        inputs and nibabel image objects are supported.
    %(subject)s
    %(subjects_dir)s
    groups : dict | None
        A dictionary with channels as keys and their group index as values.
        If None, the groups will be inferred by the channel names. Channel
        names must have a format like ``LAMY 7`` where a string prefix
        like ``LAMY`` precedes a numeric index like ``7``. If the channels
        are formatted improperly, group plotting will work incorrectly.
        Group assignments can be adjusted in the GUI.
    show : bool
        Show the GUI if True.
    block : bool
        Whether to halt program execution until the figure is closed.
    %(verbose)s

    Returns
    -------
    gui : instance of IntracranialElectrodeLocator
        The graphical user interface (GUI) window.
    r   )Ú_qt_app_execr   ©ÚIntracranialElectrodeLocatorr   )ÚQApplicationNzIntracranial Electrode Locator)r   r   Úgroupsr   r   )Zviz.backends._utilsr1   Ú_ieeg_locater3   Zqtpy.QtWidgetsr4   Úinstance)Úinfor   Z
aligned_ctr   r   r5   r   r   r   r1   r3   r4   ZappÚguir.   r.   r/   Úlocate_ieegË   s&     
      þr:   c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )Ú_GUIScraperzScrape GUI outputs.c                 C   s   dS )Nz<GUIScraper>r.   )Úselfr.   r.   r/   Ú__repr__ý   s    z_GUIScraper.__repr__c              	   C   s2  ddl m} ddlm} ddlm} ddlm} |d  ¡ D ]ð}t	|||fƒr<t
|dd	ƒs<|d
 dkr<d|_t|d ƒ}	t|dƒr†|n|jj}
|
 ¡ }t|dƒrÞ|jj}| |	¡ | |	¡}| |¡ | |
| ¡  ¡ ¡|¡ | |	¡ z|j ¡  W n tk
�r   Y nX | ¡  ||	g|d dƒ  S q<dS )Nr   r2   r   r   )Ú
figure_rst)ÚQtGuiZexample_globalsÚ_scrapedFZbuilder_nameÚhtmlTZimage_path_iteratorÚgrabÚ	_rendererÚsrc_dirZGUIr   )r6   r3   r'   r   Zsphinx_gallery.scrapersr>   Zqtpyr?   Úvaluesr    Úgetattrr@   ÚnextÚhasattrrC   Z_windowrB   ÚplotterZ
screenshotZQPixmapZQPainterZ
drawPixmapZmapToÚrectZtopLeftÚsaveÚcloseÚ	Exception)r<   r   Z
block_varsZgallery_confr3   r   r>   r?   r9   Z	img_fnameZwindowZpixmaprI   Z
sub_pixmapr.   r.   r/   Ú__call__   sH    ÿ
þ
ý



þ
  ÿ
z_GUIScraper.__call__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r=   rN   r.   r.   r.   r/   r;   ú   s   r;   )FTNNNNNNNNNT)NNNTFN)	rR   Úutilsr   r   r   r0   r:   Úobjectr;   r.   r.   r.   r/   Ú<module>   sB                 ý       ù A        ÿ.