osl_ephys.preprocessing.plot_ica#

Plotting functions for ICA.

Attributes#

backends_to_try

logger

backend

Classes#

osl_MNEBrowseFigure

OSL's adaptatation of MNE's mne.viz._mpl_figure.MNEBrowseFigure that

Functions#

plot_ica(ica, inst[, picks, start, stop, title, show, ...])

osl-ephys' adaptation of MNE's mne.preprocessing.ICA.plot_sources function to

_plot_sources(ica, inst, picks, exclude, start, stop, ...)

Adaptation of MNE's mne.preprocessing.ica._plot_sources function to allow for OSL additions.

_get_browser(**kwargs)

OSL Adaptation of MNE's mne.viz._figure._get_browser function

_init_browser(backend, **kwargs)

flatten_recursive(lst)

Flatten a list using recursion.

_plot_ica_sources_evoked(evoked, picks, exclude, ...)

Plot average over epochs in ICA space.

Module Contents#

osl_ephys.preprocessing.plot_ica.backends_to_try = ['Qt5Agg', 'QtAgg', 'GTK3Agg', 'GTK4Agg', 'macosx', 'TkAgg', 'GTK3Cairo', 'GTK4Cairo', 'wxAgg'][source]#
osl_ephys.preprocessing.plot_ica.logger = None[source]#
osl_ephys.preprocessing.plot_ica.plot_ica(ica, inst, picks=None, start=None, stop=None, title=None, show=True, block=False, show_first_samp=False, show_scrollbars=True, time_format='float', n_channels=10, bad_labels_list=['eog', 'ecg', 'emg', 'hardware', 'other'])[source]#

osl-ephys’ adaptation of MNE’s mne.preprocessing.ICA.plot_sources function to plot estimated latent sources given the unmixing matrix.

Typical usecases:

  1. plot evolution of latent sources over time based on (Raw input)

  2. plot latent source around event related time windows (Epochs input)

  3. plot time-locking in ICA space (Evoked input)

Parameters:
  • ica (mne.preprocessing.ICA.) – The ICA solution.

  • inst (mne.io.Raw, mne.Epochs, or mne.Evoked.) – The object to plot the sources from.

  • picks (str) – Channel types to pick.

  • start (float | int | None) – If inst is a mne.io.Raw or an mne.Evoked object, the first and last time point (in seconds) of the data to plot. If inst is a mne.io.Raw object, start=None and stop=None will be translated into start=0. and stop=3., respectively. For mne.Evoked, None refers to the beginning and end of the evoked signal. If inst is an mne.Epochs object, specifies the index of the first and last epoch to show.

  • stop (float | int | None) – If inst is a mne.io.Raw or an mne.Evoked object, the first and last time point (in seconds) of the data to plot. If inst is a mne.io.Raw object, start=None and stop=None will be translated into start=0. and stop=3., respectively. For mne.Evoked, None refers to the beginning and end of the evoked signal. If inst is an mne.Epochs object, specifies the index of the first and last epoch to show.

  • title (str | None) – The window title. If None a default is provided.

  • show (bool) – Show figure if True.

  • block (bool) – Whether to halt program execution until the figure is closed. Useful for interactive selection of components in raw and epoch plotter. For evoked, this parameter has no effect. Defaults to False.

  • show_first_samp (bool) – If True, show time axis relative to the raw.first_samp.

  • n_channels (int) – Number of channels to show at the same time (default: 10)

  • bad_labels_list (list of str) – list of bad labels to show in the bad labels list that can be used to mark the type of bad component. Defaults to ["eog", "ecg", "emg", "hardware", "other"].

Returns:

fig – The figure.

Return type:

instance of Figure

Notes

For raw and epoch instances, it is possible to select components for exclusion by clicking on the line. The selected components are added to ica.exclude on close.

New in version 0.10.0.

osl_ephys.preprocessing.plot_ica._plot_sources(ica, inst, picks, exclude, start, stop, show, title, block, show_scrollbars, show_first_samp, time_format, n_channels, bad_labels_list)[source]#

Adaptation of MNE’s mne.preprocessing.ica._plot_sources function to allow for OSL additions.

osl_ephys.preprocessing.plot_ica.backend = None[source]#
osl_ephys.preprocessing.plot_ica._get_browser(**kwargs)[source]#

OSL Adaptation of MNE’s mne.viz._figure._get_browser function that instantiate a new MNE browse-style figure.

osl_ephys.preprocessing.plot_ica._init_browser(backend, **kwargs)[source]#
class osl_ephys.preprocessing.plot_ica.osl_MNEBrowseFigure(inst, figsize, ica=None, xlabel='Time (s)', **kwargs)[source]#

Bases: mne.viz._mpl_figure.MNEBrowseFigure

OSL’s adaptatation of MNE’s mne.viz._mpl_figure.MNEBrowseFigure that creates an interactive figure with scrollbars, for data browsing.

backend_name = 'matplotlib'[source]#
_update_picks()[source]#

Compute which channel indices to show.

_draw_traces()[source]#

Draw (or redraw) the channel data.

plot_topos(ica, ax_topo, picks)[source]#
_keypress(event)[source]#

Handle keypress events.

_on_mouse_press(event)[source]#

Handle mouse clicks for jumping the vertical scrollbar selection.

_update_vscroll()[source]#

Update the vertical scrollbar (channel) selection indicator.

_close(event)[source]#

Handle close events (via keypress or window [x]).

osl_ephys.preprocessing.plot_ica.flatten_recursive(lst)[source]#

Flatten a list using recursion.

osl_ephys.preprocessing.plot_ica._plot_ica_sources_evoked(evoked, picks, exclude, title, show, ica, labels=None, n_channels=10, bad_labels_list=None)[source]#

Plot average over epochs in ICA space.

Parameters:
  • evoked (instance of mne.Evoked) – The Evoked to be used.

  • fitted. (%(picks_base)s all sources in the order as) –

  • exclude (array-like of int) – The components marked for exclusion. If None (default), ICA.exclude will be used.

  • title (str) – The figure title.

  • show (bool) – Show figure if True.

  • labels (None | dict) – The ICA labels attribute.