Spyder can't return the Brain class

:question: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

:page_facing_up: 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)

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 in Spyder, I did not encounter any issues. Could you try it out as well and see if it raises your problem?

Best,
Mathieu


Thanks for your reply,Mathieu!
I also tried this tutorial,but the surface did’t be anotated. The fig :point_up_2:
My 3d backend is “notebook”. Is there any wrong with my spyder preference or other problems?

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:

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.

1 Like

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

1 Like