mne-python: Error reading EEGLAB file (buffer too small)
This issue was reported in our forum using this example file.
raw = mne.io.read_raw_eeglab("EC_CON1.set")
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-6-90625f7fcaf5> in <module>
----> 1 raw = mne.io.read_raw_eeglab("EC_CON1.set")
/usr/local/lib/python3.9/site-packages/mne/io/eeglab/eeglab.py in read_raw_eeglab(input_fname, eog, preload, uint16_codec, verbose)
217 .. versionadded:: 0.11.0
218 """
--> 219 return RawEEGLAB(input_fname=input_fname, preload=preload,
220 eog=eog, verbose=verbose, uint16_codec=uint16_codec)
221
<decorator-gen-261> in __init__(self, input_fname, eog, preload, uint16_codec, verbose)
/usr/local/lib/python3.9/site-packages/mne/io/eeglab/eeglab.py in __init__(self, input_fname, eog, preload, uint16_codec, verbose)
316 preload=False, uint16_codec=None, verbose=None): # noqa: D102
317 input_fname = _check_fname(input_fname, 'read', True, 'input_fname')
--> 318 eeg = _check_load_mat(input_fname, uint16_codec)
319 if eeg.trials != 1:
320 raise TypeError('The number of trials is %d. It must be 1 for raw'
/usr/local/lib/python3.9/site-packages/mne/io/eeglab/eeglab.py in _check_load_mat(fname, uint16_codec)
57 """Check if the mat struct contains 'EEG'."""
58 from ...externals.pymatreader import read_mat
---> 59 eeg = read_mat(fname, uint16_codec=uint16_codec)
60 if 'ALLEEG' in eeg:
61 raise NotImplementedError(
/usr/local/lib/python3.9/site-packages/mne/externals/pymatreader/pymatreader.py in read_mat(filename, variable_names, ignore_fields, uint16_codec)
87 extra_kwargs['uint16_codec'] = uint16_codec
88
---> 89 raw_data = scipy.io.loadmat(fid, struct_as_record=True,
90 squeeze_me=True, mat_dtype=False,
91 variable_names=variable_names,
/usr/local/lib/python3.9/site-packages/scipy/io/matlab/mio.py in loadmat(file_name, mdict, appendmat, **kwargs)
224 with _open_file_context(file_name, appendmat) as f:
225 MR, _ = mat_reader_factory(f, **kwargs)
--> 226 matfile_dict = MR.get_variables(variable_names)
227
228 if mdict is not None:
/usr/local/lib/python3.9/site-packages/scipy/io/matlab/mio5.py in get_variables(self, variable_names)
330 continue
331 try:
--> 332 res = self.read_var_array(hdr, process)
333 except MatReadError as err:
334 warnings.warn(
/usr/local/lib/python3.9/site-packages/scipy/io/matlab/mio5.py in read_var_array(self, header, process)
290 `process`.
291 '''
--> 292 return self._matrix_reader.array_from_header(header, process)
293
294 def get_variables(self, variable_names=None):
mio5_utils.pyx in scipy.io.matlab.mio5_utils.VarReader5.array_from_header()
mio5_utils.pyx in scipy.io.matlab.mio5_utils.VarReader5.array_from_header()
mio5_utils.pyx in scipy.io.matlab.mio5_utils.VarReader5.read_struct()
mio5_utils.pyx in scipy.io.matlab.mio5_utils.VarReader5.read_mi_matrix()
mio5_utils.pyx in scipy.io.matlab.mio5_utils.VarReader5.array_from_header()
mio5_utils.pyx in scipy.io.matlab.mio5_utils.VarReader5.read_char()
TypeError: buffer is too small for requested array
It looks like this is related to reading the .mat file.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 27 (18 by maintainers)
https://github.com/mne-tools/mne-python/issues/8226#issuecomment-965439900
Quoting the docs for the
uint16_codecparameter ofread_raw_eeglab:fix scipy but this will take time and before fix the file with matlab to be able to load it as is
my 2c