Index Error when trying to read data

Hi
I am trying to uploud Data from MFF file of EEG record .
By using:raw_orig=mne.io.read_raw_egi(path)
The same code is working to the previous EEG data session,but when trying to upload the Second record,I get an erro:

File “C:\Users\Lab_EEG\anaconda3\envs\spyder-4.2.0\lib\site-packages\mne\io\egi\events.py”, line 32, in _read_events
events[n][i] = n + 1

IndexError: index 1358868 is out of bounds for axis 0 with size 1358427

Is anyone familiar with this Error or have any idea how to try fix it.

You could exclude the event channel that’s causing the error if you don’t need it mne.io.read_raw_egi — MNE 1.6.0 documentation. Otherwise, it’s hard to give advice or troubleshoot without access to the file (and also the full stack trace not just the end would help).

Just replying to this because I encountered a similar issue in 0.24.1 and found a hack fix. Excluding event channels in read_raw_egi() doesn’t help, because the error occurs at data load while exclude_list is only used later, when reading events. The hack is to manually add in the exclusion to mne/io/egi/events.py, under the for loop in _read_events():

for n, event in enumerate(event_codes):
if event == ‘IEND’:
continue
for i in mff_events[event]:
print(n, i)
events[n][i] = n + 1

A better fix might be to include the exclude list when calling _read_events()… in egimff.py… but I don’t know enough about the code base to make sure that won’t break stuff. Also, I think this happens because the EGI software adds triggers after the end of the signal, but I’m not sure why only some data files raise the error.


IndexError Traceback (most recent call last)
in
5
6
----> 7 raw = mne.io.read_raw_egi(DATAPATH_WIS / f’WIS_{SUBJECT}.mff’, preload=True, verbose=2)
8
9

in read_raw_egi(input_fname, eog, misc, include, exclude, preload, channel_naming, verbose)

c:\users\wesley\anaconda2\envs\python3\lib\site-packages\mne\io\egi\egi.py in read_raw_egi(input_fname, eog, misc, include, exclude, preload, channel_naming, verbose)
155 if input_fname.endswith(’.mff’):
156 return _read_raw_egi_mff(input_fname, eog, misc, include,
→ 157 exclude, preload, channel_naming, verbose)
158 return RawEGI(input_fname, eog, misc, include, exclude, preload,
159 channel_naming, verbose)

in _read_raw_egi_mff(input_fname, eog, misc, include, exclude, preload, channel_naming, verbose)

c:\users\wesley\anaconda2\envs\python3\lib\site-packages\mne\io\egi\egimff.py in _read_raw_egi_mff(input_fname, eog, misc, include, exclude, preload, channel_naming, verbose)
374 “”"
375 return RawMff(input_fname, eog, misc, include, exclude,
→ 376 preload, channel_naming, verbose)
377
378

in init(self, input_fname, eog, misc, include, exclude, preload, channel_naming, verbose)

c:\users\wesley\anaconda2\envs\python3\lib\site-packages\mne\io\egi\egimff.py in init(self, input_fname, eog, misc, include, exclude, preload, channel_naming, verbose)
396
397 logger.info(’ Reading events …’)
→ 398 egi_events, egi_info = _read_events(input_fname, egi_info)
399 cals = _get_eeg_calibration_info(input_fname, egi_info)
400 logger.info(’ Assembling measurement info …’)

c:\users\wesley\anaconda2\envs\python3\lib\site-packages\mne\io\egi\events.py in _read_events(input_fname, info)
30 for n, event in enumerate(event_codes):
31 for i in mff_events[event]:
—> 32 events[n][i] = n + 1
33 return events, info
34

IndexError: index 751743 is out of bounds for axis 0 with size 751717

@larsoner would you please guide regard this INDEX ERROR and what should I do when events are not mutually exclusive?

@MKHD I am not sure what you mean. It would be good to post a minimal (as small as possible) reproducible script with the error message you mean. This post is about 0.24.1 and it would be good to test with 1.0 (or 1.1.dev0)

1 Like