question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting RuntimeError: Render window interactor must be initialized before processing events.

See original GitHub issue

Describe the bug

When running the tutorial Compute coherence in source space using a MNE inverse solution, the compiler return an error

RuntimeError: Render window interactor must be initialized before processing events.

at line brain.show_view('lateral')

Actual results

The full tracebackl

---------------------------------------------------------------------------

RuntimeError                              Traceback (most recent call last)

/tmp/ipykernel_23683/1897321839.py in <module>
    139 print('t1')
    140 # Now we can visualize the coherence using the plot method.
--> 141 brain = coh_stc.plot('sample', 'inflated', 'both',
    142                      time_label='Coherence %0.1f Hz',
    143                      subjects_dir=subjects_dir,

~/anaconda3/envs/source_space_mne/lib/python3.9/site-packages/mne/source_estimate.py in plot(self, subject, surface, hemi, colormap, time_label, smoothing_steps, transparent, alpha, time_viewer, subjects_dir, figure, views, colorbar, clim, cortex, size, background, foreground, initial_time, time_unit, backend, spacing, title, show_traces, src, volume_options, view_layout, add_data_kwargs, brain_kwargs, verbose)
    649              src=None, volume_options=1., view_layout='vertical',
    650              add_data_kwargs=None, brain_kwargs=None, verbose=None):
--> 651         brain = plot_source_estimates(
    652             self, subject, surface=surface, hemi=hemi, colormap=colormap,
    653             time_label=time_label, smoothing_steps=smoothing_steps,

<decorator-gen-153> in plot_source_estimates(stc, subject, surface, hemi, colormap, time_label, smoothing_steps, transparent, alpha, time_viewer, subjects_dir, figure, views, colorbar, clim, cortex, size, background, foreground, initial_time, time_unit, backend, spacing, title, show_traces, src, volume_options, view_layout, add_data_kwargs, brain_kwargs, verbose)

~/anaconda3/envs/source_space_mne/lib/python3.9/site-packages/mne/viz/_3d.py in plot_source_estimates(stc, subject, surface, hemi, colormap, time_label, smoothing_steps, transparent, alpha, time_viewer, subjects_dir, figure, views, colorbar, clim, cortex, size, background, foreground, initial_time, time_unit, backend, spacing, title, show_traces, src, volume_options, view_layout, add_data_kwargs, brain_kwargs, verbose)
   1779     else:
   1780         with use_3d_backend(backend):
-> 1781             return _plot_stc(
   1782                 stc, overlay_alpha=alpha, brain_alpha=alpha,
   1783                 vector_alpha=alpha, cortex=cortex, foreground=foreground,

~/anaconda3/envs/source_space_mne/lib/python3.9/site-packages/mne/viz/_3d.py in _plot_stc(stc, subject, surface, hemi, colormap, time_label, smoothing_steps, subjects_dir, views, clim, figure, initial_time, time_unit, background, time_viewer, colorbar, transparent, brain_alpha, overlay_alpha, vector_alpha, cortex, foreground, size, scale_factor, show_traces, src, volume_options, view_layout, add_data_kwargs, brain_kwargs)
   1861                              'mayavi backend')
   1862     with warnings.catch_warnings(record=True):  # traits warnings
-> 1863         brain = Brain(**kwargs)
   1864     del kwargs
   1865 

~/anaconda3/envs/source_space_mne/lib/python3.9/site-packages/mne/viz/_brain/_brain.py in __init__(self, subject_id, hemi, surf, title, cortex, alpha, size, background, foreground, figure, subjects_dir, views, offset, show_toolbar, offscreen, interaction, units, view_layout, silhouette, theme, show)
    526                         decimate=self._silhouette["decimate"],
    527                     )
--> 528                 self._renderer.set_camera(**views_dicts[h][v])
    529 
    530         self.interaction = interaction

~/anaconda3/envs/source_space_mne/lib/python3.9/site-packages/mne/viz/backends/_pyvista.py in set_camera(self, azimuth, elevation, distance, focalpoint, roll, reset_camera, rigid)
    597                    focalpoint='auto', roll=None, reset_camera=True,
    598                    rigid=None):
--> 599         _set_3d_view(self.figure, azimuth=azimuth, elevation=elevation,
    600                      distance=distance, focalpoint=focalpoint, roll=roll,
    601                      reset_camera=reset_camera, rigid=rigid)

~/anaconda3/envs/source_space_mne/lib/python3.9/site-packages/mne/viz/backends/_pyvista.py in _set_3d_view(figure, azimuth, elevation, focalpoint, distance, roll, reset_camera, rigid)
    994         figure.plotter.camera.SetRoll(figure.plotter.camera.GetRoll() + roll)
    995 
--> 996     figure.plotter.update()
    997     _process_events(figure.plotter)
    998 

~/anaconda3/envs/source_space_mne/lib/python3.9/site-packages/pyvista/plotting/plotting.py in update(self, stime, force_redraw)
   1401             update_rate = self.iren.get_desired_update_rate()
   1402             if (curr_time - Plotter.last_update_time) > (1.0/update_rate):
-> 1403                 self.right_timer_id = self.iren.create_repeating_timer(stime)
   1404                 self.render()
   1405                 Plotter.last_update_time = curr_time

