- MNE version: 0.24.0
- operating system: Linux on Docker
I’m trying to run the MRI reconstruction example without success on a headless installation on Docker
The best attempt following other discussion about 3d visualization and the use of pyvista seems to be the following:
import os
import mne
from pyvista.utilities import xvfb
xvfb.start_xvfb()
mne.viz.set_3d_backend("notebook")
sample_data_folder = mne.datasets.sample.data_path()
subjects_dir = os.path.join(sample_data_folder, 'subjects')
Brain = mne.viz.get_brain_class()
brain = Brain('sample', hemi='lh', surf='pial',
subjects_dir=subjects_dir, size=(800, 600))
brain.add_annotation('aparc.a2009s', borders=False)
With the predefined mne-tools/mne-python-plot docker image I get the following error on a jupyter notebook:
RuntimeError Traceback (most recent call last)
Input In [5], in <module>
7 subjects_dir = os.path.join(sample_data_folder, 'subjects')
8 Brain = mne.viz.get_brain_class()
----> 9 brain = Brain('sample', hemi='lh', surf='pial',
10 subjects_dir=subjects_dir, size=(800, 600))
11 brain.add_annotation('aparc.a2009s', borders=False)
File /opt/conda/lib/python3.9/site-packages/mne/viz/_brain/_brain.py:528, in Brain.__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)
520 mesh = self._layered_meshes[h]
521 self._renderer._silhouette(
522 mesh=mesh._polydata,
523 color=self._silhouette["color"],
(...)
526 decimate=self._silhouette["decimate"],
527 )
--> 528 self._renderer.set_camera(**views_dicts[h][v])
530 self.interaction = interaction
531 self._closed = False
File /opt/conda/lib/python3.9/site-packages/mne/viz/backends/_pyvista.py:599, in _PyVistaRenderer.set_camera(self, azimuth, elevation, distance, focalpoint, roll, reset_camera, rigid)
596 def set_camera(self, azimuth=None, elevation=None, distance=None,
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)
File /opt/conda/lib/python3.9/site-packages/mne/viz/backends/_pyvista.py:996, in _set_3d_view(figure, azimuth, elevation, focalpoint, distance, roll, reset_camera, rigid)
993 if roll is not None:
994 figure.plotter.camera.SetRoll(figure.plotter.camera.GetRoll() + roll)
--> 996 figure.plotter.update()
997 _process_events(figure.plotter)
File /opt/conda/lib/python3.9/site-packages/pyvista/plotting/plotting.py:1538, in BasePlotter.update(self, stime, force_redraw)
1536 update_rate = self.iren.get_desired_update_rate()
1537 if (curr_time - Plotter.last_update_time) > (1.0/update_rate):
-> 1538 self.right_timer_id = self.iren.create_repeating_timer(stime)
1539 self.render()
1540 Plotter.last_update_time = curr_time
File /opt/conda/lib/python3.9/site-packages/pyvista/plotting/render_window_interactor.py:640, in RenderWindowInteractor.create_repeating_timer(self, stime)
638 timer_id = self.interactor.CreateRepeatingTimer(stime)
639 if hasattr(self.interactor, 'ProcessEvents'):
--> 640 self.process_events()
641 else:
642 self.interactor.Start()
File /opt/conda/lib/python3.9/site-packages/pyvista/plotting/render_window_interactor.py:662, in RenderWindowInteractor.process_events(self)
660 # Note: This is only available in VTK 9+
661 if not self.initialized:
--> 662 raise RuntimeError('Render window interactor must be initialized '
663 'before processing events.')
664 self.interactor.ProcessEvents()
RuntimeError: Render window interactor must be initialized before processing events.
Also tried other images setups starting from here Installing MNE-Python — MNE 1.0.dev0 documentation with no luck (at best I get a black canvas)
Thanks in advance