Can't read .set EEG files anymore

Hello everyone,
Iā€™ve been using mne for a few month in order to study EEG data that comes from EEGlab.
However, since last update I canā€™t open them anymore with read_raw_eeglab()

Iā€™ve checked everything from my side but I canā€™t make the functions works.
read_raw_eeglab return this error

`mne.io.read_raw_eeglab("D:/xxx/data_example.set")`

D:\Dev\Anaconda\lib\site-packages\mne\io\eeglab\eeglab.py in read_raw_eeglab(input_fname, eog, preload, uint16_codec, verbose)
    218     """
    219     return RawEEGLAB(input_fname=input_fname, preload=preload,
--> 220                      eog=eog, verbose=verbose, uint16_codec=uint16_codec)
    221 
    222 

<decorator-gen-261> in __init__(self, input_fname, eog, preload, uint16_codec, verbose)

D:\Dev\Anaconda\lib\site-packages\mne\io\eeglab\eeglab.py in __init__(self, input_fname, eog, preload, uint16_codec, verbose)
    353         # create event_ch from annotations
    354         annot = read_annotations(input_fname)
--> 355         self.set_annotations(annot)
    356         _check_boundary(annot, None)
    357 

<decorator-gen-201> in set_annotations(self, annotations, emit_warning, on_missing, verbose)

D:\Dev\Anaconda\lib\site-packages\mne\io\base.py in set_annotations(self, annotations, emit_warning, on_missing, verbose)
    690             new_annotations._prune_ch_names(self.info, on_missing)
    691             if annotations.orig_time is None:
--> 692                 new_annotations.crop(0, self.times[-1] + delta,
    693                                      emit_warning=emit_warning)
    694                 new_annotations.onset += self._first_time

D:\Dev\Anaconda\lib\site-packages\mne\io\base.py in times(self)
   1577     def times(self):
   1578         """Time points."""
-> 1579         out = _arange_div(self.n_times, float(self.info['sfreq']))
   1580         out.flags['WRITEABLE'] = False
   1581         return out

TypeError: expected dtype object, got 'numpy.dtype[float64]'

Thanks
E.S

  • MNE-Python version: 0.24.0
  • operating system: Win10

Hello @EmileS and welcome to the forum!

Can you please share the output of:

import mne
mne.sys_info()

Thank you,

Richard

Hi Richard,
Thank you

Here is the result of mne.sys_info()

Platform:       Windows-10-10.0.19041-SP0
Python:         3.7.6 (default, Jan  8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)]
Executable:     D:\Dev\Anaconda\python.exe
CPU:            Intel64 Family 6 Model 158 Stepping 10, GenuineIntel: 8 cores
Memory:         15.8 GB

mne:            0.24.0
numpy:          1.20.3 {blas=NO_ATLAS_INFO, lapack=lapack}
scipy:          1.6.2
matplotlib:     3.1.3 {backend=module://ipykernel.pylab.backend_inline}

sklearn:        0.22.1
numba:          0.48.0
nibabel:        3.0.2
nilearn:        Not found
dipy:           1.1.0
cupy:           Not found
pandas:         1.0.1
mayavi:         4.7.1
pyvista:        Not found
pyvistaqt:      Not found
ipyvtklink:     Not found
vtk:            8.2.0
PyQt5:          5.9.2
ipympl:         Not found
mne_qt_browser: Not found
1 Like

can you share the problematic file?

Alex

Also, this is almost surely a bug introduced with the new MNE version. If you can open the same file with an older version (you could try that and install an older version such as 0.23.4), please open a new issue here.

1 Like

Ok, so this problem has been fixed by updating all python libraries
I think it was due to numpy or scipy not being up to date
Sorry for the trouble!

Emile

1 Like

I am currently finding same issue when reading .bdf files.

  File "/Users/nicobruno/mw_free_speech/preprocessing.py", line 56, in <module>
    raw = mne.io.read_raw_bdf(file, preload = True, verbose = False)
  File "/Users/nicobruno/opt/anaconda3/lib/python3.8/site-packages/mne/io/edf/edf.py", line 1312, in read_raw_bdf
    return RawEDF(input_fname=input_fname, eog=eog, misc=misc,
  File "<decorator-gen-197>", line 22, in __init__
  File "/Users/nicobruno/opt/anaconda3/lib/python3.8/site-packages/mne/io/edf/edf.py", line 121, in __init__
    super().__init__(info, preload, filenames=[input_fname],
  File "<decorator-gen-179>", line 22, in __init__
  File "/Users/nicobruno/opt/anaconda3/lib/python3.8/site-packages/mne/io/base.py", line 257, in __init__
    self._preload_data(preload)
  File "/Users/nicobruno/opt/anaconda3/lib/python3.8/site-packages/mne/io/base.py", line 536, in _preload_data
    (0, len(self.times) - 1, 0., self.times[-1]))
  File "/Users/nicobruno/opt/anaconda3/lib/python3.8/site-packages/mne/io/base.py", line 1580, in times
    out = _arange_div(self.n_times, float(self.info['sfreq']))
TypeError: expected dtype object, got 'numpy.dtype[float64]'

I tried updating numpy and scipy and the problem was not solve. The mne.sys_info()

Platform:       macOS-10.16-x86_64-i386-64bit
Python:         3.8.8 (default, Feb 24 2021, 13:46:16)  [Clang 10.0.0 ]
Executable:     /Users/nicobruno/opt/anaconda3/bin/python
CPU:            i386: 4 cores
Memory:         16.0 GB

mne:            0.24.0
numpy:          1.21.4 {blas=openblas, lapack=openblas}
scipy:          1.7.2
matplotlib:     3.5.0 {backend=MacOSX}

sklearn:        1.0.1
numba:          0.49.0
nibabel:        3.2.1
nilearn:        0.7.1
dipy:           1.4.1
cupy:           Not found
pandas:         1.3.4
mayavi:         4.7.4
pyvista:        Not found
pyvistaqt:      Not found
ipyvtklink:     Not found
vtk:            9.1.0
PyQt5:          5.12.3
ipympl:         Not found
mne_qt_browser: Not found

The only thing that works for is downgrade MNE to 0.22 (0.24 and 0.23 does not work)

can you share the file?

thx
A

Here is one example of the files that I am using:

I have no pb loading your file on my system using mne >= 0.24

import mne

raw = mne.io.read_raw_bdf(ā€˜S02_eegmw_01.bdfā€™, preload=True)

Alex

I know that it should work but for some reason versions >= 0.23 failed.

In [8]: raw = mne.io.read_raw_bdf(path + 'raw/S02_eegmw_01.bdf', preload=True)
Extracting EDF parameters from /Users/nicobruno/Documents/eegmw/eeg/raw/S02_eegmw_01.bdf...
BDF file detected
Setting channel info structure...
Could not determine channel type of the following channels, they will be set as EEG:
Fp1, Fp2, F3, F4, C3, C4, P3, P4, O1, O2, F7, F8, T7, T8, P7, P8, Fz, Cz, Pz, M1, M2, AFz, CPz, POz
Creating raw.info structure...
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-8-75600d6547ef> in <module>
----> 1 raw = mne.io.read_raw_bdf(path + 'raw/S02_eegmw_01.bdf', preload=True)

~/opt/anaconda3/lib/python3.8/site-packages/mne/io/edf/edf.py in read_raw_bdf(input_fname, eog, misc, stim_channel, exclude, preload, verbose)
   1417     for k, ev in enumerate(triggers):
   1418         onset = float(ev[0]) + offset
-> 1419         duration = float(ev[2]) if ev[2] else 0
   1420         for description in ev[3].split('\x14')[1:]:
   1421             if description:

<decorator-gen-215> in __init__(self, input_fname, eog, misc, stim_channel, exclude, preload, verbose)

~/opt/anaconda3/lib/python3.8/site-packages/mne/io/edf/edf.py in __init__(self, input_fname, eog, misc, stim_channel, exclude, preload, verbose)
    118 
    119         # Raw attributes
--> 120         last_samps = [edf_info['nsamples'] - 1]
    121         super().__init__(info, preload, filenames=[input_fname],
    122                          raw_extras=[edf_info], last_samps=last_samps,

<decorator-gen-197> in __init__(self, info, preload, first_samps, last_samps, filenames, raw_extras, orig_format, dtype, buffer_size_sec, orig_units, verbose)

~/opt/anaconda3/lib/python3.8/site-packages/mne/io/base.py in __init__(self, info, preload, first_samps, last_samps, filenames, raw_extras, orig_format, dtype, buffer_size_sec, orig_units, verbose)
    286             set_current_comp(self.info, grade)
    287             # We might need to apply it to our data now
--> 288             if self.preload:
    289                 logger.info('Applying compensator to loaded data')
    290                 lims = np.concatenate([np.arange(0, len(self.times), 10000),

~/opt/anaconda3/lib/python3.8/site-packages/mne/io/base.py in _preload_data(self, preload)
    565 
    566     # "Overridden method signature does not match call..." in LGTM
--> 567     def time_as_index(self, times, use_rounding=False, origin=None):  # lgtm
    568         """Convert time to indices.
    569 

