Problem with using mne.viz.Brain()

  • MNE version:1.5.1
  • operating system: Windows 10

Hi! I am new with code and mne,and I wish someone kind would help me to solve this problem.
I’m studying the example" Plotting with mne.viz.Brain — MNE 1.6.0 documentation",and when I run this code, an error is generated.

brain_kwargs = dict(alpha=0.1, background="white", cortex="low_contrast")
brain = mne.viz.Brain("sample", subjects_dir=subjects_dir, **brain_kwargs)

stc = mne.read_source_estimate(sample_dir / "sample_audvis-meg")
stc.crop(0.09, 0.1)

kwargs = dict(
    fmin=stc.data.min(),
    fmax=stc.data.max(),
    alpha=0.25,
    smoothing_steps="nearest",
    time=stc.times,
)

brain.add_data(stc.lh_data, hemi="lh", vertices=stc.lh_vertno, **kwargs)
brain.add_data(stc.rh_data, hemi="rh", vertices=stc.rh_vertno, **kwargs)

The visualizations look like this.


An empty model can be obtained by using the mouse wheel.

The correct result should be this:

After I close the window ,the console contents are as follows.

libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
Traceback (most recent call last):
  File "C:\Users\zdy15\PycharmProjects\110\venv\Lib\site-packages\IPython\core\interactiveshell.py", line 3526, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-12-f7be9cad9fac>", line 2, in <module>
    brain = mne.viz.Brain("sample", subjects_dir=subjects_dir, **brain_kwargs)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\zdy15\PycharmProjects\110\venv\Lib\site-packages\mne\viz\_brain\_brain.py", line 469, in __init__
    self.show()
  File "C:\Users\zdy15\PycharmProjects\110\venv\Lib\site-packages\mne\viz\_brain\_brain.py", line 3165, in show
    self._renderer.show()
  File "C:\Users\zdy15\PycharmProjects\110\venv\Lib\site-packages\mne\viz\backends\_notebook.py", line 1597, in show
    viewer.value,
    ^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'value'

I don’t know what the problem is. I tried to uninstall and reinstall MNE, but it didn’t work. I would be grateful if someone could give me some advice.

Hello @wxwwnyzjwx and welcome to the forum!

Could you try to use MNE from one of our standalone installers? I’m wondering if what you’re seeing is caused by some installation problem.

Best wishes,
Richard

Hello Richard,I don’t know if it’s because of the Internet or the browser, I tried many times to download MNE-Python installer for Windows but couldn’t download it successfully. :pensive:I don’t know what I can do for this problem now.
I can run mne.viz.Brain() successfully on another computer, but the visual window is often unresponsive for computer performance reasons.When I import the library from another computer into the computer that reported the error,some new errors arise.I am so confused now. :face_exhaling:

Hello, I’d suggest you could try to download it somewhere else then, maybe at a friend’s or colleague’s computer, and transfer the installer to your computer.

Best of luck,
Richard