I have a (large) EEG file, which works fine when I compute and plot its PSD with raw.plot_psd(). However, I then manually mark some segments as bad, perform ICA, remove some ICs, and back-project. Using this data, I cannot compute the PSD anymore:
ValueError Traceback (most recent call last)
Cell In[3], line 1
----> 1 raw.plot_psd()
File <decorator-gen-213>:5, in plot_psd(self, fmin, fmax, tmin, tmax, picks, proj, reject_by_annotation, method, average, dB, estimate, xscale, area_mode, area_alpha, color, line_alpha, spatial_colors, sphere, exclude, ax, show, n_jobs, verbose, **method_kw)
File <decorator-gen-212>:12, in plot_psd(self, fmin, fmax, tmin, tmax, picks, proj, reject_by_annotation, method, average, dB, estimate, xscale, area_mode, area_alpha, color, line_alpha, spatial_colors, sphere, exclude, ax, show, n_jobs, verbose, **method_kw)
File ~/Projects/mne-python/mne/time_frequency/spectrum.py:114, in SpectrumMixin.plot_psd(self, fmin, fmax, tmin, tmax, picks, proj, reject_by_annotation, method, average, dB, estimate, xscale, area_mode, area_alpha, color, line_alpha, spatial_colors, sphere, exclude, ax, show, n_jobs, verbose, **method_kw)
111 ci = 'sd' if area_mode == 'std' else area_mode
112 # ↓ here picks="all" because we've already restricted the `info` to
113 # ↓ have only `picks` channels
--> 114 fig = spectrum.plot(
115 picks='all', average=average, dB=dB, amplitude=amplitude,
116 xscale=xscale, ci=ci, ci_alpha=area_alpha, color=color,
117 alpha=line_alpha, spatial_colors=spatial_colors, sphere=sphere,
118 exclude=exclude, axes=ax, show=show)
119 return fig
File ~/Projects/mne-python/mne/time_frequency/spectrum.py:611, in BaseSpectrum.plot(self, picks, average, dB, amplitude, xscale, ci, ci_alpha, color, alpha, spatial_colors, sphere, exclude, axes, show)
609 xlabels_list = [False] * (len(axes) - 1) + [True]
610 # plot
--> 611 _plot_psd(self, fig, self.freqs, psd_list, picks_list, titles_list,
612 units_list, scalings_list, axes, make_label, color,
613 area_mode=ci, area_alpha=ci_alpha, dB=dB, estimate=estimate,
614 average=average, spatial_colors=spatial_colors,
615 xscale=xscale, line_alpha=alpha,
616 sphere=sphere, xlabels_list=xlabels_list)
617 fig.subplots_adjust(hspace=0.3)
618 plt_show(show, fig)
File ~/Projects/mne-python/mne/viz/utils.py:2277, in _plot_psd(inst, fig, freqs, psd_list, picks_list, titles_list, units_list, scalings_list, ax_list, make_label, color, area_mode, area_alpha, dB, estimate, average, spatial_colors, xscale, line_alpha, sphere, xlabels_list)
2275 if not spatial_colors:
2276 spatial_colors = color
-> 2277 _plot_lines(psd_array, info, picks, fig, ax_list, spatial_colors,
2278 unit, units=units, scalings=None, hline=None, gfp=False,
2279 types=types, zorder='std', xlim=(freqs[0], freqs[-1]),
2280 ylim=None, times=freqs, bad_ch_idx=[], titles=titles,
2281 ch_types_used=ch_types_used, selectable=True, psd=True,
2282 line_alpha=line_alpha, nave=None, time_unit='ms',
2283 sphere=sphere, highlight=None)
2285 for ii, (ax, xlabel) in enumerate(zip(ax_list, xlabels_list)):
2286 ax.grid(True, linestyle=':')
File ~/Projects/mne-python/mne/viz/evoked.py:462, in _plot_lines(data, info, picks, fig, axes, spatial_colors, unit, units, scalings, hline, gfp, types, zorder, xlim, ylim, times, bad_ch_idx, titles, ch_types_used, selectable, psd, line_alpha, nave, time_unit, sphere, highlight)
459 if len(idx) > 0:
460 # Set amplitude scaling
461 D = this_scaling * data[idx, :]
--> 462 _check_if_nan(D)
463 gfp_only = gfp == 'only'
464 if not gfp_only:
File ~/Projects/mne-python/mne/utils/check.py:571, in _check_if_nan(data, msg)
569 """Raise if any of the values are NaN."""
570 if not np.isfinite(data).all():
--> 571 raise ValueError("Some of the values {} are NaN.".format(msg))
ValueError: Some of the values to be plotted are NaN.
Unfortunately, the problematic file is ~240MB. It is available here:
Plotting the PSD works.
Plotting the PSD throws an error.
Description of the problem
I have a (large) EEG file, which works fine when I compute and plot its PSD with
raw.plot_psd(). However, I then manually mark some segments as bad, perform ICA, remove some ICs, and back-project. Using this data, I cannot compute the PSD anymore:Steps to reproduce
Link to data
Unfortunately, the problematic file is ~240MB. It is available here:
https://drive.google.com/file/d/1q2B5KsS-TKFlBlULBUqswCeNMdn71a-a/view?usp=sharing
Expected results
Plotting the PSD works.
Actual results
Plotting the PSD throws an error.
Additional information
Note that setting
reject_by_annotation=Falseworks, but I would like to compute the PSD from good segments only (and therefore use the defaultreject_by_annotation=True).This is on
main:Details