Skip to content

ENH: Add public LayeredMesh and brain.layered_meshes#13970

Merged
larsoner merged 28 commits into
mne-tools:mainfrom
payamsash:brain-streaming-api
Jun 25, 2026
Merged

ENH: Add public LayeredMesh and brain.layered_meshes#13970
larsoner merged 28 commits into
mne-tools:mainfrom
payamsash:brain-streaming-api

Conversation

@payamsash

Copy link
Copy Markdown
Contributor

Reference issue (if any)

#13949

What does this implement/fix?

Adds the streaming API discussed in the issue:

  • _LayeredMesh changed to LayeredMesh (public, with _LayeredMesh alias kept for compat)
  • LayeredMesh.smooth_mat: sparse matrix applied automatically in add_overlay/update_overlay
  • Brain.add_data(key="data"): named overlays
  • Brain.layered_meshes : access the mesh dict directly
  • set_data_smoothing() now syncs smooth_mat onto the mesh
  • LayeredMesh exported from mne.viz

Additional information

  • "I implemented the code changes myself, and Claude Sonnet 4.6 reviewed it."

@welcome

welcome Bot commented Jun 20, 2026

Copy link
Copy Markdown

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

@payamsash payamsash requested a review from agramfort as a code owner June 20, 2026 15:38
Comment thread mne/viz/_brain/_brain.py Outdated
Comment thread mne/viz/_brain/_brain.py
Comment thread mne/viz/_brain/_brain.py Outdated
Comment thread mne/viz/_3d_overlay.py
Comment thread mne/viz/_3d_overlay.py Outdated
Comment thread mne/viz/_3d_overlay.py Outdated
Comment thread mne/viz/_3d_overlay.py Outdated
Comment thread mne/viz/_3d_overlay.py
@larsoner

Copy link
Copy Markdown
Member

Oh and I forgot to add... we'll want some updated tests. It looks like some are already failing, see for example

https://github.com/mne-tools/mne-python/actions/runs/27902788239/job/82758652120?pr=13970#step:23:6463

Which suggests you need to make things private or add docstrings. I think map should be private and update public?

Then you'll want to modify an existing test to make use of the basics of the API. I'd take some existing test in test_brain.py that calls add_data and make sure you can access the added LayeredMesh to do what you want -- set some data, and call update. (Modifying an existing test is preferred over making a new test because our existing tests already take ages to run, so piggybacking on some existing ones here is best!)

Typically we also want to showcase this functionality in an updated example... but this is niche enough that I think it's not 100% needed here. You could update something in the Brain example if you were motivated though!

@larsoner larsoner mentioned this pull request Jun 22, 2026
payamsash and others added 9 commits June 22, 2026 20:06
Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
Comment thread mne/viz/_3d_overlay.py

@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.

I'll push the suggestion then merge once the example renders and looks okay. Thanks in advance @payamsash !

Comment thread examples/visualization/brain.py
@larsoner larsoner enabled auto-merge (squash) June 25, 2026 16:17
@larsoner

Copy link
Copy Markdown
Member

Rendered better this time so marking for merge-when-green, thanks in advance @payamsash !

@larsoner larsoner merged commit d2a7a69 into mne-tools:main Jun 25, 2026
32 checks passed
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.

4 participants