TypeError: Plotter.__init__() got an unexpected keyword argument 'multi_samples'

Hi!

I have been using MNE to perform the pre-processing of my MEG data. As we’re working in a group, we are using a Jupyter Notebook edited on VisualStudio to run the analyses.

We managed to run the co-registration via IPython directly in bash, but I was looking into adding this step into the notebook, and encountered one error.

Here is the complete code I have:

# Imports
import os
import os.path as op
import mne

# Variables
output_path = 'MEGtrain/'
fs_subject = "fs-06"
subjects_dir = op.join(output_path, 'fs/')
os.environ["SUBJECTS_DIR"] = subjects_dir

# Create head-dense.fif file (this works)
mne.bem.make_watershed_bem(subject = fs_subject, overwrite = True)
mne.bem.make_scalp_surfaces(subject = fs_subject, overwrite = True, force = True)

# Display the hemispheres (this does not work)
Brain = mne.viz.get_brain_class()  # Create a Brain object
brain = Brain(subject, 
        hemi = 'both',  # The hemisphere to visualize (`lh`, `rh`, `both`, or `split`)
        subjects_dir = subjects_dir, 
        size = (800, 600)  # The size of the window in pixels
)
brain.add_annotation('aparc.a2009s', borders = False)
brain.add_head(dense = True)

# Co-registration (this does not work)
mne.gui.coregistration(subject = fs_subject, subjects_dir = subjects_dir)

After trying to create the brain object or performing the co-registration, I get this error message:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[6], line 2
      1 Brain = mne.viz.get_brain_class()  # Create a Brain object
----> 2 brain = Brain(subject, 
      3         hemi = 'both',  # The hemisphere to visualize (`lh`, `rh`, `both`, or `split`)
      4         subjects_dir = subjects_dir, 
      5         size = (800, 600)  # The size of the window in pixels
      6 )
      7 brain.add_annotation('aparc.a2009s', borders = False)
      8 brain.add_head(dense = True)

File /megtrain_env/.conda/lib/python3.10/site-packages/mne/viz/_brain/_brain.py:409, in Brain.__init__(***failed resolving arguments***)
    407 logger.debug(f"Hemi offset: {offset}")
    408 _validate_type(theme, (str, None), "theme")
--> 409 self._renderer = _get_renderer(
    410     name=self._title, size=size, bgcolor=self._bg_color, shape=shape, fig=figure
    411 )
    412 self._renderer._window_close_connect(self._clean)
    413 self._renderer._window_set_theme(theme)

File /megtrain_env/.conda/lib/python3.10/site-packages/mne/viz/backends/renderer.py:57, in _get_renderer(*args, **kwargs)
     55 def _get_renderer(*args, **kwargs):
     56     _get_3d_backend()
---> 57     return backend._Renderer(*args, **kwargs)

File /megtrain_env/.conda/lib/python3.10/site-packages/mne/viz/backends/_notebook.py:1561, in _Renderer.__init__(self, *args, **kwargs)
   1555 if not _notebook_vtk_works():
   1556     raise RuntimeError(
   1557         "Using the notebook backend on Linux requires a compatible "
   1558         "VTK setup. Consider using Xfvb or xvfb-run to set up a "
   1559         "working virtual display, or install VTK with OSMesa enabled."
   1560     )
-> 1561 super().__init__(*args, **kwargs)
   1562 self._window_initialize(fullscreen=fullscreen)

File /megtrain_env/.conda/lib/python3.10/site-packages/mne/viz/backends/_pyvista.py:269, in _PyVistaRenderer.__init__(self, fig, size, bgcolor, name, show, shape, notebook, smooth_shading, splash, multi_samples)
    266 # pyvista theme may enable depth peeling by default so
    267 # we disable it initially to better control the value afterwards
    268 with _disabled_depth_peeling():
--> 269     self.plotter = self.figure._build()
    270 self._hide_axes()
    271 self._toggle_antialias()

File /megtrain_env/.conda/lib/python3.10/site-packages/mne/viz/backends/_pyvista.py:161, in PyVistaFigure._build(self)
    159         app = out
    160     self.store["app"] = app
--> 161 plotter = self._plotter_class(**self.store)
    162 plotter.background_color = self.background_color
    163 self._plotter = plotter

TypeError: Plotter.__init__() got an unexpected keyword argument 'multi_samples'

Here’s my specs:

  • MNE version: 1.6.0
  • operating system: CentOS 7.6.1810

Before running the code, I load the modules python/python3.6 and freesurfer/6.0.0.

Do you know where the problem can come from?

Thanks in advance :slight_smile:

Hello! Did you find a solution to this? I’ve encountered the same and wondering what the issue might be.

Hi! No unfortunately :frowning: I’ll leave it opened if anybody gets an idea.

Hi! @rpastureau @lsrinivasan I encountered the same issue when using Python OSL for MEG coregistration. Since Python OSL calls functions from MNE, I received almost identical error messages. I suspect it’s a version issue with certain packages. After reconfiguring the OSL environment, this error no longer occurred. You may consider making adjustments based on the configuration that I used, but I’m not sure if this will solve your problem.

dependencies:
- python=3.8.16
- pip=23.0.1
- vtk=9.1.0=*osmesa*
- pyvista=0.38.5
- pip:
  - jupyter==1.0.0
  - ipympl==0.9.3
  - ipywidgets==8.0.5
  - ipyevents==2.0.1
  - ipyvtklink==0.2.2
  - jupyter-client==8.1.0
  - numpy==1.23.5
  - scipy==1.10.1
  - matplotlib==3.7.1
  - mne==1.3.1
  - scikit-learn==1.2.2
  - fslpy==3.11.3
  - sails==1.4.0
  - tabulate==0.9.0
  - pyyaml==6.0
  - neurokit2==0.2.3
  - jinja2==3.1.2
  - glmtools==0.2.1
  - numba==0.56.4
  - nilearn==0.10.2
  - dask==2023.3.2
  - distributed==2023.3.2
  - parse==1.19.0
  - opencv-python==4.7.0.72
  - h5io==0.1.7
  - mat73==0.60
  - nibabel==5.0.1
  - pandas==1.5.3
  - panel==1.2.3
  - pqdm==0.2.0
  - seaborn==0.12.2
  - tensorflow==2.9.1
  - tensorflow_probability==0.17.0
  - tqdm==4.65.0
  - osfclient==0.0.5
  - osl==0.5.1
  - osl-dynamics==1.2.11

Best wishes
Luoyao

1 Like

I can confirm. I had the same error and this was fixed by upgrading mne to the latest stable release and installing some additional dependencies.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.