~/opt/anaconda3/lib/python3.8/site-packages/mne/io/base.py in times(self)
   1577                 self._data = None
   1578             self.preload = False
-> 1579         else:
   1580             # do the concatenation ourselves since preload might be a string
   1581             nchan = self.info['nchan']

TypeError: expected dtype object, got 'numpy.dtype[float64]'

what does mne.sys_info() give you?

A

Platform:       macOS-10.16-x86_64-i386-64bit
Python:         3.8.8 (default, Feb 24 2021, 13:46:16)  [Clang 10.0.0 ]
Executable:     /Users/nicobruno/opt/anaconda3/bin/python
CPU:            i386: 4 cores
Memory:         16.0 GB

mne:            0.24.0
numpy:          1.21.4 {blas=openblas, lapack=openblas}
scipy:          1.7.2
matplotlib:     3.5.0 {backend=MacOSX}

sklearn:        1.0.1
numba:          0.49.0
nibabel:        3.2.1
nilearn:        0.7.1
dipy:           1.4.1
cupy:           Not found
pandas:         1.3.4
mayavi:         4.7.4
pyvista:        Not found
pyvistaqt:      Not found
ipyvtklink:     Not found
vtk:            9.1.0
PyQt5:          5.12.3

Can you try removing numba and then rub your code again?

Iā€™ve solved it by creating a brand new virtual environment.

Thanks to everyone

These should be the default solutions for any conda-related problem:

  1. Use mamba instead of conda

  2. Create a new environment from scratch

  3. Donā€™t use Anaconda