- MNE version: e.g. 1.3.0
- operating system: Windows 10
Hi there, I am now using the following code
brain = plot_glm_surface_projection(raw_haemo.copy().pick("hbo").pick(significant_channels), model_df, colorbar=True)
brain.add_sensors(raw_haemo.info, trans='fsaverage', fnirs=['channels', 'pairs', 'sources', 'detectors'])
to plot my significant result on scalp, but I always get this error. I have tried different types of backend, including: qt, tk, webAgg, notebook etc., none of them are working, I got the same error message with this function. It would be super helpful if you could provide me the solution how to fix it! Thank you.
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[47], line 3
1 # Plot the projection and sensor locations
2 get_ipython().run_line_magic('matplotlib', 'inline')
----> 3 brain = plot_glm_surface_projection(raw_haemo.copy().pick("hbo").pick(significant_channels), model_df, colorbar=True)
5 brain.add_sensors(raw_haemo.info, trans='fsaverage', fnirs=['channels', 'pairs', 'sources', 'detectors'])
7 # mark the premotor cortex in red
File <decorator-gen-610>:10, in plot_glm_surface_projection(inst, statsmodel_df, picks, value, background, figure, clim, mode, colormap, surface, hemi, size, view, colorbar, distance, subjects_dir, src, verbose)
File D:\Anaconda\envs\fnirs\lib\site-packages\mne_nirs\visualisation\_plot_GLM_surface_projection.py:97, in plot_glm_surface_projection(inst, statsmodel_df, picks, value, background, figure, clim, mode, colormap, surface, hemi, size, view, colorbar, distance, subjects_dir, src, verbose)
90 raise RuntimeError('MNE data structure does not match dataframe '
91 f'results.\nMNE = {info.ch_names}.\n'
92 f'GLM = {list(statsmodel_df["ch_name"].values)}')
94 ea = EvokedArray(np.tile(statsmodel_df[value].values.T, (1, 1)).T,
95 info.copy())
---> 97 return _plot_3d_evoked_array(inst, ea, picks=picks,
98 value=value,
99 background=background, figure=figure,
100 clim=clim,
101 mode=mode, colormap=colormap,
102 surface=surface, hemi=hemi, size=size,
103 view=view, colorbar=colorbar,
104 distance=distance,
105 subjects_dir=subjects_dir, src=src,
106 verbose=verbose)
File D:\Anaconda\envs\fnirs\lib\site-packages\mne_nirs\visualisation\_plot_GLM_surface_projection.py:142, in _plot_3d_evoked_array(inst, ea, picks, value, background, figure, clim, mode, colormap, surface, hemi, size, view, colorbar, distance, subjects_dir, src, verbose)
139 stc = stc_near_sensors(picks=picks, **kwargs, verbose=verbose)
141 # Produce brain plot
--> 142 brain = stc.plot(src=src, subjects_dir=subjects_dir, hemi=hemi,
143 surface=surface, initial_time=0, clim=clim, size=size,
144 colormap=colormap, figure=figure, background=background,
145 colorbar=colorbar, verbose=verbose)
146 if view is not None:
147 brain.show_view(view)
File D:\Anaconda\envs\fnirs\lib\site-packages\mne\source_estimate.py:650, 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)
639 @copy_function_doc_to_method_doc(plot_source_estimates)
640 def plot(self, subject=None, surface='inflated', hemi='lh',
641 colormap='auto', time_label='auto', smoothing_steps=10,
(...)
648 src=None, volume_options=1., view_layout='vertical',
649 add_data_kwargs=None, brain_kwargs=None, verbose=None):
--> 650 brain = plot_source_estimates(
651 self, subject, surface=surface, hemi=hemi, colormap=colormap,
652 time_label=time_label, smoothing_steps=smoothing_steps,
653 transparent=transparent, alpha=alpha, time_viewer=time_viewer,
654 subjects_dir=subjects_dir, figure=figure, views=views,
655 colorbar=colorbar, clim=clim, cortex=cortex, size=size,
656 background=background, foreground=foreground,
657 initial_time=initial_time, time_unit=time_unit, backend=backend,
658 spacing=spacing, title=title, show_traces=show_traces,
659 src=src, volume_options=volume_options, view_layout=view_layout,
660 add_data_kwargs=add_data_kwargs, brain_kwargs=brain_kwargs,
661 verbose=verbose)
662 return brain
File <decorator-gen-125>:10, 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 D:\Anaconda\envs\fnirs\lib\site-packages\mne\viz\_3d.py:1987, 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)
1985 else:
1986 with use_3d_backend(backend):
-> 1987 return _plot_stc(
1988 stc, overlay_alpha=alpha, brain_alpha=alpha,
1989 vector_alpha=alpha, cortex=cortex, foreground=foreground,
1990 size=size, scale_factor=None, show_traces=show_traces,
1991 src=src, volume_options=volume_options,
1992 view_layout=view_layout, add_data_kwargs=add_data_kwargs,
1993 brain_kwargs=brain_kwargs, **kwargs)
File D:\Anaconda\envs\fnirs\lib\site-packages\mne\viz\_3d.py:2110, 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)
2107 del kwargs
2109 if time_viewer:
-> 2110 brain.setup_time_viewer(time_viewer=time_viewer,
2111 show_traces=show_traces)
2112 else:
2113 brain.show()
File D:\Anaconda\envs\fnirs\lib\site-packages\mne\viz\_brain\_brain.py:523, in Brain.setup_time_viewer(***failed resolving arguments***)
521 self._configure_menu()
522 self._configure_status_bar()
--> 523 self._configure_playback()
524 self._configure_help()
525 # show everything at the end
File D:\Anaconda\envs\fnirs\lib\site-packages\mne\viz\_brain\_brain.py:1004, in Brain._configure_playback(self)
1003 def _configure_playback(self):
-> 1004 self._renderer._playback_initialize(
1005 func=self._play,
1006 timeout=self.refresh_rate_ms,
1007 value=self._data['time_idx'],
1008 rng=[0, len(self._data['time']) - 1],
1009 time_widget=self.widgets["time"],
1010 play_widget=self.widgets["play"],
1011 )
File D:\Anaconda\envs\fnirs\lib\site-packages\mne\viz\backends\_notebook.py:1227, in _IpyPlayback._playback_initialize(self, func, timeout, value, rng, time_widget, play_widget)
1225 play.max = rng[1]
1226 play.value = value
-> 1227 slider = time_widget._widget
1228 jsdlink((play, 'value'), (slider, 'value'))
1229 jsdlink((slider, 'value'), (play, 'value'))
AttributeError: 'NoneType' object has no attribute '_widget