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
plot_events throws ValueError if event_id contains additional entries #6905
ValueError: 17 from event_id is not present in events.
Is it possible to make this only a warning and let the code run through? In my experiments the stimuli are letters and not all letters are present in every session, and it is very tiresome creating a specific filtered event dict for every session.
If you don't mind I'd like to discuss the problem a little further, but I'd like to precise I'm very new to MNE and I'm using it to treat fNIRS data (working with @swy7ch), so I might be missing a big part of the iceberg 😉
First of all, in this part of the code, event_id is optional and its purpose is to add a legend to the plot if provided by the user (according to the function docstring).
The following piece of code (pointed out by the present issue) throw an error if you try to give a description in the legend to events that are not present in the dataset.
for this_event in unique_events_id:
if this_event not in unique_events:
raise ValueError('%s from event_id is not present in events.'
% this_event)
It seems to me that it should clearly not throw an error because here, event_id just contains more information than required for this optional functionality. I wonder if this should even be a warning ? If we throw a warning, the purpose seems to be:
Hey, are you sure your dataset is good, you don't seem to have all the events you want to describe ?
But is it the purpose of this optional functionality, in a plot function ? I'm not sure, and my preference goes to just skipping the unnecessary information. We would need however to filter unique_events_id so it only contains event IDs present in the dataset to avoid having blank lines on the plot.
It seems to me that the piece of code coming just after is also problematic (should I open another issue ?):
for this_event in unique_events:
if this_event not in unique_events_id:
warn('event %s missing from event_id will be ignored'
% this_event)
It is realized here that information is missing to completely update the legend and it is decided to ignore events that would have no entries in it. Thus, adding this optional parameters change what the plot contains, and it looks like an issue, isn't it ?
We could follow @larsoner suggestion and replicate the Epochs(..., on_missing=...) API to solve it, but I'm not sure what to do if the user select warning/ignore ? Partially update the legend, so we have legend entries following event_label = '%s (%s)' % (event_id_rev[ev], count) and others following event_label = 'N=%d' % (count,) ?
Activity
agramfort commentedon Oct 3, 2019
larsoner commentedon Oct 3, 2019
It would be good to replicate the
Epochs(..., on_missing=...)API hererderollepot commentedon Jul 17, 2020
Any news on this issue ?
If not, I can try to work on it as I am confronted with this problem too.
larsoner commentedon Jul 17, 2020
Nobody has worked on it as far as I know @rderollepot, feel free to give it a shot!
rderollepot commentedon Jul 17, 2020
Ok I will give it a try !
rderollepot commentedon Jul 17, 2020
If you don't mind I'd like to discuss the problem a little further, but I'd like to precise I'm very new to MNE and I'm using it to treat fNIRS data (working with @swy7ch), so I might be missing a big part of the iceberg 😉
First of all, in this part of the code, event_id is optional and its purpose is to add a legend to the plot if provided by the user (according to the function docstring).
The following piece of code (pointed out by the present issue) throw an error if you try to give a description in the legend to events that are not present in the dataset.
It seems to me that it should clearly not throw an error because here, event_id just contains more information than required for this optional functionality. I wonder if this should even be a warning ? If we throw a warning, the purpose seems to be:
But is it the purpose of this optional functionality, in a plot function ? I'm not sure, and my preference goes to just skipping the unnecessary information. We would need however to filter unique_events_id so it only contains event IDs present in the dataset to avoid having blank lines on the plot.
It seems to me that the piece of code coming just after is also problematic (should I open another issue ?):
It is realized here that information is missing to completely update the legend and it is decided to ignore events that would have no entries in it. Thus, adding this optional parameters change what the plot contains, and it looks like an issue, isn't it ?
We could follow @larsoner suggestion and replicate the
Epochs(..., on_missing=...)API to solve it, but I'm not sure what to do if the user select warning/ignore ? Partially update the legend, so we have legend entries followingevent_label = '%s (%s)' % (event_id_rev[ev], count)and others followingevent_label = 'N=%d' % (count,)?