MNE-BIDS Import Error

  • MNE-Python version: 0.23.0
  • operating system: Windows 10

I was trying to read openneuro dataset with MNE_BIDS (OSF | Prediction Error), to run a different analysis with MNE. However, I’m having mat error as below.

It seems that the authors have used MATLAB EEGLAB for their analysis. Is there a chance that this could cause a problem??

ValueError: Unknown mat file type, version 99, 57
ValueError                                Traceback (most recent call last)
<ipython-input-56-96f3ea41320a> in <module>
      6 bids_path
----> 8 raw = read_raw_bids(bids_path=bids_path, verbose=False)

~\AppData\Roaming\Python\Python38\site-packages\mne_bids\ in read_raw_bids(bids_path, extra_params, verbose)
    646         extra_params['allow_maxshield'] = True
--> 648     raw = _read_raw(bids_fpath, electrode=None, hsp=None, hpi=None,
    649                     config=config, verbose=None, **extra_params)

~\AppData\Roaming\Python\Python38\site-packages\mne_bids\ in _read_raw(raw_fpath, electrode, hsp, hpi, allow_maxshield, config, verbose, **kwargs)
     55     elif ext in ['.ds', '.vhdr', '.set', '.edf', '.bdf']:
---> 56         raw = reader[ext](raw_fpath, **kwargs)
     58     # MEF and NWB are allowed, but not yet implemented

C:\ProgramData\Anaconda3\lib\site-packages\mne\io\eeglab\ 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)

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

C:\ProgramData\Anaconda3\lib\site-packages\mne\io\eeglab\ 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'

C:\ProgramData\Anaconda3\lib\site-packages\mne\io\eeglab\ 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(

C:\ProgramData\Anaconda3\lib\site-packages\mne\externals\pymatreader\ in read_mat(filename, variable_names, ignore_fields, uint16_codec)
     82     try:
     83         with open(filename, 'rb') as fid:  # avoid open file warnings on error
---> 84             mjv, _ = get_matfile_version(fid)
     85             extra_kwargs = {}
     86             if mjv == 1:

C:\ProgramData\Anaconda3\lib\site-packages\scipy\io\matlab\ in get_matfile_version(fileobj)
    229     if maj_val in (1, 2):
    230         return ret
--> 231     raise ValueError('Unknown mat file type, version %s, %s' % ret)

ValueError: Unknown mat file type, version 99, 57

Hello, can you please share the output of

import mne


FWIW this is not an OpenNeuro dataset, as it’s hosted on OSF :face_with_monocle:

oh, I uploaded the other link. They also uploaded in openneuro too.

Here’s the result

Platform: Windows-10-10.0.19041-SP0
Python: 3.8.8 (default, Apr 13 2021, 15:08:03) [MSC v.1916 64 bit (AMD64)]
Executable: C:\ProgramData\Anaconda3\python.exe
CPU: AMD64 Family 25 Model 33 Stepping 0, AuthenticAMD: 16 cores
Memory: 63.9 GB

mne: 0.23.0
numpy: 1.20.1 {blas=mkl_rt, lapack=mkl_rt}
scipy: 1.6.2
matplotlib: 3.3.4 {backend=module://ipykernel.pylab.backend_inline}

sklearn: 0.24.2
numba: 0.53.1
nibabel: 3.2.1
nilearn: 0.8.0
dipy: 1.4.1
cupy: 9.4.0
pandas: 1.2.4
mayavi: Not found
pyvista: 0.31.3 {OpenGL 4.5.0 NVIDIA 471.96 via NVIDIA GeForce RTX 3090/PCIe/SSE2}
vtk: 9.0.3
PyQt5: 5.9.2

can you share a small script that crashes on this dataset?


I only have the traceback


import os
import os.path as op
from mne_bids import BIDSPath, read_raw_bids, print_dir_tree, make_report

# Path Config
bids_root = "./"
if not op.isdir(bids_root):


bids_path = BIDSPath(subject="001", datatype=datatype, task=task, root=bids_root, extension='.set')

raw = read_raw_bids(bids_path=bids_path, verbose=False)

with mne-python and mne-bids main branches I get:

/Users/alex/work/src/mne-python/mne/externals/pymatreader/ UserWarning: Complex objects (like classes) are not supported. They are imported on a best effort base but your mileage will vary.
  warn('Complex objects (like classes) are not supported. '
Traceback (most recent call last):
  File "/Users/alex/miniconda3/lib/python3.8/", line 1704, in main
  File "/Users/alex/miniconda3/lib/python3.8/", line 1573, in _runscript
  File "/Users/alex/miniconda3/lib/python3.8/", line 580, in run
    exec(cmd, globals, locals)
  File "<string>", line 1, in <module>
  File "/Users/alex/mne_data/ds003552/", line 1, in <module>
    import os
  File "/Users/alex/work/src/mne-bids/mne_bids/", line 648, in read_raw_bids
    raw = _read_raw(bids_fpath, electrode=None, hsp=None, hpi=None,
  File "/Users/alex/work/src/mne-bids/mne_bids/", line 56, in _read_raw
    raw = reader[ext](raw_fpath, **kwargs)
  File "/Users/alex/work/src/mne-python/mne/io/eeglab/", line 219, in read_raw_eeglab
    return RawEEGLAB(input_fname=input_fname, preload=preload,
  File "<decorator-gen-255>", line 24, in __init__
  File "/Users/alex/work/src/mne-python/mne/io/eeglab/", line 354, in __init__
    annot = read_annotations(input_fname)
  File "/Users/alex/work/src/mne-python/mne/", line 888, in read_annotations
    annotations = _read_annotations_eeglab(fname,
  File "/Users/alex/work/src/mne-python/mne/io/eeglab/", line 612, in _read_annotations_eeglab
    description = [str(event.type) for event in events]
  File "/Users/alex/work/src/mne-python/mne/io/eeglab/", line 612, in <listcomp>
    description = [str(event.type) for event in events]
AttributeError: 'Bunch' object has no attribute 'type'
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
> /Users/alex/work/src/mne-python/mne/io/eeglab/<listcomp>()
-> description = [str(event.type) for event in events]
(Pdb) p event
{'isiTime': 'n/a', 'box': 'n/a', 'pulseCount': 'n/a', 'visualFeedback': 'n/a', 'currentBlockNr': '1', 'cube': 'n/a', 'condition': 'vibro', 'latency': 47.5, 'trial_type': 'block_start', 'emsWidth': 'n/a', 'normal_or_conflict': 'n/a', 'hedTag': 'block:start;currentBlockNr:1;condition:vibro;training:false', 'ipq_question_nr_3_answer': 'n/a', 'training': 'false', 'duration': 0.0, 'vibroFeedback': 'n/a', 'reaction_time': 'n/a', 'vibroFeedbackDuration': 'n/a', 'emsFeedback': 'n/a', 'emsCurrent': 'n/a', 'ipq_question_nr_1_answer': 'n/a', 'ipq_question_nr_2_answer': 'n/a', 'block': 'start', 'urevent': 1.0, 'ipq_question_nr_4_answer': 'n/a', 'trial_nr': 'n/a', 'vibro_duration': 'n/a'}


So it seems type Is trial_type here? This should be a trivial fix?

let’s try to replicate with just mne-python and let’s open an issue on mne-python issue tracker