Reported on our site today, it looks like raw.compute_psd() does not handle correctly annotated bad segments.
Both on 1.6 and on main.
@drammock Maybe you have an idea from the top of your head?
Steps to reproduce
import numpy as np
from mne import Annotations, create_info
from mne.io import RawArray
data = np.random.randn(3, 10000)
info = create_info(ch_names=["A", "B", "C"], sfreq=1000, ch_types="eeg")
raw = RawArray(data, info)
spectrum = raw.compute_psd(
method="multitaper", fmin=0, fmax=40, picks="eeg", exclude="bads"
)
assert spectrum.get_data().shape[0] == len(raw.ch_names)
assert not np.all(np.isnan(spectrum.get_data()))
# with a bad segment
annotation = Annotations(onset=1, duration=1, description="bad_segment")
raw.set_annotations(annotation)
spectrum = raw.compute_psd(
method="multitaper", fmin=0, fmax=40, picks="eeg", exclude="bads"
)
assert spectrum.get_data().shape[0] == len(raw.ch_names)
assert np.all(np.isnan(spectrum.get_data()))
Description of the problem
Reported on our site today, it looks like
raw.compute_psd()
does not handle correctly annotated bad segments. Both on 1.6 and onmain
. @drammock Maybe you have an idea from the top of your head?Steps to reproduce