~/anaconda3/envs/source_space_mne/lib/python3.9/site-packages/pyvista/plotting/render_window_interactor.py in create_repeating_timer(self, stime)
    607         timer_id = self.interactor.CreateRepeatingTimer(stime)
    608         if hasattr(self.interactor, 'ProcessEvents'):
--> 609             self.process_events()
    610         else:
    611             self.interactor.Start()

~/anaconda3/envs/source_space_mne/lib/python3.9/site-packages/pyvista/plotting/render_window_interactor.py in process_events(self)
    629         # Note: This is only available in VTK 9+
    630         if not self.initialized:
--> 631             raise RuntimeError('Render window interactor must be initialized '
    632                                'before processing events.')
    633         self.interactor.ProcessEvents()

RuntimeError: Render window interactor must be initialized before processing events.

Additional information:

Ubuntu 18.04 Issue occur for both Python 3.7 and 3.9.

Package Version


aiohttp 3.7.4.post0 appdirs 1.4.4 argcomplete 1.12.3 argon2-cffi 20.1.0 async-generator 1.10 async-timeout 3.0.1 attrs 21.2.0 autobahn 21.3.1 Automat 20.2.0 backcall 0.2.0 bleach 4.0.0 certifi 2021.5.30 cffi 1.14.6 chardet 4.0.0 constantly 15.1.0 cryptography 3.4.8 cycler 0.10.0 debugpy 1.4.1 decorator 5.0.9 defusedxml 0.7.1 entrypoints 0.3 hyperlink 21.0.0 idna 3.2 imageio 2.9.0 importlib-metadata 4.8.1 incremental 21.3.0 ipykernel 6.2.0 ipython 7.27.0 ipython-genutils 0.2.0 ipywidgets 7.6.4 jedi 0.18.0 Jinja2 3.0.1 joblib 1.0.1 jsonschema 3.2.0 jupyter 1.0.0 jupyter-client 7.0.1 jupyter-console 6.4.0 jupyter-core 4.7.1 jupyterlab-pygments 0.1.2 jupyterlab-widgets 1.0.0 kiwisolver 1.3.2 MarkupSafe 2.0.1 matplotlib 3.4.3 matplotlib-inline 0.1.2 meshio 4.4.6 mistune 0.8.4 mne 0.23.4 multidict 5.1.0 nbclient 0.5.3 nbconvert 6.1.0 nbformat 5.1.3 nest-asyncio 1.5.1 notebook 6.4.3 numpy 1.21.2 packaging 21.0 pandocfilters 1.4.3 parso 0.8.2 pexpect 4.8.0 pickleshare 0.7.5 Pillow 8.3.2 pip 21.0.1 prometheus-client 0.11.0 prompt-toolkit 3.0.17 ptyprocess 0.7.0 pycparser 2.20 Pygments 2.10.0 pyparsing 2.4.7 PyQt5 5.15.4 PyQt5-Qt5 5.15.2 PyQt5-sip 12.9.0 pyrsistent 0.17.3 python-dateutil 2.8.2 pyvista 0.32.1 pyzmq 22.2.1 qtconsole 5.1.1 QtPy 1.10.0 scikit-learn 1.0 scipy 1.7.1 scooby 0.5.7 Send2Trash 1.8.0 setuptools 58.0.4 six 1.16.0 sklearn 0.0 terminado 0.9.4 testpath 0.5.0 threadpoolctl 2.2.0 tornado 6.1 tqdm 4.62.3 traitlets 5.1.0 Twisted 21.7.0 txaio 21.2.1 typing-extensions 3.10.0.2 vtk 9.0.3 wcwidth 0.2.5 webencodings 0.5.1 wheel 0.37.0 widgetsnbextension 3.5.1 wslink 1.0.7 yarl 1.6.3 zipp 3.5.0 zope.interface 5.4.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
larsonercommented, Sep 28, 2021

It could be VTK 9.0.3. On your 3.7 Python you can use vtk==9.0.1 and see if it helps.

I don’t see pyvistaqt installed, so I’m assuming you want this to run in the notebook? In theory it should auto-detect this, but try putting mne.viz.set_3d_backend('notebook') at the top of the example to see if it helps

0reactions
larsonercommented, Oct 1, 2021

I think we’re good for now, thanks for letting us know it’s working @balandongiv !

Read more comments on GitHub >

github_iconTop Results From Across the Web

vtkRenderWindowInteractor stalling program - Stack Overflow
Calling Start() on a RenderWindowInteractor starts the event loop necessary to execute render events, much as the event loop in a GUI.
Read more >
Tutorial processing - Support & Discussions - MNE Forum
... MNE 0.23.0 documentation, I got an error: RuntimeError: Render window interactor must be initialized before processing events.
Read more >
Continuing processing after interactor (Python) - VTK Discourse
In a pure VTK app, this means that before you call Start() you should set observers for any events you want to process...
Read more >
pyvista/plotting.py at main · pyvista/pyvista - GitHub
EXPERIMENTAL: permit pyvista to kill the render window. KILL_DISPLAY = platform.system() == 'Linux' and os.environ.get('PYVISTA_KILL_DISPLAY').
Read more >
RenderWindowInteractor | vtk.js - Kitware, Inc.
Initialize () must be called prior to enabling/disabling interaction. These methods are used when a window/widget is being shared by multiple renderers and ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found