first reported on gitter
Describe the bug
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.
Look at this part in the code.
Steps to reproduce
MWE:
# Create raw data
sfreq = 1000
times = 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 seconds
events = np.array([[2000, 0, 1]])
# There is a bad segment from 1 to 1.5 seconds
onset=[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)
assert len(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 3s
epochs = mne.Epochs(raw, events, tmin=-1, tmax=1, reject_tmin=-0.2, preload=True, reject_by_annotation=True)
# This errors
assert len(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
first reported on gitter
Describe the bug
The
reject_tminandreject_tmaxparameters fromEpochsare not used for thereject_by_annotationparameter. But instead only for therejectandflatparameters.Look at this part in the code.
Steps to reproduce
MWE:
Expected results
reject_tminandreject_tmaxshould have an effect on howreject_by_annotationis 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 aBADannotation from, say -2s to -1.5s