Template matching for automatic epoch rejection

Hello,

I was thinking of implementing a function for automatic bad epoch rejection (both EEG and MEG) based on template matching. So which means you compute the evoked object by averaging over epochs, then you compare the evoke (template) with each single epoch, if the similarity between the evoke and epoch was less than a threshold, it drops the epoch, then evoke object will be updated.

there are multiple ways for template matching (e.g. convolutional TM, Bayesian TM, …) which could be passed as an argument to the function.

I can quickly implement and push it, but first let me know your ideas.

Best,
Payam

2 Likes

Personally, I would advise against doing something the way this question was framed; if you throw out all epochs that don’t look like what you expect, you’re guarenteed to get what you expect making it impossible to fail to reject your null hypothesis–you’re always going to find your result because you screened out any data that would contradict your result.

I think what you might be looking for is a signal-to-noise ratio metric. If you don’t suppose a template but assume the evoked average is the ground truth, that will give you an estimate of trials where maybe they moved or heard something outside of the experiment or otherwise had more task irrelevant brain activity than on other trials. Hope that helps!

Edit: After closer rereading your post, you were suggesting using the evoked as a template which is the same as SNR not some arbitary shape so the first paragraph doesn’t really apply. I think there’s a lot of good classic SNR metrics that you might look at first before trying something fancier.

2 Likes

We’re already doing some kind of template matching in the ICA methods that remove EOG and ECG artifacts, maybe there’s some inspiration to be gathered from there

1 Like

Thank you Richard, can you direct me to your ICA TM methods?

Here is the TM paragraph for ICA: Repairing artifacts with ICA — MNE 1.5.1 documentation

Mathieu

2 Likes

Thanks Alex for the inputs, that’s true, we could only use template matching or SNR metric, if we assume that evoke object could serve as ground truth. but don’t you think comparing single epochs with evoke using TM like convolution one, will be less prone to noise than SNR metric?

That’s a good question that’s probably best answered empirically. SNR might be a good place to start and for comparison since its so widely used (and multiple metrics, variance as denominator or RMS) but if a convolution is less effected by noise, that will show up in the data and you could make a pretty convincing case that it’s better. That sounds a bit like a methods paper though…