Skip to content

Allow subclasses of FigureClass to be passed to plot_raw/plot_epochs - #13979

Merged
larsoner merged 4 commits into
mne-tools:mainfrom
frankier:allow-figureclass-subclasses
Jul 9, 2026
Merged

Allow subclasses of FigureClass to be passed to plot_raw/plot_epochs#13979
larsoner merged 4 commits into
mne-tools:mainfrom
frankier:allow-figureclass-subclasses

Conversation

@frankier

Copy link
Copy Markdown
Contributor

What does this implement/fix?

This change allows for customization of raw/epoch plots via passing in a subclass of MNEBrowseFigure.

Currently I have achieved this in my own code through monkeypatching. This PR is the first steps towards cleaning things up to make extensions cleaner.

@welcome

welcome Bot commented Jun 23, 2026

Copy link
Copy Markdown

Hello! 👋 Thanks for opening your first pull request here! ❤️ We will try to get back to you soon. 🚴

@frankier
frankier requested a review from larsoner as a code owner June 23, 2026 07:29

@larsoner larsoner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Docs should probably also mention that this param only affects the matplotlib plotting backend.

Do you think it's worth adding some version of this to an advanced raw viz example?

Comment thread doc/changes/dev/13979.newfeature.rst Outdated
Comment thread mne/viz/epochs.py Outdated
Comment thread mne/viz/raw.py Outdated
Comment thread mne/utils/docs.py Outdated
Comment thread mne/io/base.py Outdated
@frankier
frankier force-pushed the allow-figureclass-subclasses branch 2 times, most recently from d5e8ef6 to 98ab4b3 Compare June 24, 2026 09:02
@frankier

Copy link
Copy Markdown
Contributor Author

Okay I've tried to address all of these and added an example

@larsoner larsoner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you see if you can get pytest mne/tests/test_docstring_parameters.py to pass locally? CIs are still unhappy with the ordering

Comment thread doc/changes/dev/13979.newfeature.rst Outdated
@@ -0,0 +1 @@
Allow subclasses of `MNEBrowseFigure` to be passed to plot_raw/plot_epochs, as well as the corresponding `plot(...)` methods of the raw and epochs classes, by :newcontrib:`Frankie Robertson`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

single backtick is default linking mode (which for us is :py:obj: I think), if not adding to public API need code mode

Suggested change
Allow subclasses of `MNEBrowseFigure` to be passed to plot_raw/plot_epochs, as well as the corresponding `plot(...)` methods of the raw and epochs classes, by :newcontrib:`Frankie Robertson`
Allow subclasses of ``MNEBrowseFigure`` to be passed to plot_raw/plot_epochs, as well as the corresponding `plot(...)` methods of the raw and epochs classes, by :newcontrib:`Frankie Robertson`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If you want to keep it this way, you need to add it to the public API + docs, so in doc/api/visualization.rst. This is why CircleCI complains (part of it at least!) Also if you do want to keep it, then let's explicitly link

Suggested change
Allow subclasses of `MNEBrowseFigure` to be passed to plot_raw/plot_epochs, as well as the corresponding `plot(...)` methods of the raw and epochs classes, by :newcontrib:`Frankie Robertson`
Allow subclasses of :class:`mne.viz.MNEBrowseFigure` to be passed to plot_raw/plot_epochs, as well as the corresponding `plot(...)` methods of the raw and epochs classes, by :newcontrib:`Frankie Robertson`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

... and actually this path is a pain because of imports, etc. Lets just make these code...

Comment thread mne/utils/docs.py Outdated
Comment thread examples/visualization/onionskin.py Outdated
Comment thread examples/visualization/onionskin.py Outdated
Comment thread examples/visualization/onionskin.py
@frankier
frankier force-pushed the allow-figureclass-subclasses branch 3 times, most recently from 7a0ff1d to 223c163 Compare July 9, 2026 13:02
 * Allow subclasses of `MNEBrowseFigure` to be passed to plot_raw/plot_epochs, as well as the corresponding `plot(...)` methods of the raw and epochs classes.
 * Add an example showing onionskinning of MEG traces
@frankier
frankier force-pushed the allow-figureclass-subclasses branch from 223c163 to 315feee Compare July 9, 2026 13:02
@frankier
frankier requested a review from larsoner July 9, 2026 13:03
Comment thread mne/utils/docs.py Outdated

