error when running tutorial example: working-with-seeg-data

Dear,
I am trying to running this tutorial example:
https://mne.tools/stable/auto_tutorials/clinical/20_seeg.html?highlight=seeg#working-with-seeg-data
however, it showed me error message as below:
AttributeError: '_Renderer' object has no attribute '_window_close_connect'

Also when I am trying to run another tutorial example:
https://mne.tools/stable/auto_tutorials/clinical/10_ieeg_localize.html
it also give me error message as: AttributeError: ‘_Renderer’ object has no attribute ‘plotter’
I think it might be package version problem. I am using python3.7.11, mayavi-4.7.4, vtk-9.1.0, numpy 1.21.4.
Could you please advise?

I think this might have something to do with the version of mayavi and vtk.
have a try with

vtk==8.1.2

Or much more recommended, use

conda create --name=mne --channel=conda-forge mne

which is recommended by MNE officially to install all the packages working well with MNE.

1 Like

Hello @Long, as @BarryLiu97 pointed out, we’d suggest to create an entirely new Python environment for MNE in a situation like this. Please follow the official installation instructions you can find on our website.

Best wishes,
Richard

Thanks for your help on this. As suggested, I install MNE with conda using:

conda create --name=mne --channel=conda-forge mne

However, when I walk through this example: https://mne.tools/stable/auto_tutorials/clinical/10_ieeg_localize.html, when I am trying to locate the ieeg with command:

gui = mne.gui.locate_ieeg(raw_ecog.info, subj_trans_ecog, CT_aligned_ecog,
subject=‘sample_ecog’,
subjects_dir=op.join(misc_path, ‘ecog’))

There is no plot showed up, and I can see some message in the console as:

qt.qpa.drawing: Layer-backing can not be explicitly controlled on 10.14 when built against the 10.14 SDK
qt.qpa.window: <QNSWindow: 0x7f945f391c60; contentView=<QNSView: 0x7f945cdf0460; QCocoaWindow(0x6000029563c0, window=QWidgetWindow(0x600003a33c60, name="QWidgetClassWindow"))>> has active key-value observers (KVO)! These will stop working now that the window is recreated, and will result in exceptions when the observers are removed. Break in QCocoaWindow::recreateWindowIfNeeded to debug.
qt.qpa.window: <QNSWindow: 0x7f945f396aa0; contentView=<QNSView: 0x7f945f396690; QCocoaWindow(0x6000029421b0, window=QWidgetWindow(0x600003af1c20, name="QWidgetClassWindow"))>> has active key-value observers (KVO)! These will stop working now that the window is recreated, and will result in exceptions when the observers are removed. Break in QCocoaWindow::recreateWindowIfNeeded to debug.

Plot seems stucked through I can see the MNE icon showed up in my mac dock but can’t be clicked to open.

Hello @Long, which version of macOS is that?

It’s Monterey 12.0.1.

I’m using 12.1, I can try to run your example later today and check if it works for me. The warnings you see actually shouldn’t be the problem…

I will try to upgrade to 12.1 and see. And yes, this message doesn’t looks like the error msg, but still the plot get stucked in my dock and wouldn’t come out. Other plots are working just fine.

I just upgraded to 12.1, not working either. The same result.

Dear Richard,
Have you tried on your machine yet? I am still facing the same problem. Appreciate any feedback.

Could you provide the information returned by mne.sys_info()?
I suspect you are running on old versions of Python/PyQt5.

Here is the output:

mne.sys_info()
Platform:       macOS-12.1-x86_64-i386-64bit
Python:         3.9.7 | packaged by conda-forge | (default, Sep 29 2021, 20:33:18)  [Clang 11.1.0 ]
Executable:     /Users/long/opt/anaconda3/envs/mne/bin/python
CPU:            i386: 4 cores
Memory:         16.0 GB
mne:            0.24.1
numpy:          1.21.4 {blas=NO_ATLAS_INFO, lapack=lapack}
scipy:          1.7.3
matplotlib:     3.5.0 {backend=MacOSX}
sklearn:        1.0.1
numba:          0.53.1
nibabel:        3.2.1
nilearn:        0.8.1
dipy:           1.4.1
cupy:           Not found
pandas:         1.3.4
mayavi:         4.7.2
pyvista:        0.32.1 {OpenGL 4.1 INTEL-18.3.5 via Intel(R) Iris(TM) Plus Graphics 640}
pyvistaqt:      0.5.0
ipyvtklink:     Not found
vtk:            9.0.3
PyQt5:          5.12.3
ipympl:         Not found
mne_qt_browser: 0.1.7
pooch:          v1.5.2

