I’m trying to reproduce the Head Model and Forward Computation tutorial, and I was getting the same error: RuntimeError: Render window interactor must be initialized before processing events.
After reading the messages here, I installed pyvistaqt through conda (pyvistaqt conda-forge/noarch::pyvistaqt-0.5.0-pyhd8ed1ab_0), and now I’m getting the following error when executing cell [4] in the tutorial:
Read a total of 3 projection items:
PCA-v1 (1 x 102) idle
PCA-v2 (1 x 102) idle
PCA-v3 (1 x 102) idle
Using lh.seghead for head surface.
Getting helmet for system 306m
Using pyvista 3d backend.
qt.qpa.xcb: QXcbConnection: XCB error: 128 (Unknown), sequence: 418, resource id: 0, major code: 130 (Unknown), minor code: 2
<mne.viz.backends._pyvista._Figure at 0x7fe19a3d9f10>
sklearn: 0.24.2
numba: Not found
nibabel: 3.2.1
nilearn: 0.8.0
dipy: Not found
cupy: Not found
pandas: 1.3.2
mayavi: Not found
pyvista: 0.31.3 {pyvistaqt=0.5.0, OpenGL 3.3 (Core Profile) Mesa 18.3.1 via llvmpipe (LLVM 7.0, 128 bits)}
vtk: 9.0.0
PyQt5: 5.15.4
I often see this when running code on a remote server, and find that the plots actually do work (I can assign the plot to a variable, save them as PDF or PNG, and then view them). In fact, the next line of your “error” shows that the function did in fact return a Figure object:
Can you check whether that works for you? Also please say more about how you’re trying to plot (in a notebook? Interactively in python/ipython with the “pop-up” plot window? are you connected to a remote server? Does the server have a display attached, or is it “headless”?
Thank you for the reply (and sorry for necroposting in the other thread)!
Indeed I noticed that part of the output was the normal stdout with the output of the mne.viz.plot_alignment function. However, I imagined that that object was just empty.
I also was not really sure what this object represented, since the documentation says that mne.viz.plot_alignment returns * instance of [ mayavi.mlab.Figure ]*, and it is clearly returning another object.
I did some inspection on the mne/viz/backends/_pyvista.py and found that the build funciton returns a plotter, so together with the pyvista tutorial I was actually able to plot the figure!
This may help to shed some light in the problem: I installed XQuartz in my macbook and run ssh with -Y so that I can do X11 forwarding. I run the tutorial code in ipython and got the following error when trying to run mne.viz.plot_alignment
I believe XQuartz doesn’t have 3D acceleration support, hence GLX context creation fails. I doubt this is related to the problem you observed on your Linux computer.
That is good to know. Also sorry if I was not clear, but I have always been using the same setup: a macbook BigSur 11.5 as client (with firefox 91.0.2) and a linux Ubuntu 18.04.5 LTS as server.
I fixed my problem by downgrading pyvista to 0.29.1 (last version before 0.30). Following the error stack, I noticed that viewer.layout had no property width on viz/backends/_notebook.py line 352. The object was from the type PIL.Image.Image, which looks like some default class returned by pyvista when it is not happy with the backend (for instance if I change the backend to ipygany, the viewer is from a class from ipygany and not PIL.Image.Image, and it “kinda” works). So I tried a few things to fix the vtk/ipyvtk installation since the backend chosen by MNE is ipyvtk_simple, but nothing worked. I noticed that in the code, for older versions of pyvista, the parameters passed to self.plotter.show were different, so I gave it a shot, and it worked!
I’m still not sure why it doesn’t work with the most recent versions of pyvista, since I have vtk 9.0.0 installed, etc. I even tried to manually install the package ipyvtk-simple, but didn’t work. Thank you for the help (I didn’t need to install pyvistaqt btw, I think in the jupyter/headless server setup, it is better to use the notebook backend and avoid qt).