Skip to content

Commit c63da99

Browse files
Add psd_args to plot_ica_sources and ICA.plot_sources (#12912)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 97f5b9c commit c63da99

File tree

5 files changed

+17
-0
lines changed

5 files changed

+17
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added the ``psd_args`` argument to :func:`mne.viz.plot_ica_sources` and :meth:`mne.preprocessing.ICA.plot_sources`, by `Richard Scholz`_.

mne/preprocessing/ica.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2588,6 +2588,7 @@ def plot_sources(
25882588
precompute=None,
25892589
use_opengl=None,
25902590
*,
2591+
psd_args=None,
25912592
theme=None,
25922593
overview_mode=None,
25932594
splash=True,
@@ -2601,6 +2602,7 @@ def plot_sources(
26012602
title=title,
26022603
show=show,
26032604
block=block,
2605+
psd_args=psd_args,
26042606
show_first_samp=show_first_samp,
26052607
show_scrollbars=show_scrollbars,
26062608
time_format=time_format,

mne/viz/_figure.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ def _create_ica_properties_fig(self, idx):
534534
self.mne.ica_inst,
535535
picks=pick,
536536
axes=axes,
537+
psd_args=self.mne.psd_args,
537538
precomputed_data=self.mne.data_ica_properties,
538539
show=False,
539540
)

mne/viz/ica.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def plot_ica_sources(
5050
precompute=None,
5151
use_opengl=None,
5252
*,
53+
psd_args=None,
5354
theme=None,
5455
overview_mode=None,
5556
splash=True,
@@ -91,6 +92,12 @@ def plot_ica_sources(
9192
%(time_format)s
9293
%(precompute)s
9394
%(use_opengl)s
95+
psd_args : dict | None
96+
Dictionary of arguments to pass to :meth:`~mne.Epochs.compute_psd` in
97+
interactive mode. Ignored if ``inst`` is not supplied. If ``None``,
98+
nothing is passed. Defaults to ``None``.
99+
100+
.. versionadded:: 1.9
94101
%(theme_pg)s
95102
96103
.. versionadded:: 1.0
@@ -133,6 +140,7 @@ def plot_ica_sources(
133140
show=show,
134141
title=title,
135142
block=block,
143+
psd_args=psd_args,
136144
show_first_samp=show_first_samp,
137145
show_scrollbars=show_scrollbars,
138146
time_format=time_format,
@@ -1284,6 +1292,7 @@ def _plot_sources(
12841292
precompute,
12851293
use_opengl,
12861294
*,
1295+
psd_args,
12871296
theme=None,
12881297
overview_mode=None,
12891298
splash=True,
@@ -1431,6 +1440,7 @@ def _plot_sources(
14311440
use_opengl=use_opengl,
14321441
theme=theme,
14331442
overview_mode=overview_mode,
1443+
psd_args=psd_args,
14341444
splash=splash,
14351445
)
14361446
if is_epo:

mne/viz/tests/test_ica.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,9 @@ def test_plot_ica_sources(raw_orig, browser_backend, monkeypatch):
370370
leg = ax.get_legend()
371371
assert len(leg.get_texts()) == len(ica.exclude) == 1
372372

373+
# test passing psd_args argument
374+
ica.plot_sources(epochs, psd_args=dict(fmax=50))
375+
373376
# plot with bad channels excluded
374377
ica.exclude = [0]
375378
ica.plot_sources(evoked)

0 commit comments

Comments
 (0)