I just update the PyQt5, but sitll can’t open the plot. Here is the new sys_info():

mne.sys_info()
Platform:       macOS-12.1-x86_64-i386-64bit
Python:         3.9.7 | packaged by conda-forge | (default, Sep 29 2021, 20:33:18)  [Clang 11.1.0 ]
Executable:     /Users/long/opt/anaconda3/envs/mne/bin/python
CPU:            i386: 4 cores
Memory:         16.0 GB
mne:            0.24.1
numpy:          1.21.4 {blas=NO_ATLAS_INFO, lapack=lapack}
scipy:          1.7.3
matplotlib:     3.5.0 {backend=MacOSX}
sklearn:        1.0.1
numba:          0.53.1
nibabel:        3.2.1
nilearn:        0.8.1
dipy:           1.4.1
cupy:           Not found
pandas:         1.3.4
mayavi:         4.7.2
pyvista:        0.32.1 {OpenGL 4.1 INTEL-18.3.5 via Intel(R) Iris(TM) Plus Graphics 640}
pyvistaqt:      0.5.0
ipyvtklink:     Not found
vtk:            9.0.3
PyQt5:          5.15.6
ipympl:         Not found
mne_qt_browser: 0.1.7
pooch:          v1.5.2

I think I know where goes wrong.
When I finish plotting the first plot with viewer = T1.orthoview() and close it, error msg will show up as:

Traceback (most recent call last):
  File "/Users/long/opt/anaconda3/envs/mne/lib/python3.9/site-packages/matplotlib/cbook/__init__.py", line 287, in process
    func(*args, **kwargs)
TypeError: _cleanup() takes 1 positional argument but 2 were given

Then I run mne.gui.locate_ieeg, and it will never show up. However, if I don’t close the first plot, and then go ahead and run the locate_ieeg, this ieeg plot will show up. But since the first plot is always active, I can’t actually bring the second plot forward. So we still need to find a way to close the first plot and working on the second one.
Appreciate any help here.

Ok, so the version of Python is fine; and the previous version of PyQt5 was also fine.
You now have updated outside the limits for MNE: pyqt5>=5.10,<5.14; platform_system == "Darwin".

I have a macOS install on Big Sur, so it’s not 12.xx but I can give it a shot later today and see if I’m able to reproduce.

Never mind, I can reproduce this TypeError: _cleanup() takes 1 positional argument but 2 were given on Windows as well with the current dev version of MNE, but it looks like a bug in nibabel: AttributeError raised in OrthoSlicer3D · Issue #920 · nipy/nibabel · GitHub
Maybe you could try older versions of matplotlib… Or comment this line to skip this problematic plot.

I don’t get the last part however:

But since the first plot is always active, I can’t actually bring the second plot forward. So we still need to find a way to close the first plot and working on the second one.

Each plot opens in a separate free window, for my case I could close the figure and continue… and then when trying to use mne.gui.locate_ieeg I had wrong versions for some dependencies and broke my VTK install :sweat_smile:

I tried go ahead and call mne.gui.locate_ieeg, however no plot will show up if I do not call the first problematic plot. Very strange. Can you please try on you machine?

For the last part, I mean when I had the problematic plot and locate_ieeg open at the same time, the first problematic plot will always keep active and stay on top of the other plots even after I click on the locate_ieeg plot.

I will try old version matplotlib later.

I have tried matplotlib from 3.1 to 3.5. None of them work well for this tutorial example. Actually, the _cleanup() error doesn’t bother me, what I really want is the mne.git.locate_ieeg.