Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add psd_args to plot_ica_sources and ICA.plot_sources #12912

Merged
merged 10 commits into from
Oct 23, 2024
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
Loading