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, projs=False, verbose=None)[source]

Object for rendering HTML.

Parameters
info_fnameNone | str

Name of the file containing the info dictionary.

subjects_dirstr | None

The path to the freesurfer subjects reconstructions. It corresponds to Freesurfer environment variable SUBJECTS_DIR.

subjectstr | None

Subject name.

titlestr

Title of the report.

cov_fnameNone | str

Name of the file containing the noise covariance.

baselineNone | tuple of length 2

The time interval to consider as “baseline” when applying baseline correction. If None, do not apply baseline correction. If a tuple (a, b), the interval is between a and b (in seconds), including the endpoints. If a is None, the beginning of the data is used; and if b is None, it is set to the end of the interval. If (None, None), the entire time interval is used.

Note

The baseline (a, b) includes both endpoints, i.e. all timepoints t such that a <= t <= b.

Correction is applied in the following way to each channel:

  1. Calculate the mean signal of the baseline period.

  2. Subtract this mean from the entire time period.

For Epochs, this algorithm is run on each epoch individually. Defaults to None, i.e. no baseline correction.

image_formatstr

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 to mne.io.Raw.plot_psd().

New in version 0.17.

projsbool

Whether to include topographic plots of SSP projectors, if present in the data. Defaults to False.

New in version 0.21.

verbosebool, str, int, or None

If not None, override default verbose level (see mne.verbose() and Logging documentation for more). If used, it should be passed as a keyword-argument only.

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__(/)

Return hash(self).

__len__()

Return the number of items in report.

add_bem_to_section(subject[, caption, …])

Render a bem slider html str.

add_figs_to_section(figs, captions[, …])

Append custom user-defined figures.

add_htmls_to_section(htmls, captions[, …])

Append htmls to the report.

add_images_to_section(fnames, captions[, …])

Append custom user-defined images.

add_slider_to_section(figs[, captions, …])

Render a slider of figs to the report.

parse_folder(data_path[, pattern, n_jobs, …])

Render all the files in the folder.

remove(caption[, section])

Remove a figure from the report.

save([fname, open_browser, overwrite])

Save the report and optionally open it in browser.

__len__()[source]

Return the number of items in report.

add_bem_to_section(subject, caption='BEM', section='bem', decim=2, n_jobs=1, subjects_dir=None, replace=False)[source]

Render a bem slider html str.

Parameters
subjectstr

Subject name.

captionstr

A caption for the bem.

sectionstr

Name of the section. If section already exists, the bem will be appended to the end of the section.

decimint

Use this decimation factor for generating MRI/BEM images (since it can be time consuming).

n_jobsint

The number of jobs to run in parallel (default 1). Requires the joblib package.

subjects_dirstr | None

The path to the freesurfer subjects reconstructions. It corresponds to Freesurfer environment variable SUBJECTS_DIR.

replacebool

If True, figures already present that have the same caption will be replaced. Defaults to False.

Notes

New in version 0.9.0.

add_figs_to_section(figs, captions, section='custom', scale=None, image_format=None, comments=None, replace=False)[source]

Append custom user-defined figures.

Parameters
figsmatplotlib.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, or numpy.ndarray.

captionsstr | list of str

A caption or a list of captions to the figures.

sectionstr

Name of the section to place the figure in. If section already exists, the figures will be appended to the end of the section.

scalefloat | 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_formatstr | 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.

commentsNone | str | list of str

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 to False.

Examples using add_figs_to_section:

add_htmls_to_section(htmls, captions, section='custom', replace=False)[source]

Append htmls to the report.

Parameters
htmlsstr | list of str

An html str or a list of html str.

captionsstr | list of str

A caption or a list of captions to the htmls.

sectionstr

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 to False.

Notes

New in version 0.9.0.

add_images_to_section(fnames, captions, scale=None, section='custom', comments=None, replace=False)[source]

Append custom user-defined images.

Parameters
fnamesstr | list of str

A filename or a list of filenames from which images are read. Images can be PNG, GIF or SVG.

captionsstr | list of str

A caption or a list of captions to the images.

scalefloat | None

Scale the images maintaining the aspect ratio. Defaults to None. If None, no scaling will be applied.

sectionstr

Name of the section. If section already exists, the images will be appended to the end of the section.

commentsNone | str | list of str

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 to False.

add_slider_to_section(figs, captions=None, section='custom', title='Slider', scale=None, image_format=None, replace=False)[source]

Render a slider of figs to the report.

Parameters
figslist of Figure

Each figure in the list can be an instance of matplotlib.figure.Figure, mayavi.core.api.Scene, or numpy.ndarray. Must have at least 2 elements.

captionslist of str | list of float | 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.

sectionstr

Name of the section. If section already exists, the figures will be appended to the end of the section.

titlestr

The title of the slider.

scalefloat | 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_formatstr | 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 to False.

Notes

New in version 0.10.0.

Examples using add_slider_to_section:

parse_folder(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_pathstr

Path to the folder containing data whose HTML report will be created.

patternstr | list of str

Filename pattern(s) to include in the report. Example: [*raw.fif, *ave.fif] will include Raw as well as Evoked files.

n_jobsint

The number of jobs to run in parallel (default 1). Requires the joblib package.

mri_decimint

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_errorstr

What to do if a file cannot be rendered. Can be ‘ignore’, ‘warn’ (default), or ‘raise’.

image_formatstr | 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, or None

If not None, override default verbose level (see mne.verbose() and Logging documentation for more). If used, it should be passed as a keyword-argument only. Defaults to self.verbose.

Examples using parse_folder:

remove(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.

Parameters
captionstr

If set, search for the figure by caption.

sectionstr | None

If set, limit the search to the section with the given label.

Returns
removed_indexint | None

The integer index of the figure that was removed, or None if no figure matched the search criteria.

save(fname=None, open_browser=True, overwrite=False)[source]

Save the report and optionally open it in browser.

Parameters
fnamestr | 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. If None, the report is saved to ‘report.html’ in the current working directory. Defaults to None.

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.

Returns
fnamestr

The file name to which the report was saved.

Examples using save: