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

Conversation

scholzri
Copy link
Contributor

Fixes #12905

This PR enhances the functionality of mne.viz.plot_ica_sources and mne.preprocessing.ICA.plot_sources by introducing a new psd_args argument. This addition allows users to customize the power spectral density (PSD) plot that appears when right-clicking on an ICA label. This change makes these functions consistent with mne.viz.plot_ica_components and mne.preprocessing.ICA.plot_components, which already supports psd_args.

Copy link
Member

@larsoner larsoner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you modify some test that calls ica.plot_sources? Probably a bit annoying to test that it actually has an effect, but you can at least have a smoke test like ica.plot_sources(..., psd_args=dict(...))

@@ -2582,6 +2582,7 @@ def plot_sources(
title=None,
show=True,
block=False,
psd_args=None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be placed after the * otherwise it's technically a backward compat break

mne/viz/ica.py Outdated Show resolved Hide resolved
mne/viz/ica.py Outdated
@@ -44,6 +44,7 @@ def plot_ica_sources(
title=None,
show=True,
block=False,
psd_args=None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also needs to move down

@scholzri
Copy link
Contributor Author

I dont get it. It fails with

FAILED mne/tests/test_docstring_parameters.py::test_docstring_parameters - AssertionError: 1 error found:
mne.preprocessing : mne.preprocessing.ica.ICA.plot_properties : PR03 : Wrong parameters order. Actual: ('inst', 'picks', 'axes', 'dB', 'plot_std', 'log_scale', 'topomap_args', 'image_args', 'figsize', 'show', 'reject', 'reject_by_annotation', 'psd_args', 'estimate', 'verbose'). Documented: ('inst', 'picks', 'axes', 'dB', 'plot_std', 'log_scale', 'topomap_args', 'image_args', 'psd_args', 'figsize', 'show', 'reject', 'reject_by_annotation', 'estimate', 'verbose')

but didnt I revert this accidental change here: dd5091a

figsize=None,
show=True,
reject="auto",
reject_by_annotation=True,
*,
psd_args=None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one should move back up because it was already there.

Incidentally the error is about this order changing without the docstring also changing to reflect that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... in other words dd5091a only reverted one of the two accidental changes, this is the other one: eb6ea0f

Copy link
Member

@larsoner larsoner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed a commit to fix the ordering error, marking for merge-when-green. Thanks in advance @scholzri !

@larsoner larsoner enabled auto-merge (squash) October 23, 2024 11:56
@larsoner larsoner merged commit c63da99 into mne-tools:main Oct 23, 2024
28 checks passed
@scholzri
Copy link
Contributor Author

Thank you! @larsoner

larsoner added a commit to larsoner/mne-python that referenced this pull request Oct 28, 2024
* upstream/main: (824 commits)
  Add `psd_args` to `plot_ica_sources` and `ICA.plot_sources` (mne-tools#12912)
  Fix GDF NumPy >= 2 (mne-tools#12909)
  [pre-commit.ci] pre-commit autoupdate (mne-tools#12908)
  ENH: Improve report usability (mne-tools#12901)
  MAINT: Avoid problematic PySide6 (mne-tools#12902)
  Sync README dependencies with pyproject.toml (mne-tools#12890)
  remove trailing slash from pybv base URL [ci skip] (mne-tools#12892)
  Cast tuple of filenames to list to improve error handling (mne-tools#12891)
  Website (mne-tools#12885)
  [pre-commit.ci] pre-commit autoupdate (mne-tools#12888)
  BUG: Fix bugs with coreg (mne-tools#12884)
  Bump mamba-org/setup-micromamba from 1 to 2 in the actions group (mne-tools#12887)
  Update spacing for comments in pyproject.toml (mne-tools#12886)
  make HTML repr for Forward match others (mne-tools#12883)
  MAINT: Linkchecks [circle deploy] (mne-tools#12882)
  Update roadmap (mne-tools#12872)
  [MRG] Require good and bad channels when creating a SpectrumArray object (mne-tools#12877)
  [pre-commit.ci] pre-commit autoupdate (mne-tools#12879)
  MAINT: Update code credit (mne-tools#12880)
  BUG: Fix bug with Path casting (mne-tools#12878)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add psd_args parameter to mne.preprocessing.ICA.plot_sources
2 participants