Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raw.compute_psd("multitaper", ...) on a raw with "bad_xxx" annotations yields all np.nan #12519

Closed
mscheltienne opened this issue Mar 27, 2024 · 1 comment · Fixed by #12535
Closed
Assignees
Labels
Milestone

Comments

@mscheltienne
Copy link
Member

mscheltienne commented Mar 27, 2024

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 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()))
@larsoner
Copy link
Member

Tangentially related #11413 could maybe be tackled at the same time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants