U
    f»{jâ  ã                   @   s\   d Z ddlZddlZddlZddlmZ ddlmZmZ ed	dd„ƒZ	dd„ Z
ej ¡  dS )
a~	  Create mne report for a folder.

Examples
--------
Before getting started with ``mne report``, make sure the files you want to
render follow the filename conventions defined by MNE:

.. highlight:: console

.. cssclass:: table-bordered
.. rst-class:: midvalign

============ ==============================================================
Data object  Filename convention (ends with)
============ ==============================================================
raw          -raw.fif(.gz), -raw_sss.fif(.gz), -raw_tsss.fif(.gz),
             _meg.fif(.gz), _eeg.fif(.gz), _ieeg.fif(.gz)
events       -eve.fif(.gz)
epochs       -epo.fif(.gz)
evoked       -ave.fif(.gz)
covariance   -cov.fif(.gz)
trans        -trans.fif(.gz)
forward      -fwd.fif(.gz)
inverse      -inv.fif(.gz)
============ ==============================================================

To generate a barebones report from all the \*.fif files in the sample
dataset, invoke the following command in a system (e.g., Bash) shell::

    $ mne report --path MNE-sample-data/ --verbose

On successful creation of the report, it will open the HTML in a new tab in
the browser. To disable this, use the ``--no-browser`` option.

TO generate a report for a single subject, give the ``SUBJECT`` name and
the ``SUBJECTS_DIR`` and this will generate the MRI slices (with BEM
contours overlaid on top if available)::

    $ mne report --path MNE-sample-data/ --subject sample --subjects-dir \
        MNE-sample-data/subjects --verbose

To properly render ``trans`` and ``covariance`` files, add the measurement
information::

    $ mne report --path MNE-sample-data/ \
        --info MNE-sample-data/MEG/sample/sample_audvis-ave.fif \
        --subject sample --subjects-dir MNE-sample-data/subjects --verbose

To render whitened ``evoked`` files with baseline correction, add the noise
covariance file::

    $ mne report --path MNE-sample-data/ \
        --info MNE-sample-data/MEG/sample/sample_audvis-ave.fif \
        --cov MNE-sample-data/MEG/sample/sample_audvis-cov.fif --bmax 0 \
        --subject sample --subjects-dir MNE-sample-data/subjects --verbose

To generate the report in parallel::

    $ mne report --path MNE-sample-data/ \
        --info MNE-sample-data/MEG/sample/sample_audvis-ave.fif \
        --subject sample --subjects-dir MNE-sample-data/subjects \
        --verbose --jobs 6

For help on all the available options, do::

    $ mne report --help
é    N)ÚReport)ÚverboseÚloggerc                 C   s   t  dt| dƒ ¡ dS )zLog elapsed time.zReport complete in %s secondsé   N)r   ÚinfoÚround)Útr   © r	   úV/var/www/html/bwave/python/venv/lib/python3.8/site-packages/mne/commands/mne_report.pyÚlog_elapsedN   s    r   c               	   C   sZ  ddl m} m} | tƒ}|jddddd� |jdd	d
ddd� |jdddddd� |jddddd� |jddddd� |jddddd� |jddd d!d� |jd"d#d$d%d&� |jd'd(d$d)d&� |jd*d+d,d-d� |jd.d/d0d1d2d3d4� |jd5d6d7d8d9d4� ||ƒ | ¡ \}}|j}|dk�r0| ¡  t 	d:¡ |j
}|j}|j}|j}	|j}
t|jƒ}|jdk	�rhd;nd<}|jdk	�r|d<nd;}|jdk	�r�d;nd<}|jdk	�rªt|jƒnd:}|jdk	�rÄt|jƒnd}|jdk	�rÞt|jƒnd}|dk�rü|dk�rüd}n||f}t ¡ }t|||	||||
d=�}|j||||d>� tt ¡ | |d?� |j||d@� dS )AzRun command.r   )Úget_optparserÚ_add_verbose_flagz-pz--pathÚpathz-Path to folder who MNE-Report must be created)ÚdestÚhelpz-iz--infoÚ
info_fnamez-File from which info dictionary is to be readÚFILE)r   r   Úmetavarz-cz--covÚ	cov_fnamez.File from which noise covariance is to be readz--bminÚbminz4Time at which baseline correction starts for evokedsN)r   r   Údefaultz--bmaxÚbmaxz3Time at which baseline correction stops for evokedsz-dz--subjects-dirÚsubjects_dirzThe subjects directoryz-sz	--subjectÚsubjectzThe subject namez--no-browserÚ
no_browserÚstore_falsez!Do not open MNE-Report in browser)r   Úactionr   z--overwriteÚ	overwritez*Overwrite html report if it already existsz-jz--jobsÚn_jobsz!Number of jobs to run in parallelz-mz--mri-decimÚintÚ	mri_decimé   z)Integer factor used to decimate BEM plots)Útyper   r   r   z--image-formatÚstrÚimage_formatZpngz+Image format to use (can be 'png' or 'svg')r   TF)r   r   Úbaseliner   r   r$   )r   r   r    )r   )Úopen_browserr   )Zmne.commands.utilsr   r   Ú__file__Ú
add_optionÚ
parse_argsr   Ú
print_helpÚsysÚexitr   r   r   r   r$   r   r    r   r   r   r   r   Úfloatr   Útimer   Zparse_folderr   Úsave)r   r   ÚparserÚoptionsÚargsr   r   r   r   r   r$   r    r   r&   r   r   r   r   r%   Út0Úreportr	   r	   r
   ÚrunT   s˜    
ÿ
þ
þþþ
ÿ
ÿ
ÿ
ÿ ÿ
 ÿ


  ý
ÿr5   )N)Ú__doc__r+   r.   ZmneZ
mne.reportr   Z	mne.utilsr   r   r   r5   ÚutilsZrun_command_if_mainr	   r	   r	   r
   Ú<module>   s   DI