i’m trying to subselect epochs by condition. my event descriptions are pretty long because ideally i want to be able to subselect different parts of my data. a selection from the events dictionary below:
i’ve annotated my raw data and can see the annotations when i plot my data. however when i make my epochs and try to select a subsection with
epochs['onset'] to take out only the epochs that fall into condition ‘onset’ i get the error message below.
it seems like it’s looking in the trigger codes and not the descriptions, but when i go back a few steps to where i created the annotations, using
event_annotations = mne.annotations_from_events(events=events, sfreq=rawmff.info['sfreq'], orig_time=rawmff.info['meas_date'], event_desc=eventsdict, verbose=True) rawmff.set_annotations(rawmff.annotations + event_annotations)
and i try to FLIP the keys and the values in my event_desc=eventsdict dictionary, i get an error “TypeError: Event names must be an instance of str or None, got <class ‘int’> instead.”. so the structure of my dictionary seems to be correct - i create the annotations ok. it’s just after, when i try to use them in the epoched data, i can’t seem to get through to them.
mne v. 1.2.3, mac os 12.3.1.
many thanks for your help,
“Traceback (most recent call last):
File “/Users/ivanova/opt/anaconda3/envs/eegProc/lib/python3.9/site-packages/IPython/core/interactiveshell.py”, line 3433, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File “”, line 1, in
File “/Users/ivanova/opt/anaconda3/envs/eegProc/lib/python3.9/site-packages/mne/utils/mixin.py”, line 144, in getitem
File “/Users/ivanova/opt/anaconda3/envs/eegProc/lib/python3.9/site-packages/mne/utils/mixin.py”, line 195, in _getitem
select = inst._item_to_select(item)
File “/Users/ivanova/opt/anaconda3/envs/eegProc/lib/python3.9/site-packages/mne/utils/mixin.py”, line 153, in _item_to_select
select = self._keys_to_idx(item)
File “/Users/ivanova/opt/anaconda3/envs/eegProc/lib/python3.9/site-packages/mne/utils/mixin.py”, line 242, in _keys_to_idx
for k in match_event_names(self.event_id, keys)]),
File “/Users/ivanova/opt/anaconda3/envs/eegProc/lib/python3.9/site-packages/mne/event.py”, line 1493, in match_event_names
File “/Users/ivanova/opt/anaconda3/envs/eegProc/lib/python3.9/site-packages/mne/utils/check.py”, line 991, in _on_missing
KeyError: ‘Event name “onset” could not be found. The following events are present in the data: 10, 11, 12, 13, 14, 15, MY HUNDRED TRIGGER CODES, 1219, 1220, 1221, 1222, 1223, 1224’
/Applications/DataSpell.app/Contents/plugins/python-ce/helpers/pydev/_pydevd_bundle/pydevd_utils.py:609: FutureWarning: iteritems is deprecated and will be removed in a future version. Use .items instead.
for item in s.iteritems():”