Skip to content

Commit

Permalink
Add psd_args to plot_ica_sources and ICA.plot_sources (#12912)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
scholzri and pre-commit-ci[bot] authored Oct 23, 2024
1 parent 97f5b9c commit c63da99
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/changes/devel/12912.newfeature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added the ``psd_args`` argument to :func:`mne.viz.plot_ica_sources` and :meth:`mne.preprocessing.ICA.plot_sources`, by `Richard Scholz`_.
2 changes: 2 additions & 0 deletions mne/preprocessing/ica.py
Original file line number Diff line number Diff line change
Expand Up @@ -2588,6 +2588,7 @@ def plot_sources(
precompute=None,
use_opengl=None,
*,
psd_args=None,
theme=None,
overview_mode=None,
splash=True,
Expand All @@ -2601,6 +2602,7 @@ def plot_sources(
title=title,
show=show,
block=block,
psd_args=psd_args,
show_first_samp=show_first_samp,
show_scrollbars=show_scrollbars,
time_format=time_format,
Expand Down
1 change: 1 addition & 0 deletions mne/viz/_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ def _create_ica_properties_fig(self, idx):
self.mne.ica_inst,
picks=pick,
axes=axes,
psd_args=self.mne.psd_args,
precomputed_data=self.mne.data_ica_properties,
show=False,
)
Expand Down
10 changes: 10 additions & 0 deletions mne/viz/ica.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def plot_ica_sources(
precompute=None,
use_opengl=None,
*,
psd_args=None,
theme=None,
overview_mode=None,
splash=True,
Expand Down Expand Up @@ -91,6 +92,12 @@ def plot_ica_sources(
%(time_format)s
%(precompute)s
%(use_opengl)s
psd_args : dict | None
Dictionary of arguments to pass to :meth:`~mne.Epochs.compute_psd` in
interactive mode. Ignored if ``inst`` is not supplied. If ``None``,
nothing is passed. Defaults to ``None``.
.. versionadded:: 1.9
%(theme_pg)s
.. versionadded:: 1.0
Expand Down Expand Up @@ -133,6 +140,7 @@ def plot_ica_sources(
show=show,
title=title,
block=block,
psd_args=psd_args,
show_first_samp=show_first_samp,
show_scrollbars=show_scrollbars,
time_format=time_format,
Expand Down Expand Up @@ -1284,6 +1292,7 @@ def _plot_sources(
precompute,
use_opengl,
*,
psd_args,
theme=None,
overview_mode=None,
splash=True,
Expand Down Expand Up @@ -1431,6 +1440,7 @@ def _plot_sources(
use_opengl=use_opengl,
theme=theme,
overview_mode=overview_mode,
psd_args=psd_args,
splash=splash,
)
if is_epo:
Expand Down
3 changes: 3 additions & 0 deletions mne/viz/tests/test_ica.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,9 @@ def test_plot_ica_sources(raw_orig, browser_backend, monkeypatch):
leg = ax.get_legend()
assert len(leg.get_texts()) == len(ica.exclude) == 1

# test passing psd_args argument
ica.plot_sources(epochs, psd_args=dict(fmax=50))

# plot with bad channels excluded
ica.exclude = [0]
ica.plot_sources(evoked)
Expand Down

0 comments on commit c63da99

Please sign in to comment.