mne.Report¶
-
class
mne.
Report
(info_fname=None, subjects_dir=None, subject=None, title=None, cov_fname=None, baseline=None, image_format='png', raw_psd=False, verbose=None)[source]¶ Object for rendering HTML.
- Parameters
- info_fname
str
Name of the file containing the info dictionary.
- subjects_dir
str
|None
Path to the SUBJECTS_DIR. If None, the path is obtained by using the environment variable SUBJECTS_DIR.
- subject
str
|None
Subject name.
- title
str
Title of the report.
- cov_fname
str
Name of the file containing the noise covariance.
- baseline
None
ortuple
of length 2 (default (None
, 0)) The time interval to apply baseline correction for evokeds. If None do not apply it. If baseline is (a, b) the interval is between “a (s)” and “b (s)”. If a is None the beginning of the data is used and if b is None then b is set to the end of the interval. If baseline is equal to (None, None) all the time interval is used. The baseline (a, b) includes both endpoints, i.e. all timepoints t such that a <= t <= b.
- image_format
str
Default image format to use (default is ‘png’). SVG uses vector graphics, so fidelity is higher but can increase file size and browser image rendering time as well.
New in version 0.15.
- raw_psdbool |
dict
If True, include PSD plots for raw files. Can be False (default) to omit, True to plot, or a dict to pass as
kwargs
tomne.io.Raw.plot_psd()
.New in version 0.17.
- verbosebool,
str
,int
, orNone
If not None, override default verbose level (see
mne.verbose()
and Logging documentation for more).
- info_fname
Notes
See Getting started with mne.Report for an introduction to using
mne.Report
, and this example for an example of customizing the report with a slider.New in version 0.8.0.
Methods
__hash__
(self, /)Return hash(self).
__len__
(self)Return the number of items in report.
add_bem_to_section
(self, subject[, caption, …])Render a bem slider html str.
add_figs_to_section
(self, figs, captions[, …])Append custom user-defined figures.
add_htmls_to_section
(self, htmls, captions)Append htmls to the report.
add_images_to_section
(self, fnames, captions)Append custom user-defined images.
add_slider_to_section
(self, figs[, …])Render a slider of figs to the report.
parse_folder
(self, data_path[, pattern, …])Render all the files in the folder.
remove
(self, caption[, section])Remove a figure from the report.
save
(self[, fname, open_browser, overwrite])Save the report and optionally open it in browser.
-
__hash__
(self, /)¶ Return hash(self).
-
add_bem_to_section
(self, subject, caption='BEM', section='bem', decim=2, n_jobs=1, subjects_dir=None, replace=False)[source]¶ Render a bem slider html str.
- Parameters
- subject
str
Subject name.
- caption
str
A caption for the bem.
- section
str
Name of the section. If section already exists, the bem will be appended to the end of the section.
- decim
int
Use this decimation factor for generating MRI/BEM images (since it can be time consuming).
- n_jobs
int
The number of jobs to run in parallel (default 1). Requires the joblib package.
- subjects_dir
str
|None
Path to the SUBJECTS_DIR. If None, the path is obtained by using the environment variable SUBJECTS_DIR.
- replacebool
If
True
, figures already present that have the same caption will be replaced. Defaults toFalse
.
- subject
Notes
New in version 0.9.0.
-
add_figs_to_section
(self, figs, captions, section='custom', scale=None, image_format=None, comments=None, replace=False)[source]¶ Append custom user-defined figures.
- Parameters
- figs
matplotlib.figure.Figure
|mlab.Figure
|array
|list
A figure or a list of figures to add to the report. Each figure in the list can be an instance of
matplotlib.figure.Figure
,mayavi.core.api.Scene
, ornumpy.ndarray
.- captions
str
|list
ofstr
A caption or a list of captions to the figures.
- section
str
Name of the section to place the figure in. If section already exists, the figures will be appended to the end of the section.
- scale
float
|None
|callable()
Scale the images maintaining the aspect ratio. If None, no scaling is applied. If float, scale will determine the relative scaling (might not work for scale <= 1 depending on font sizes). If function, should take a figure object as input parameter. Defaults to None.
- image_format
str
|None
The image format to be used for the report, can be ‘png’ or ‘svd’. None (default) will use the default specified during Report class construction.
- comments
None
|str
|list
ofstr
A string of text or a list of strings of text to be appended after the figure.
- replacebool
If
True
, figures already present that have the same caption will be replaced. Defaults toFalse
.
- figs
Examples using
add_figs_to_section
:
-
add_htmls_to_section
(self, htmls, captions, section='custom', replace=False)[source]¶ Append htmls to the report.
- Parameters
- htmls
str
|list
ofstr
An html str or a list of html str.
- captions
str
|list
ofstr
A caption or a list of captions to the htmls.
- section
str
Name of the section. If section already exists, the images will be appended to the end of the section.
- replacebool
If
True
, figures already present that have the same caption will be replaced. Defaults toFalse
.
- htmls
Notes
New in version 0.9.0.
-
add_images_to_section
(self, fnames, captions, scale=None, section='custom', comments=None, replace=False)[source]¶ Append custom user-defined images.
- Parameters
- fnames
str
|list
ofstr
A filename or a list of filenames from which images are read. Images can be PNG, GIF or SVG.
- captions
str
|list
ofstr
A caption or a list of captions to the images.
- scale
float
|None
Scale the images maintaining the aspect ratio. Defaults to None. If None, no scaling will be applied.
- section
str
Name of the section. If section already exists, the images will be appended to the end of the section.
- comments
None
|str
|list
ofstr
A string of text or a list of strings of text to be appended after the image.
- replacebool
If
True
, figures already present that have the same caption will be replaced. Defaults toFalse
.
- fnames
-
add_slider_to_section
(self, figs, captions=None, section='custom', title='Slider', scale=None, image_format=None, replace=False)[source]¶ Render a slider of figs to the report.
- Parameters
- figs
list
of figures. Each figure in the list can be an instance of
matplotlib.figure.Figure
,mayavi.core.api.Scene
, ornumpy.ndarray
. Must have at least 2 elements.- captions
list
ofstr
|list
offloat
|None
A list of captions to the figures. If float, a str will be constructed as %f s. If None, it will default to Data slice %d.
- section
str
Name of the section. If section already exists, the figures will be appended to the end of the section.
- title
str
The title of the slider.
- scale
float
|None
|callable()
Scale the images maintaining the aspect ratio. If None, no scaling is applied. If float, scale will determine the relative scaling (might not work for scale <= 1 depending on font sizes). If function, should take a figure object as input parameter. Defaults to None.
- image_format
str
|None
The image format to be used for the report, can be ‘png’ or ‘svd’. None (default) will use the default specified during Report class construction.
- replacebool
If
True
, figures already present that have the same caption will be replaced. Defaults toFalse
.
- figs
Notes
New in version 0.10.0.
Examples using
add_slider_to_section
:
-
parse_folder
(self, data_path, pattern='*.fif', n_jobs=1, mri_decim=2, sort_sections=True, on_error='warn', image_format=None, render_bem=True, verbose=None)[source]¶ Render all the files in the folder.
- Parameters
- data_path
str
Path to the folder containing data whose HTML report will be created.
- pattern
str
|list
ofstr
Filename pattern(s) to include in the report. Example: [*raw.fif, *ave.fif] will include Raw as well as Evoked files.
- n_jobs
int
The number of jobs to run in parallel (default 1). Requires the joblib package.
- mri_decim
int
Use this decimation factor for generating MRI/BEM images (since it can be time consuming).
- sort_sectionsbool
- If True, sort sections in the order: raw -> events -> epochs
-> evoked -> covariance -> trans -> mri -> forward -> inverse.
- on_error
str
What to do if a file cannot be rendered. Can be ‘ignore’, ‘warn’ (default), or ‘raise’.
- image_format
str
|None
The image format to be used for the report, can be ‘png’ or ‘svd’. None (default) will use the default specified during Report class construction.
New in version 0.15.
- render_bembool
If True (default), try to render the BEM.
New in version 0.16.
- verbosebool,
str
,int
, orNone
If not None, override default verbose level (see
mne.verbose()
and Logging documentation for more). Defaults to self.verbose.
- data_path
Examples using
parse_folder
:
-
remove
(self, caption, section=None)[source]¶ Remove a figure from the report.
The figure to remove is searched for by its caption. When searching by caption, the section label can be specified as well to narrow down the search. If multiple figures match the search criteria, the last one will be removed.
Any empty sections will be removed as well.
-
save
(self, fname=None, open_browser=True, overwrite=False)[source]¶ Save the report and optionally open it in browser.
- Parameters
- fname
str
|None
File name of the report. If the file name ends in ‘.h5’ or ‘.hdf5’, the report is saved in HDF5 format, so it can later be loaded again with
open_report()
. If the file name ends in anything else, the report is rendered to HTML. IfNone
, the report is saved to ‘report.html’ in the current working directory. Defaults toNone
.- open_browserbool
When saving to HTML, open the rendered HTML file browser after saving if True. Defaults to True.
- overwritebool
If True, overwrite report if it already exists. Defaults to False.
- fname
- Returns
- fname
str
The file name to which the report was saved.
- fname
Examples using
save
: