Hi everyone,
I wanted to create epochs for polysomnography data. First, I set annotations to mark each epoch(30 seconds) sleep stage and mark some bad epochs. After that, I generated the epochs. However, I found that mne set some epochs bad even if I didnât mark it as a bad one. I expected that epochs.drop_log should be a tuple full of empty tuple because I have already set âreject_by_annotation=Trueâ. The truth was that there were many (âbadâ,) tuples. Did mne automatically drop epochs?
Here is my code:
annot = mne.Annotations(onset=[0,30,60,120,150,180,...],
duration=[30,30,30,30,30,30,...],
description=['W','W','bad','N1','N1',...])
raw = mne.io.read_raw_edf(edf_file, preload=True)
stage_id = {'W':0, 'N1':1, 'N2':2, 'N3':3, 'R':4}
stages = list(set(annot['description']))
stages.remove('bad')
annot_2_event = {stage:stage_id[stage] for stage in stages}
events, _ = mne.events_from_annotations(
raw, event_id=annot_2_event, chunk_duration=30
)
epochs = mne.Epochs(
raw=raw,
events=events,
event_id=annot_2_event,
reject_by_annotation=True,
picks='eeg',
tmin=0,
tmax=30,
baseline=(None,None),
preload=True
)
Indeed, len(epochs) is equal to the len([x for x in annot[âdescriptionâ] if x!=âbadâ]).
Any advice would be appreciated!