ValueError: list.remove(x)

Hello,
I would like to perform this tutorial using my own EEG data and an MNI standard brain:
https://mne.tools/stable/auto_examples/inverse/dics_source_power.html
The tutorial works fine with the files provided on the website.
However, when I use my own files for it, I consistently get an error at the final step.

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[38], line 3
      1 stc = beta_source_power / baseline_source_power
      2 message = "DICS source power in the 12-30 Hz frequency band"
----> 3 brain = stc.plot(
      4     hemi="both",
      5     views="axial",
      6     subjects_dir=MRI_data_folder,
      7     subject='outputrecon',
      8     time_label=message,
      9 )

File ~/anaconda3/envs/experiment_neue_fresh_backup/lib/python3.11/site-packages/mne/source_estimate.py:743, in _BaseSourceEstimate.plot(self, subject, surface, hemi, colormap, time_label, smoothing_steps, transparent, alpha, time_viewer, subjects_dir, figure, views, colorbar, clim, cortex, size, background, foreground, initial_time, time_unit, backend, spacing, title, show_traces, src, volume_options, view_layout, add_data_kwargs, brain_kwargs, verbose)
    709 @copy_function_doc_to_method_doc(plot_source_estimates)
    710 def plot(
    711     self,
   (...)
    741     verbose=None,
    742 ):
--> 743     brain = plot_source_estimates(
    744         self,
    745         subject,
    746         surface=surface,
    747         hemi=hemi,
    748         colormap=colormap,
    749         time_label=time_label,
    750         smoothing_steps=smoothing_steps,
    751         transparent=transparent,
    752         alpha=alpha,
    753         time_viewer=time_viewer,
    754         subjects_dir=subjects_dir,
    755         figure=figure,
    756         views=views,
    757         colorbar=colorbar,
    758         clim=clim,
    759         cortex=cortex,
    760         size=size,
    761         background=background,
    762         foreground=foreground,
    763         initial_time=initial_time,
    764         time_unit=time_unit,
    765         backend=backend,
    766         spacing=spacing,
    767         title=title,
    768         show_traces=show_traces,
    769         src=src,
    770         volume_options=volume_options,
    771         view_layout=view_layout,
    772         add_data_kwargs=add_data_kwargs,
    773         brain_kwargs=brain_kwargs,
    774         verbose=verbose,
    775     )
    776     return brain

File <decorator-gen-164>:12, in plot_source_estimates(stc, subject, surface, hemi, colormap, time_label, smoothing_steps, transparent, alpha, time_viewer, subjects_dir, figure, views, colorbar, clim, cortex, size, background, foreground, initial_time, time_unit, backend, spacing, title, show_traces, src, volume_options, view_layout, add_data_kwargs, brain_kwargs, verbose)

File ~/anaconda3/envs/experiment_neue_fresh_backup/lib/python3.11/site-packages/mne/viz/_3d.py:2431, in plot_source_estimates(stc, subject, surface, hemi, colormap, time_label, smoothing_steps, transparent, alpha, time_viewer, subjects_dir, figure, views, colorbar, clim, cortex, size, background, foreground, initial_time, time_unit, backend, spacing, title, show_traces, src, volume_options, view_layout, add_data_kwargs, brain_kwargs, verbose)
   2429 else:
   2430     with use_3d_backend(backend):
-> 2431         return _plot_stc(
   2432             stc,
   2433             overlay_alpha=alpha,
   2434             brain_alpha=alpha,
   2435             vector_alpha=alpha,
   2436             cortex=cortex,
   2437             foreground=foreground,
   2438             size=size,
   2439             scale_factor=None,
   2440             show_traces=show_traces,
   2441             src=src,
   2442             volume_options=volume_options,
   2443             view_layout=view_layout,
   2444             add_data_kwargs=add_data_kwargs,
   2445             brain_kwargs=brain_kwargs,
   2446             **kwargs,
   2447         )

File ~/anaconda3/envs/experiment_neue_fresh_backup/lib/python3.11/site-packages/mne/viz/_3d.py:2601, in _plot_stc(stc, subject, surface, hemi, colormap, time_label, smoothing_steps, subjects_dir, views, clim, figure, initial_time, time_unit, background, time_viewer, colorbar, transparent, brain_alpha, overlay_alpha, vector_alpha, cortex, foreground, size, scale_factor, show_traces, src, volume_options, view_layout, add_data_kwargs, brain_kwargs)
   2598 del kwargs
   2600 if time_viewer:
-> 2601     brain.setup_time_viewer(time_viewer=time_viewer, show_traces=show_traces)
   2602 else:
   2603     brain.show()

File ~/anaconda3/envs/experiment_neue_fresh_backup/lib/python3.11/site-packages/mne/viz/_brain/_brain.py:556, in Brain.setup_time_viewer(self, time_viewer, show_traces)
    554 self.color_list = _get_color_list()
    555 # remove grey for better contrast on the brain
--> 556 self.color_list.remove("#7f7f7f")
    557 self.color_cycle = _ReuseCycle(self.color_list)
    558 self.mpl_canvas = None

ValueError: list.remove(x): x not in list

I would like to inquire how I can work around the error in order to generate a plot, as I am unable to modify the β€œlist.remove(x)” command.

Thank you in advance for your help!
Best regards,
brainfreeze1212

MNE version: 1.6.1
Operating system: macOS Ventura Version 13.6.1

did you try removing your installation and creating a new one from scratch? To me, this looks like a conflict between software versions.

Alternatively, please look at the exact colors you are passing to the functions, and try experimenting with that and whether that can fix something.

1 Like