Skip to content

ENH: Viz for spatial filters#13332

Merged
larsoner merged 50 commits into
mne-tools:mainfrom
Genuster:ged-viz
Aug 22, 2025
Merged

ENH: Viz for spatial filters#13332
larsoner merged 50 commits into
mne-tools:mainfrom
Genuster:ged-viz

Conversation

@Genuster
Copy link
Copy Markdown
Contributor

@Genuster Genuster commented Jul 18, 2025

What does this implement/fix?

Adds SpatialFilter container for visualisation of filters, patterns and eigenvalues of GED-based algorithms (CSP, SPoC, SSD, XdawnTransformer) and other linear models (LinearModel).

  • implement plot_filters, plot_patterns, plot_scree
  • make possible to plot inverse_transform'ed filters/patterns in case of pipeline (as get_coef does)
    • make get_coef work with arbitrary step in the pipeline (not only the last LinearModel)
  • cover tests
  • replace CSP's plots with internal functions
  • make existing examples use the container's plotting methods

@wmvanvliet
Copy link
Copy Markdown
Contributor

I'm all for adding nice visualizations for filters/patterns. Suggestion: would a MixedIn pattern make sense here instead of the class you have now?

@Genuster
Copy link
Copy Markdown
Contributor Author

Cheers @wmvanvliet!

My original thought was to make it usable with external spatial filters (PyRiemann transformers, for example).
I also realize now if the relevant transformer is in the middle of the pipeline and I want visualize its filters/patterns after inverse-transform, it would make sense to use a plain function that would instantiate the Viz class instead of adding it as a method to GED/LinearModel.
If I go with Mixin this case would be problematic, as far as I can tell.

Does that make sense? If you have an idea how we can work around it with Mixin, I'd be glad to hear

@Genuster Genuster marked this pull request as ready for review July 30, 2025 08:16
@Genuster Genuster requested a review from larsoner as a code owner July 30, 2025 08:16
Copy link
Copy Markdown
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.

Looks like a good start! Needs some tutorial to show how it's useful though. Bonus points if you can modify some existing example to make it shorter and/or clearer

Comment thread doc/api/visualization.rst Outdated
Comment thread mne/decoding/tests/test_base.py
Comment thread mne/decoding/tests/test_base.py Outdated
Comment thread mne/viz/decoding/ged.py Outdated
Comment thread mne/viz/decoding/ged.py Outdated
Comment thread mne/viz/decoding/ged.py Outdated
Comment thread mne/viz/decoding/ged.py
@Genuster
Copy link
Copy Markdown
Contributor Author

Genuster commented Aug 19, 2025

@larsoner, I think it's ready for the next round!
I didn't add a tutorial specifically for the class, but used most of the functionality across the examples, hope it's enough

Copy link
Copy Markdown
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.

Had a look at CircleCI, and some examples were unchanged (good), and this one looks better (good):

Just a tiny minor things then I think we're good to go!

Comment thread doc/changes/dev/13332.newfeature.rst Outdated
Comment thread mne/decoding/csp.py Outdated
Comment thread mne/decoding/tests/test_base.py Outdated
@Genuster
Copy link
Copy Markdown
Contributor Author

@larsoner, if you don't have additional comments - it's ready ☺️

@larsoner larsoner merged commit 0474b49 into mne-tools:main Aug 22, 2025
32 checks passed
@larsoner
Copy link
Copy Markdown
Member

Thanks @Genuster !

@Genuster Genuster deleted the ged-viz branch August 22, 2025 19:20
@Genuster Genuster mentioned this pull request Aug 23, 2025
7 tasks
zEdS15B3GCwq pushed a commit to zEdS15B3GCwq/mne-python that referenced this pull request Aug 25, 2025
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
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.

3 participants