docdict["figure_class"] = """
figure_class : class
The backend specific `MNEBrowseFigure` class to use. This is typically used

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
The backend specific `MNEBrowseFigure` class to use. This is typically used
The backend specific :class:`mne.viz.MNEBrowseFigure` class to use. This is typically used

Comment thread doc/changes/dev/13979.newfeature.rst Outdated
@@ -0,0 +1 @@
Allow subclasses of `MNEBrowseFigure` to be passed to plot_raw/plot_epochs, as well as the corresponding `plot(...)` methods of the raw and epochs classes, by :newcontrib:`Frankie Robertson`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

... and actually this path is a pain because of imports, etc. Lets just make these code...

@larsoner

larsoner commented Jul 9, 2026

Copy link
Copy Markdown
Member

Pushed the reST fixes, otherwise LGTM, marking for merge-when-green. Thanks in advance @frankier !

@larsoner
larsoner enabled auto-merge (squash) July 9, 2026 17:08
@larsoner
larsoner merged commit ab77d2c into mne-tools:main Jul 9, 2026
32 checks passed
@welcome

welcome Bot commented Jul 9, 2026

Copy link
Copy Markdown

🎉 Congrats on merging your first pull request! 🥳 Looking forward to seeing more from you in the future! 💪

larsoner added a commit to larsoner/mne-python that referenced this pull request Jul 14, 2026
* upstream/main:
  Make scrollbar handlers draggable (mne-tools#14040)
  [pre-commit.ci] pre-commit autoupdate (mne-tools#14052)
  Warn when Epochs events fall outside the raw data range (mne-tools#12989) (mne-tools#14004)
  Ensure epochs being concatenated have compatible event ids (mne-tools#14051)
  Widen main content area (mne-tools#14015)
  MAINT: remove dead gain/bits/value_range fields from _read_header in … (mne-tools#14047)
  ENH: replace `_get_blocks` binary reader with mffpy Reader API (mne-tools#14043)
  MAINT: Update dependency specifiers (mne-tools#14048)
  [dependabot]: Bump the actions group with 2 updates (mne-tools#14049)
  Simplify doc building with more refleak (mne-tools#14045)
  ENH: add overlay Brain GUI (mne-tools#14031)
  ENH: support multiple simultaneous overlays in Brain.add_data (mne-tools#13995)
  Add option to show a zero line in browser (mne-tools#14018)
  FIX: pass cmap name string not tuple to interactive topomap slider kwargs (mne-tools#14039)
  Doc/add ai policy pointer (mne-tools#14037)
  Allow subclasses of FigureClass to be passed to plot_raw/plot_epochs (mne-tools#13979)
  MAINT: Replace manual PNS binary block reader in `_read_segment_file` with `mffpy` (mne-tools#14030)
larsoner added a commit to sharifhsn/mne-python that referenced this pull request Jul 14, 2026
* upstream/main: (206 commits)
  Improve type checks (mne-tools#14036)
  Make scrollbar handlers draggable (mne-tools#14040)
  [pre-commit.ci] pre-commit autoupdate (mne-tools#14052)
  Warn when Epochs events fall outside the raw data range (mne-tools#12989) (mne-tools#14004)
  Ensure epochs being concatenated have compatible event ids (mne-tools#14051)
  Widen main content area (mne-tools#14015)
  MAINT: remove dead gain/bits/value_range fields from _read_header in … (mne-tools#14047)
  ENH: replace `_get_blocks` binary reader with mffpy Reader API (mne-tools#14043)
  MAINT: Update dependency specifiers (mne-tools#14048)
  [dependabot]: Bump the actions group with 2 updates (mne-tools#14049)
  Simplify doc building with more refleak (mne-tools#14045)
  ENH: add overlay Brain GUI (mne-tools#14031)
  ENH: support multiple simultaneous overlays in Brain.add_data (mne-tools#13995)
  Add option to show a zero line in browser (mne-tools#14018)
  FIX: pass cmap name string not tuple to interactive topomap slider kwargs (mne-tools#14039)
  Doc/add ai policy pointer (mne-tools#14037)
  Allow subclasses of FigureClass to be passed to plot_raw/plot_epochs (mne-tools#13979)
  MAINT: Replace manual PNS binary block reader in `_read_segment_file` with `mffpy` (mne-tools#14030)
  Fix transition bandwidth reported in 'filter too short' error (mne-tools#11406) (mne-tools#14005)
  ENH: Show the current time as a vertical line in plot_evoked_topo (mne-tools#14032)
  ...
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.

2 participants