# Segmentation fault when visualizing the brain

**URL:** <https://mne.discourse.group/t/segmentation-fault-when-visualizing-the-brain/10785>\
**Category:** Support & Discussions\
**Tags:** installation\
**Created:** [February 11, 2025, 12:36pm UTC](https://mne.discourse.group/t/segmentation-fault-when-visualizing-the-brain/10785 "2025-02-11T12:36:55Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![okapi](https://avatars.discourse-cdn.com/v4/letter/o/da6949/32.png) [@okapi](https://mne.discourse.group/u/okapi)\
**Post date:** [February 11, 2025, 12:36pm UTC](https://mne.discourse.group/t/segmentation-fault-when-visualizing-the-brain/10785/1 "2025-02-11T12:36:55Z")

</div>

- MNE version: 1.9.0 (using MNE-Python installers)
- operating system: e.g. macOS 12 / Windows 10 / Ubuntu 18.04

Dear MNE experts,

I have a problem when trying to visualize 3D brains on local computer for all kinds of 3d brain visualizations I tried involving pyvista. To install MNE, I use MNE-Python installers.

As an example, I have the error when running this code example with data provided:  
[https://mne.tools/1.8/auto\_examples/visualization/parcellation.html#sphx-glr-auto-examples-visualization-parcellation-py](https://mne.tools/1.8/auto_examples/visualization/parcellation.html#sphx-glr-auto-examples-visualization-parcellation-py)

Error occurs in this line:

[brain](https://mne.tools/1.8/generated/mne.viz.Brain.html#mne.viz.Brain) = [Brain](https://mne.tools/1.8/generated/mne.viz.Brain.html#mne.viz.Brain)( “fsaverage”, “lh”, “inflated”, [subjects\_dir](https://docs.python.org/3/library/pathlib.html#pathlib.PosixPath)=[subjects\_dir](https://docs.python.org/3/library/pathlib.html#pathlib.PosixPath), cortex=“low\_contrast”, background=“white”, size=(800, 600), )

The error:

Using pyvistaqt 3d backend.  
/usr/lib/python3/dist-packages/spyder/plugins/ipythonconsole/scripts/  
conda-activate.sh: line 18: 9782 Segmentation fault  
(core dumped)  
$CONDA\_ENV\_PYTHON -m spyder\_kernels.console -f $SPYDER\_KERNEL\_SPEC  
Fatal Python error: Segmentation fault  
Main thread:  
Current thread 0x00007d484ca4e600 (most recent call first):  
File “/home/okapi/mne-python/1.9.0\_0/lib/python3.12/site-packages/  
pyvista/plotting/render\_window\_interactor.py”, line 1372 in initialize  
File “/home/okapi/mne-python/1.9.0\_0/lib/python3.12/site-packages/  
pyvistaqt/plotting.py”, line 287 in \_setup\_interactor  
File “/home/okapi/mne-python/1.9.0\_0/lib/python3.12/site-packages/  
pyvistaqt/plotting.py”, line 247 in **init**  
File “/home/okapi/mne-python/1.9.0\_0/lib/python3.12/site-packages/  
pyvistaqt/plotting.py”, line 572 in **init**  
File “/home/okapi/mne-python/1.9.0\_0/lib/python3.12/site-packages/mne/  
viz/backends/\_pyvista.py”, line 150 in \_build  
File “/home/okapi/mne-python/1.9.0\_0/lib/python3.12/site-packages/mne/  
viz/backends/\_pyvista.py”, line 256 in **init**  
File “/home/okapi/mne-python/1.9.0\_0/lib/python3.12/site-packages/mne/  
viz/backends/\_qt.py”, line 1777 in **init**  
File “/home/okapi/mne-python/1.9.0\_0/lib/python3.12/site-packages/mne/  
viz/backends/\_utils.py”, line 391 in func  
File “/home/okapi/mne-python/1.9.0\_0/lib/python3.12/site-packages/mne/  
viz/backends/renderer.py”, line 53 in \_get\_renderer  
File “/home/okapi/mne-python/1.9.0\_0/lib/python3.12/site-packages/mne/  
gui/\_coreg.py”, line 284 in **init**  
File “”, line 12 in **init**  
File “/home/okapi/mne-python/1.9.0\_0/lib/python3.12/site-packages/mne/  
viz/backends/\_utils.py”, line 391 in func  
File “/home/okapi/mne-python/1.9.0\_0/lib/python3.12/site-packages/mne/  
gui/\_gui.py”, line 149 in coregistration  
File “”, line 12 in coregistration  
File “/home/okapi/.config/spyder-py3/temp.py”, line 21 in   
File “/home/okapi/mne-python/1.9.0\_0/lib/python3.12/site-packages/  
spyder\_kernels/py3compat.py”, line 356 in compat\_exec  
File “/home/okapi/mne-python/1.9.0\_0/lib/python3.12/site-packages/  
spyder\_kernels/customize/spydercustomize.py”, line 473 in exec\_code  
File “/home/okapi/mne-python/1.9.0\_0/lib/python3.12/site-packages/  
spyder\_kernels/customize/spydercustomize.py”, line 740 in \_exec\_cell  
File “/home/okapi/mne-python/1.9.0\_0/lib/python3.12/site-packages/  
spyder\_kernels/customize/spydercustomize.py”, line 689 in runcell  
File “/tmp/ipykernel\_9782/1346111906.py”, line 1 in

Which results in restartig the kernel.  
At first, I suspected the issue might be related to my GPU. However, basic 3D visualization seems to work. For example, I tried to display a sphere using pyvista:

import pyvista as pv  
mesh = pv.Sphere()  
p = pv.Plotter()  
p.add\_mesh(mesh)  
mesh.plot()  
p.show()

The sphere renders correctly, and I can interact with it.

As I faced the same error for previous MNE versions too, I suppose it’s not just version-related issue.

I would be very grateful for any help or suggestions!

All the best,  
Viktoria

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [February 15, 2025, 9:53am UTC](https://mne.discourse.group/t/segmentation-fault-when-visualizing-the-brain/10785/2 "2025-02-15T09:53:28Z")

</div>

Hello, which operating system is that?

Best wishes,  
Richard

---

<div class="post-metadata">

**Author:** ![okapi](https://avatars.discourse-cdn.com/v4/letter/o/da6949/32.png) [@okapi](https://mne.discourse.group/u/okapi)\
**Post date:** [February 15, 2025, 10:09am UTC](https://mne.discourse.group/t/segmentation-fault-when-visualizing-the-brain/10785/3 "2025-02-15T10:09:11Z")

</div>

Hello,  
Sorry, I must have removed this info by mistake during editing…  
I have Linux, Ubuntu 24.04.2 LTS

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [February 15, 2025, 10:59am UTC](https://mne.discourse.group/t/segmentation-fault-when-visualizing-the-brain/10785/4 "2025-02-15T10:59:26Z")

</div>

@larsoner Would you have time to look into this?

---

<div class="post-metadata">

**Author:** ![okapi](https://avatars.discourse-cdn.com/v4/letter/o/da6949/32.png) [@okapi](https://mne.discourse.group/u/okapi)\
**Post date:** [February 15, 2025, 10:11pm UTC](https://mne.discourse.group/t/segmentation-fault-when-visualizing-the-brain/10785/5 "2025-02-15T22:11:00Z")

</div>

I think that it’s a problem of 1.9.0 version of MNE, or its installer: I returned back to version 1.7.0 (also Installer) and the error disappeared.  
Also, in 1.9.0 version I had a problem when trying to plot raw file, just raw.plot(): in Spyder I had this error, no interactive window opened: “Using qt as 2D backend. ERROR:root:Cannot activate multiple GUI eventloops”, and in MNE console I had an error when closing interactive window: “RuntimeWarning: Failed to disconnect (None) from signal “triggered()”.”

---

<div class="post-metadata">

**Author:** ![larsoner](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/larsoner/32/3_2.png) [@larsoner](https://mne.discourse.group/u/larsoner)\
**Post date:** [February 18, 2025, 3:54pm UTC](https://mne.discourse.group/t/segmentation-fault-when-visualizing-the-brain/10785/6 "2025-02-18T15:54:08Z")

</div>

Can you run `mne sys_info` or `>>> import mne; mne.sys_info()` ? It should tell us info about your GPU etc. It’s possible it’s not new enough for 3D viz using newer VTK

---

<div class="post-metadata">

**Author:** ![okapi](https://avatars.discourse-cdn.com/v4/letter/o/da6949/32.png) [@okapi](https://mne.discourse.group/u/okapi)\
**Post date:** [February 18, 2025, 4:22pm UTC](https://mne.discourse.group/t/segmentation-fault-when-visualizing-the-brain/10785/7 "2025-02-18T16:22:03Z")

</div>

> [@larsoner](#):
>
> import mne; mne.sys\_info()

Sure, thanks!

Platform Linux-6.11.0-17-generic-x86\_64-with-glibc2.39  
Python 3.12.2 | packaged by conda-forge | (main, Feb 16 2024, 20:50:58) [GCC 12.3.0]  
Executable /home/okapi/mne-python/1.7.1\_0/bin/python  
CPU x86\_64 (16 cores)  
Memory 15.0 GB

Core  
├☒ mne 1.7.1 (outdated, release 1.9.0 is available!)  
├☑ numpy 1.26.4 (OpenBLAS 0.3.27 with 16 threads)  
├☑ scipy 1.13.1  
└☑ matplotlib 3.8.4 (backend=Qt5Agg)

Numerical (optional)  
├☑ sklearn 1.5.0  
├☑ numba 0.59.1  
├☑ nibabel 5.2.1  
├☑ nilearn 0.10.4  
├☑ dipy 1.9.0  
├☑ openmeeg 2.5.11  
├☑ pandas 2.2.2  
├☑ h5io 0.2.3  
├☑ h5py 3.11.0  
└☐ unavailable cupy

Visualization (optional)  
├☑ pyvista 0.43.9 (OpenGL 4.6 (Core Profile) Mesa 24.2.8-1ubuntu1~24.04.1 via AMD Radeon Graphics (radeonsi, renoir, LLVM 19.1.1, DRM 3.59, 6.11.0-17-generic))  
├☑ pyvistaqt 0.11.0  
├☑ vtk 9.2.6  
├☑ qtpy 2.4.1 (PyQt5=5.15.8)  
├☑ ipympl 0.9.4  
├☑ pyqtgraph 0.13.7  
├☑ mne-qt-browser 0.6.3  
├☑ ipywidgets 8.1.3  
├☑ trame\_client 3.1.0  
├☑ trame\_server 3.0.1  
├☑ trame\_vtk 2.8.9  
└☑ trame\_vuetify 2.6.0

Ecosystem (optional)  
├☑ mne-bids 0.15.0  
├☑ mne-nirs 0.6.0  
├☑ mne-features 0.3  
├☑ mne-connectivity 0.7.0  
├☑ mne-icalabel 0.6.0  
├☑ mne-bids-pipeline 1.8.0  
├☑ neo 0.13.0  
├☑ eeglabio 0.0.2-4  
├☑ edfio 0.4.2  
├☑ mffpy 0.9.0  
└☑ pybv 0.7.5

---

<div class="post-metadata">

**Author:** ![larsoner](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/larsoner/32/3_2.png) [@larsoner](https://mne.discourse.group/u/larsoner)\
**Post date:** [February 18, 2025, 4:33pm UTC](https://mne.discourse.group/t/segmentation-fault-when-visualizing-the-brain/10785/8 "2025-02-18T16:33:13Z")

</div>

That must be for the old/working install, can you give the one for the new/broken 1.9 one?

---

<div class="post-metadata">

**Author:** ![okapi](https://avatars.discourse-cdn.com/v4/letter/o/da6949/32.png) [@okapi](https://mne.discourse.group/u/okapi)\
**Post date:** [March 3, 2025, 5:45pm UTC](https://mne.discourse.group/t/segmentation-fault-when-visualizing-the-brain/10785/9 "2025-03-03T17:45:27Z")

</div>

Hello,  
Sorry I was able to uninstall old version and install new one only now.

Here’s the output for 1.9 version:

Platform Linux-6.11.0-17-generic-x86\_64-with-glibc2.39  
Python 3.12.7 | packaged by conda-forge | (main, Oct 4 2024, 16:05:46) [GCC 13.3.0]  
Executable /home/okapi/mne-python/1.9.0\_0/bin/python  
CPU AMD Ryzen 7 5700U with Radeon Graphics (16 cores)  
Memory 15.0 GiB

Core  
├☑ mne 1.9.0 (latest release)  
├☑ numpy 1.26.4 (OpenBLAS 0.3.28 with 16 threads)  
├☑ scipy 1.14.1  
└☑ matplotlib 3.10.0 (backend=module://matplotlib\_inline.backend\_inline)

Numerical (optional)  
├☑ sklearn 1.6.0  
├☑ numba 0.60.0  
├☑ nibabel 5.3.2  
├☑ nilearn 0.11.0  
├☑ dipy 1.10.0  
├☑ openmeeg 2.5.14  
├☑ pandas 2.2.3  
├☑ h5io 0.2.4  
├☑ h5py 3.12.1  
└☐ unavailable cupy

Visualization (optional)  
├☑ pyvista 0.44.2 (OpenGL 4.6 (Core Profile) Mesa 24.2.8-1ubuntu1~24.04.1 via AMD Radeon Graphics (radeonsi, renoir, LLVM 19.1.1, DRM 3.59, 6.11.0-17-generic))  
├☑ pyvistaqt 0.11.1  
├☑ vtk 9.3.1  
├☑ qtpy 2.4.2 (PySide6=6.7.3)  
├☑ ipympl 0.9.5  
├☑ pyqtgraph 0.13.7  
├☑ mne-qt-browser 0.6.3  
├☑ ipywidgets 8.1.5  
├☑ trame\_client 3.5.0  
├☑ trame\_server 3.2.3  
├☑ trame\_vtk 2.8.12  
└☑ trame\_vuetify 2.7.2

Ecosystem (optional)  
├☑ mne-bids 0.16.0  
├☑ mne-nirs 0.7.1  
├☑ mne-features 0.3  
├☑ mne-connectivity 0.7.0  
├☑ mne-icalabel 0.7.0  
├☑ mne-bids-pipeline 1.9.0  
├☑ neo 0.13.4  
├☑ eeglabio 0.0.3  
├☑ edfio 0.4.5  
├☑ mffpy 0.10.0  
└☑ pybv 0.7.6

---

<div class="post-metadata">

**Author:** ![larsoner](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/larsoner/32/3_2.png) [@larsoner](https://mne.discourse.group/u/larsoner)\
**Post date:** [March 5, 2025, 4:22pm UTC](https://mne.discourse.group/t/segmentation-fault-when-visualizing-the-brain/10785/10 "2025-03-05T16:22:00Z")

</div>

Plain PyVista working does suggest it’s not a 3D issue most likely. But plain PyVista doesn’t use Qt, and `Brain` does, so it’s probably a Qt issue.

Does it work if you run your code from a plain `python` console as opposed to running it from Spyder (which it looks like you’re doing)? I wonder if you maybe don’t have Spyder configured properly to use the MNE-Python env correctly somehow

---

<div class="post-metadata">

**Author:** ![okapi](https://avatars.discourse-cdn.com/v4/letter/o/da6949/32.png) [@okapi](https://mne.discourse.group/u/okapi)\
**Post date:** [March 5, 2025, 9:45pm UTC](https://mne.discourse.group/t/segmentation-fault-when-visualizing-the-brain/10785/11 "2025-03-05T21:45:10Z")

</div>

> [@okapi](#):
>
> Also, in 1.9.0 version I had a problem when trying to plot raw file, just raw.plot(): in Spyder I had this error, no interactive window opened: “Using qt as 2D backend. ERROR:root:Cannot activate multiple GUI eventloops”, and in MNE console I had an error when closing interactive window: “RuntimeWarning: Failed to disconnect (None) from signal “triggered()”.”

No, it doesn’t work in console too, and more than that, I could not plot raw file either, so it was not just a problem of 3d brain somehow… I wrote about it in the comment above:

"Also, in 1.9.0 version I had a problem when trying to plot raw file, just raw.plot(): in Spyder I had this error, no interactive window opened: “Using qt as 2D backend. ERROR:root:Cannot activate multiple GUI eventloops”, and in MNE console I had an error when closing interactive window: “RuntimeWarning: Failed to disconnect (None) from signal “triggered()”.”

I don’t understand what can cause such a massive error…

---

<div class="post-metadata">

**Author:** ![larsoner](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/larsoner/32/3_2.png) [@larsoner](https://mne.discourse.group/u/larsoner)\
**Post date:** [March 6, 2025, 7:08pm UTC](https://mne.discourse.group/t/segmentation-fault-when-visualizing-the-brain/10785/12 "2025-03-06T19:08:06Z")

</div>

2D plotting with the mne-qt-browser backend at least uses OpenGL. But both mne-qt-browser and the matplotlib backend will probably depend on having a Qt backend available. So I wonder if your Qt implementation is somehow broken. Another possibility is that it’s a `wayland` issue – if you `echo $XDG_SESSION_DESKTOP` is it xorg or wayland?
