I want to compute PSD of an EEG signal during REM sleep stage. I have a raw EEG signal annotated with sleep stages. The description of my annotations are 'S0, S1, S2, S3, REM'. Is there a way to access the raw signal directly from annotations without creating epochs? I mean, if it is possible to compute the psd directly on raw signal specifing in which portion of the raw signal I want to compute the PSD, according to the description of the annotations. Something like this:
annotations = mne.Annotations(onset, duration, description, orig_time=None)
raw.set_annotations(annotations)
psds, freqs = mne.time_frequency.psd_welch(raw[raw.annotations.description['REM']], fmin=13.0, fmax=22.0)
But the code above doesn't work