mne.viz.plot_epochs

mne.viz.plot_epochs(epochs, picks=None, scalings=None, n_epochs=20, n_channels=20, title=None, events=None, event_colors=None, show=True, block=False)[source]

Visualize epochs.

Bad epochs can be marked with a left click on top of the epoch. Bad channels can be selected by clicking the channel name on the left side of the main axes. Calling this function drops all the selected bad epochs as well as bad epochs marked beforehand with rejection parameters.

Parameters:

epochs : instance of Epochs

The epochs object

picks : array-like of int | None

Channels to be included. If None only good data channels are used. Defaults to None

scalings : dict | ‘auto’ | None

Scaling factors for the traces. If any fields in scalings are ‘auto’, the scaling factor is set to match the 99.5th percentile of a subset of the corresponding data. If scalings == ‘auto’, all scalings fields are set to ‘auto’. If any fields are ‘auto’ and data is not preloaded, a subset of epochs up to 100mb will be loaded. If None, defaults to:

dict(mag=1e-12, grad=4e-11, eeg=20e-6, eog=150e-6, ecg=5e-4,
     emg=1e-3, ref_meg=1e-12, misc=1e-3, stim=1, resp=1, chpi=1e-4)

n_epochs : int

The number of epochs per view. Defaults to 20.

n_channels : int

The number of channels per view. Defaults to 20.

title : str | None

The title of the window. If None, epochs name will be displayed. Defaults to None.

events : None, array, shape (n_events, 3)

Events to show with vertical bars. If events are provided, the epoch numbers are not shown to prevent overlap. You can toggle epoch numbering through options (press ‘o’ key). You can use mne.viz.plot_events() as a legend for the colors. By default, the coloring scheme is the same.

Warning

If the epochs have been resampled, the events no longer align with the data.

New in version 0.14.0.

event_colors : None, dict

Dictionary of event_id value and its associated color. If None, colors are automatically drawn from a default list (cycled through if number of events longer than list of default colors). Uses the same coloring scheme as mne.viz.plot_events().

New in version 0.14.0.

show : bool

Show figure if True. Defaults to True

block : bool

Whether to halt program execution until the figure is closed. Useful for rejecting bad trials on the fly by clicking on an epoch. Defaults to False.

Returns:

fig : Instance of matplotlib.figure.Figure

The figure.

Notes

The arrow keys (up/down/left/right) can be used to navigate between channels and epochs and the scaling can be adjusted with - and + (or =) keys, but this depends on the backend matplotlib is configured to use (e.g., mpl.use(TkAgg) should work). Full screen mode can be toggled with f11 key. The amount of epochs and channels per view can be adjusted with home/end and page down/page up keys. These can also be set through options dialog by pressing o key. h key plots a histogram of peak-to-peak values along with the used rejection thresholds. Butterfly plot can be toggled with b key. Right mouse click adds a vertical line to the plot. Click ‘help’ button at bottom left corner of the plotter to view all the options.

New in version 0.10.0.