# Spyder can't return the Brain class

**URL:** <https://mne.discourse.group/t/spyder-cant-return-the-brain-class/5771>\
**Category:** Support & Discussions\
**Created:** [October 21, 2022, 2:24am UTC](https://mne.discourse.group/t/spyder-cant-return-the-brain-class/5771 "2022-10-21T02:24:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![skylar](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@skylar](https://mne.discourse.group/u/skylar)\
**Post date:** [October 21, 2022, 2:24am UTC](https://mne.discourse.group/t/spyder-cant-return-the-brain-class/5771/1 "2022-10-21T02:24:17Z")

</div>

**❓When I use spyder to get a brain class and plot a brain by using Brain, then the PyVista window will show a surface. But , the program will not keep executing when i close the PyVista window . Error rises : ‘NoneType’ object has no attribute 'layout. So I can’t add\_annotation to brain.**

- MNE version: 1.2.1
- operating system: Windows 10

**📄 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)**

---

<div class="post-metadata">

**Author:** ![mscheltienne](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/mscheltienne/32/827_2.png) [@mscheltienne](https://mne.discourse.group/u/mscheltienne)\
**Post date:** [October 21, 2022, 2:48pm UTC](https://mne.discourse.group/t/spyder-cant-return-the-brain-class/5771/2 "2022-10-21T14:48:36Z")

</div>

Hello,

We are going to need a bit more information. We can not reproduce what you experienced with the code snippet you provide. Also, could you please paste the full traceback and not only the last line?

I tried out this tutorial: [Plot a cortical parcellation — MNE 1.2.1 documentation](https://mne.tools/stable/auto_examples/visualization/parcellation.html#sphx-glr-auto-examples-visualization-parcellation-py) in Spyder, I did not encounter any issues. Could you try it out as well and see if it raises your problem?

Best,  
Mathieu

---

<div class="post-metadata">

**Author:** ![skylar](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@skylar](https://mne.discourse.group/u/skylar)\
**Post date:** [October 23, 2022, 2:52am UTC](https://mne.discourse.group/t/spyder-cant-return-the-brain-class/5771/3 "2022-10-23T02:52:18Z")

</div>

![image](https://global.discourse-cdn.com/free1/uploads/mne/original/2X/0/02ebff107ccd3e009ea5e91717dfe9a9b0a91cf0.png)  
Thanks for your reply,Mathieu!  
I also tried this tutorial,but the surface did’t be anotated. The fig 👆  
My 3d backend is “notebook”. Is there any wrong with my spyder preference or other problems?

---

<div class="post-metadata">

**Author:** ![mscheltienne](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/mscheltienne/32/827_2.png) [@mscheltienne](https://mne.discourse.group/u/mscheltienne)\
**Post date:** [October 23, 2022, 8:41am UTC](https://mne.discourse.group/t/spyder-cant-return-the-brain-class/5771/4 "2022-10-23T08:41:22Z")

</div>

In the Spyder preferences: IPython console \>\> Graphics \>\> Graphics backend. I have this set to Qt5.  
For MNE’s backend, let’s try both as I don’t remember which one was working for me and I don’t have the 3D viz dependencies installed on this computer. You can change it with a context manager:

```python
from mne.viz import use_3d_backend

with use_3d_backend("pyvistaqt"):
    # tutorial code

```

If that does not work, I’ll check the exact settings on my laptop on Monday.

---

<div class="post-metadata">

**Author:** ![skylar](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@skylar](https://mne.discourse.group/u/skylar)\
**Post date:** [October 23, 2022, 11:22am UTC](https://mne.discourse.group/t/spyder-cant-return-the-brain-class/5771/5 "2022-10-23T11:22:55Z")

</div>

Thanks，Mathieu.I changed backend from ‘notebook’ to ‘pyvistaqt’ and it worked. 😀  
Thanks again for your help!
