Describe the new feature or enhancement
making mne.viz.Brain usable for real-time streaming applications (neurofeedback, BCI, live source imaging), as suggested in discussion with @larsoner.
Describe your proposed implementation
mne.viz.Brain uses pyvistaqt.BackgroundPlotter under the hood, but the
public API is not designed for repeated scalar updates from a background
thread:
brain.add_data() is designed to be called once, calling it repeatedly (once per analysis window) is not thread-safe because it recreates actors and scalar bars also brain.set_time() does not accept new data only works when the data was preloaded.
MNE-RT uses pyvistaqt.BackgroundPlotter directly, keep a single PolyData mesh, and update mesh["activity"] scalars in-place plus call p.render(), which BackgroundPlotter handles safely from a
non-Qt thread. see link:
Describe possible alternatives
Add a lightweight streaming update API to mne.viz.Brain, for example:
# One-time setup
brain = mne.viz.Brain("fsaverage", hemi="split", surf="inflated")
handle = brain.add_data(stc_empty, colormap="hot", clim=(0, 1))
# Called from any thread
handle.set_scalars(new_vertex_values) # thread-safe scalar swap + render
Or expose the existing PolyData mesh directly so users can update scalars themselves:
brain.lh_mesh["activity"] = new_lh_values
brain.render() # non-blocking
Additional context
No response
Describe the new feature or enhancement
making
mne.viz.Brainusable for real-time streaming applications (neurofeedback, BCI, live source imaging), as suggested in discussion with @larsoner.Describe your proposed implementation
mne.viz.Brainusespyvistaqt.BackgroundPlotterunder the hood, but thepublic API is not designed for repeated scalar updates from a background
thread:
brain.add_data()is designed to be called once, calling it repeatedly (once per analysis window) is not thread-safe because it recreates actors and scalar bars alsobrain.set_time()does not accept new data only works when the data was preloaded.MNE-RT uses
pyvistaqt.BackgroundPlotterdirectly, keep a singlePolyDatamesh, and updatemesh["activity"]scalars in-place plus callp.render(), whichBackgroundPlotterhandles safely from anon-Qt thread. see link:
Describe possible alternatives
Add a lightweight streaming update API to
mne.viz.Brain, for example:Or expose the existing
PolyDatamesh directly so users can update scalars themselves:Additional context
No response