mne-tools / mne-bids

MNE-BIDS is a Python package that allows you to read and write BIDS-compatible datasets with the help of MNE-Python.
https://mne.tools/mne-bids/
BSD 3-Clause "New" or "Revised" License
132 stars 86 forks source link

Doesn't supports header versions in ds003498 #938

Closed zhengliuer closed 2 years ago

zhengliuer commented 2 years ago

Describe the bug

When loading ds003498 from OpenNeuro, a ValueError came up and said MNE-Python currently only supports header versions 1.0 and 2.0, got unparsable

Steps to reproduce

from mne_bids import read_raw_bids, BIDSPath, get_entity_vals, get_datatypes, make_report
 # path to the data
root = 'H:\\fedele_hfo_data' 
report = make_report(root, 'ses-interictalsleep', verbose=False)

# there are iEEG datatypes throughout the dataset
datatypes = get_datatypes(root)

# get all the subjects, sessions
subjects = get_entity_vals(root, 'subject')
sessions = get_entity_vals(root, 'session')

# construct BIDSPath for dataset we will demo
subjectID = subjects[0]
sessionID = sessions[0]
bids_path = BIDSPath(subject=subjectID, session=sessionID, datatype='ieeg', suffix='ieeg', extension='.vhdr', root=root)

# get all matching datasets
fpaths = bids_path.match()

dataset_path = fpaths[0]
raw = read_raw_bids(dataset_path, preload=True)

Actual results

The whole output is

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
C:/Users/barryliu/AppData/Local/Temp/xpython_28768/2657012993.py in <module>
      1 # load dataset into mne Raw object
      2 extra_params = dict(preload=True)
----> 3 raw = read_raw_bids(dataset_path, extra_params)

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

D:\ProgramData\Miniconda3\envs\mne\lib\site-packages\mne_bids\read.py in read_raw_bids(bids_path, extra_params, verbose)
    682     if raw_path.suffix == '.fif' and 'allow_maxshield' not in extra_params:
    683         extra_params['allow_maxshield'] = True
--> 684     raw = _read_raw(raw_path, electrode=None, hsp=None, hpi=None,
    685                     config_path=config_path, **extra_params)
    686 

D:\ProgramData\Miniconda3\envs\mne\lib\site-packages\mne_bids\read.py in _read_raw(raw_path, electrode, hsp, hpi, allow_maxshield, config_path, **kwargs)
     57     elif ext in ['.ds', '.vhdr', '.set', '.edf', '.bdf', '.EDF']:
     58         raw_path = Path(raw_path)
---> 59         raw = reader[ext](raw_path, **kwargs)
     60 
     61     # MEF and NWB are allowed, but not yet implemented

D:\ProgramData\Miniconda3\envs\mne\lib\site-packages\mne\io\brainvision\brainvision.py in read_raw_brainvision(vhdr_fname, eog, misc, scale, preload, verbose)
    855     mne.io.Raw : Documentation of attribute and methods.
    856     """
--> 857     return RawBrainVision(vhdr_fname=vhdr_fname, eog=eog,
    858                           misc=misc, scale=scale, preload=preload,
    859                           verbose=verbose)

<decorator-gen-211> in __init__(self, vhdr_fname, eog, misc, scale, preload, verbose)

D:\ProgramData\Miniconda3\envs\mne\lib\site-packages\mne\io\brainvision\brainvision.py in __init__(self, vhdr_fname, eog, misc, scale, preload, verbose)
     71         vhdr_fname = op.abspath(vhdr_fname)
     72         (info, data_fname, fmt, order, n_samples, mrk_fname, montage,
---> 73          orig_units) = _get_vhdr_info(vhdr_fname, eog, misc, scale)
     74 
     75         with open(data_fname, 'rb') as f:

D:\ProgramData\Miniconda3\envs\mne\lib\site-packages\mne\io\brainvision\brainvision.py in _get_vhdr_info(vhdr_fname, eog, misc, scale)
    455                       "not a file with extension '%s'." % ext)
    456 
--> 457     settings, cfg, cinfostr, info = _aux_vhdr_info(vhdr_fname)
    458     info._unlocked = True
    459 

D:\ProgramData\Miniconda3\envs\mne\lib\site-packages\mne\io\brainvision\brainvision.py in _aux_vhdr_info(vhdr_fname)
    365         # same in Latin-1 and UTF-8
    366         header = header.decode('ascii', 'ignore').strip()
--> 367         _check_bv_version(header, 'header')
    368 
    369         settings = f.read()

D:\ProgramData\Miniconda3\envs\mne\lib\site-packages\mne\io\brainvision\brainvision.py in _check_bv_version(header, kind)
    315             return version
    316     else:
--> 317         raise ValueError(_data_err % (kind, header))
    318 
    319 

ValueError: MNE-Python currently only supports header versions 1.0 and 2.0, got unparsable '../../../.git/annex/objects/1W/fj/MD5E-s1619--90ced559786a5c30e9f7aadcb3a552d7.vhdr/MD5E-s1619--90ced559786a5c30e9f7aadcb3a552d7.vhdr'. Contact MNE-Python developers for support.
welcome[bot] commented 2 years ago

Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴🏽‍♂️

agramfort commented 2 years ago

can you share the file ../../../.git/annex/objects/1W/fj/MD5E-s1619-- 90ced559786a5c30e9f7aadcb3a552d7.vhdr/MD5E-s1619-- 90ced559786a5c30e9f7aadcb3a552d7.vhdr ?

Message ID: @.***>

zhengliuer commented 2 years ago

OK, I might know what happened. I didn't successfully download the files. the full size should be 44GB, and I've got bout 143MB. Is this a usual error when downloading data from OpenNeuro in Windiows?

zhengliuer commented 2 years ago

I'll close this issue for now.