Skip to content

A metric for event detection quality #183

Description

@GWeindel

Context: It's sometimes hard to judge how much an event is supported by the EEG data as opposed to supported by the distributions. E.g. some trials might have very low probability over long times samples without a clear peak.

Proposition: create a measure of probability update due to the EEG data, a bit like a prior/posterior contraction index in Bayesian analysis.

Implementation: we can create, for each event, a null model where all magnitudes and parameters are used except the one from the studied event. We don't re-estimate the model but just compare the event probabilities of each trial in the estimated model vs the null model.
See for example:

fake_mags = np.zeros(estimates.magnitudes.shape)
fake_mags[:2] = estimates.magnitudes[:2]
null = init.fit_single(4, parameters=estimates.parameters, magnitudes=fake_mags, maximization=False)

randidx = list(np.random.randint(0, 20000, 5))
fig, ax = plt.subplots(5, sharex=True, sharey=False, dpi=200)
for i, idx in enumerate(randidx): 
    for ev in range(4):
        ax[i].plot(estimates.samples*1000/256, estimates.eventprobs.isel(trial_x_participant=idx)[:,ev], color=colors_ev[ev])
        ax[i].plot(null.samples*1000/256, null.eventprobs.isel(trial_x_participant=idx)[:,ev], ls='--', color=colors_ev[ev])
plt.xlim(0,1000)

Image

In this case we're looking at how the event 3 improved with the estimation of magnitudes compared to just using the distribution and the convolution with the probabilties from the previous events

We could thus compute something like the ratio of the probabilities given the real estimates compared to the null model. In pseudo-code this would give something like:

x = argmax(estimates.eventprobs.sel(trial=idx))

update = estimates.eventprobs.sel(x)/null.eventprobs.sel(x)

What do you think? @jelmerborst @lvmaanen @rickdott amongst others

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions