You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"reject_tmin" and "reject_tmax" params in Epochs are not applied for "reject_by_annotation" #7958
The reject_tmin and reject_tmax parameters from Epochs are not used for the reject_by_annotation parameter. But instead only for the reject and flat parameters.
# Create raw datasfreq=1000times=np.arange(0, 10, 0.001)
sin=np.sin(times*10)
cos=np.cos(times*10)
data=np.array([sin, cos])
ch_types= ['mag', 'grad']
ch_names= ['sin', 'cos']
info=mne.create_info(ch_names=ch_names, sfreq=sfreq, ch_types=ch_types)
raw=mne.io.RawArray(data, info)
# We have an event at 2 secondsevents=np.array([[2000, 0, 1]])
# There is a bad segment from 1 to 1.5 secondsonset=[1]
duration=[0.5]
description=['BAD']
annots=mne.Annotations(onset, duration, description)
raw.set_annotations(annots)
# Create epochs from 1s to 3s, centered on the event at 2s.# this epoch will be rejected_by_annotation, because there is an overlap# with a bad segment (1s to 1.5s)epochs=mne.Epochs(raw, events, tmin=-1, tmax=1, preload=True, reject_by_annotation=True)
assertlen(epochs) ==0# Now setting `reject_tmin` so that there is NO overlap ... should not reject# any epochs ... because bad segment is from 1s to 1.5s ... but epochs "reject" window# is from 1.8s to 3sepochs=mne.Epochs(raw, events, tmin=-1, tmax=1, reject_tmin=-0.2, preload=True, reject_by_annotation=True)
# This errorsassertlen(epochs) ==1, "oups!"
Expected results
reject_tmin and reject_tmax should have an effect on how reject_by_annotation is applied.
Example: When an epoch from -2s to 3s relative to 0 was formed with reject_tmin=-0.2, then that epoch MUST NOT be rejected if there is an overlap with a BAD annotation from, say -2s to -1.5s
Activity
larsoner commentedon Jul 6, 2020
Agreed, @sappelhoff do you have time to look into it?
sappelhoff commentedon Jul 6, 2020
yes, I'll look into it!