Dear users,
I am reading EEG data from an .xdf file, which was recorded using LSLrecorder. The EEG channels are in one stream, the event codes in another. I am using a combination of mne, mnelab, and pyxdf.
Here is the code I’m using to read in the data:
### Identify stream containing EEG channels
streams = pyxdf.resolve_streams(raw_fname) # raw_fname is an .xdf file
stream_id = pyxdf.match_streaminfos(streams, [{"type": "signal"}])
### Read in data
raw = read_raw_xdf(raw_fname, stream_ids = stream_id)
### Get events
events, event_dict = mne.events_from_annotations(raw)
The problem is that events
is not what I expect. The event codes for this dataset should be 1,2,3,10,20,30,40. However, events
instead contains values 1-7 that appear to be labelled / annotated (?) with the correct values. This can be seen in events_dict
:
> print(events_dict)
>> {'1': 1, '10': 2, '2': 3, '20': 4, '3': 5, '30': 6, '40': 7}
…and by visualizing the raw data (the coloured values in the first output are the expected codes, the small black values are stored in events
):
%matplotlib notebook
raw.plot(events=events, event_id=None, n_channels=16,
scalings=dict(eeg=.00009), # Convert V to mV
duration=30, title='Raw EEG');
Output:
…and also by vizualising the event codes themselves:
%matplotlib inline
mne.viz.plot_events(events, sfreq=1024.0, event_id = event_dict);
Output
So, I’m really not sure what is happening. Is there a way to isolate the correct codes as events? I know I could probably replace the values in events
with their corresponding labels from events_dict
. However, I am reluctant to do this because I don’t know where the first set of values come from or whether code-to-label mappings would be consistent across different datasets.
Any advice would be greatly appreciated
- Python version: 3.9.13
- MNE version: 1.6.1
- operating system: Windows 10
Edit: corrected some typos