Errors with `read_raw_bids` with `.edf` files

**:question: Errors with read_raw_bids with .edf files

  • MNE version:
    mne==0.24.1
    mne-bids==0.9

  • operating system: Manjaro 21.2.0

Iā€™m having a problem with .edf files in the dataset ds002720 found in the OpenNeuro repository.
Iā€™ve succeeded in working with other datasets, so I donā€™t know if the bug is in the dataset in the MNE library.
In the MNE GitHub account, Iā€™ve found that you have to set the verbose to load the wrong channels.
Iā€™ve done it, and Iā€™m still getting an error, and I didnā€™t do any processing yet, just trying to read the raw data.
Iā€™m sending a jupyter notebook with the error; Iā€™ve used the tutorial jupyter notebook on the MNE site and just changed the dataset.
read_bids_datasets
Thank you a lot, guys
Best regards

Hello @AngelicaRibeiro and welcome to the forum!

I couldnā€™t access your notebook (but requested permission), so I cooked up a minimal working example:

# %%
from pathlib import Path
import openneuro
import mne_bids


bids_root = Path('/tmp/ds002720')

# %%
openneuro.download(
    dataset='ds002720',
    target_dir=bids_root,
    include=['sub-01/*task-run1*']
)

# %%
bids_path = mne_bids.BIDSPath(
    subject='01',
    task='run1',
    suffix='eeg',
    extension='.edf',
    datatype='eeg',
    root=bids_root
)
raw = mne_bids.read_raw_bids(bids_path=bids_path)

This yields the following error message:

ValueError                                Traceback (most recent call last)
Untitled-4 in <module>
      23     root=bids_root
      24 )
----> 25 raw = mne_bids.read_raw_bids(bids_path=bids_path)

<decorator-gen-557> in read_raw_bids(bids_path, extra_params, verbose)

~/Development/mne-bids/mne_bids/read.py in read_raw_bids(bids_path, extra_params, verbose)
    691                                           on_error='warn')
    692     if events_fname is not None:
--> 693         raw = _handle_events_reading(events_fname, raw)
    694 
    695     # Try to find an associated channels.tsv to get information about the

~/Development/mne-bids/mne_bids/read.py in _handle_events_reading(events_fname, raw)
    400     if trial_type_col_name is not None:
    401         # Drop events unrelated to a trial type
--> 402         events_dict = _drop(events_dict, 'n/a', trial_type_col_name)
    403 
    404         if 'value' in events_dict:

~/Development/mne-bids/mne_bids/tsv_handler.py in _drop(data, values, column)
    110     # FutureWarning, see
    111     # https://github.com/mne-tools/mne-bids/pull/372
--> 112     values = np.array(values, dtype=new_data_col.dtype)
    113 
    114     mask = np.in1d(new_data_col, values, invert=True)

ValueError: could not convert string to float: 'n/a'

Seems like a bug in MNE-BIDS.

@sappelhoff can you take a look if you have time?

Best wishes,
Richard

Hello @AngelicaRibeiro,

the cause of the issue is that the *_events.tsv files in the dataset are empty (except for the column names). The BIDS spec isnā€™t clear on whether this is valid. In any case, MNE-BIDS doesnā€™t handle this situation gracefully.

Simply removing the *_events.tsv files fixes the issue.

btw another aspect that this dataset isnā€™t doing great is that apparently it encodes runs as ā€œtasksā€. May seem like a formality only, but itā€™s clearly not how BIDS envisioned things to beā€¦

Best wishes,
Richard

Edit: Iā€™ve opened an issue at

1 Like

seems like it ā€¦ Iā€™ll look into it and will maybe make a PR to the spec and the validator.

1 Like

Iā€™ve gave you permission, to access the file.
And its the same ā€˜NaNā€™ error that you reproduced.
Iā€™ve noticed that they are using run as tasks, to work around this problem, Iā€™ve settled up like :

dataset ='ds002720'
subject = ['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18']
session = None
task=['run1','run2', 'run3', 'run4', 'run5','run6', 'run7','run8','run9']
acquisition = None
run = None
processing= None
recording= None
space= None
split = None
suffix = ['channels', 'eeg', 'eeg', 'events', '.events']
extension = ['.tsv', '.edf', '.json', '.json', '.tsv' ]
datatype = 'eeg'
check = True

Thanks again