Thanks for the 0.7 mne-bids update!

Hello and thanks to everyone working on the 0.7 update! This tool helps our lab really a lot organizing datasets!

I have two additional comments.
First, I tried reading an ieeg Dataset including an electrode.tsv and a coordinatesystem.json. The files get correctly read, and I can also see in the montage the electrode locations.
Then I simply tested to write out the RawArray again using
mne_bids.write_raw_bids(raw_arr, bids_path, format="BrainVision")

This resulted in the following error:

ValueError Traceback (most recent call last)
----> 1 mne_bids.write_raw_bids(raw_arr, bids_path, format=“BrainVision”)

~\Anaconda3\lib\site-packages\mne_bids\ in write_raw_bids(raw, bids_path, events_data, event_id, anonymize, format, overwrite, verbose)
1265 # if we have an available DigMontage
1266 if[‘dig’] is not None and[‘dig’]:
→ 1267 _write_dig_bids(bids_path, raw, overwrite, verbose)
1268 else:
1269 logger.warning(f’Writing of electrodes.tsv is not supported ’

~\Anaconda3\lib\site-packages\mne_bids\ in _write_dig_bids(bids_path, raw, overwrite, verbose)
367 # XXX: To improve when mne-python allows coord_frame=‘unknown’
368 # coordinate frame is either
→ 369 coordsystem_path.update(space=coord_frame)
370 electrodes_path.update(space=coord_frame)

~\Anaconda3\lib\site-packages\mne_bids\ in update(self, check, **kwargs)
611 # Perform a check of the entities.
→ 612 self._check()
613 return self

~\Anaconda3\lib\site-packages\mne_bids\ in _check(self)
726 f’{self.datatype}‘)
727 elif space not in allowed_spaces_for_dtype:
→ 728 raise ValueError(f’space ({space}) is not valid for ’
729 f’datatype ({self.datatype}).\n’
730 f’Should be one of ’

ValueError: space (CapTrak) is not valid for datatype (ieeg).
Should be one of [‘ICBM452AirSpace’, ‘ICBM452Warp5Space’, ‘IXI549Space’, ‘fsaverage’, ‘fsaverageSym’, ‘fsLR’, ‘MNIColin27’, ‘MNI152Lin’, ‘MNI152NLin2009aSym’, ‘MNI152NLin2009bSym’, ‘MNI152NLin2009cSym’, ‘MNI152NLin2009aAsym’, ‘MNI152NLin2009bAsym’, ‘MNI152NLin2009cAsym’, ‘MNI152NLin6Sym’, ‘MNI152NLin6ASym’, ‘MNI305’, ‘NIHPD’, ‘OASIS30AntsOASISAnts’, ‘OASIS30Atropos’, ‘Talairach’, ‘UNCInfant’, ‘fsaverage3’, ‘fsaverage4’, ‘fsaverage5’, ‘fsaverage6’, ‘fsaveragesym’, ‘UNCInfant0V21’, ‘UNCInfant1V21’, ‘UNCInfant2V21’, ‘UNCInfant0V22’, ‘UNCInfant1V22’, ‘UNCInfant2V22’, ‘UNCInfant0V23’, ‘UNCInfant1V23’, ‘UNCInfant2V23’, ‘Other’, ‘Pixels’, ‘ACPC’]

I guess that it’s related to the standard “CapTrak” space, also for ieeg. Maybe switching this space for ieeg data to another space might already fix this issue.

My second question, and sorry if this is a bit unrelated, is that it would be super great in future to use write_raw_bids also without previously reading in a fif or brainvision file (as done here 08. Convert iEEG data to BIDS format — MNE-BIDS 0.14 documentation with
raw = []([misc_path]( + '/ecog/sample_ecog.edf')

So instead data could be simply specified as

ch_names = ["ch_1", "ch_2", "ch_3", "ch_4"]
info = mne.create_info(ch_names, 1000., 'ecog')
raw =[4, 2000]), info=info)['line_freq'] = 60  # specify power line frequency as required by BIDS
raw.set_channel_types({ch: 'ecog' for ch in raw.ch_names})

And then write_raw_bids could be called:

mne_bids.write_raw_bids(raw, bids_path=bids_path, format=“BrainVision”)

Which currently results in this error:

ValueError Traceback (most recent call last)
----> 1 mne_bids.write_raw_bids(raw, bids_path=bids_path, format=“BrainVision”)

~\Anaconda3\lib\site-packages\mne_bids\ in write_raw_bids(raw, bids_path, events_data, event_id, anonymize, format, overwrite, verbose)
1104 if not hasattr(raw, ‘filenames’) or raw.filenames[0] is None:
→ 1105 raise ValueError(‘raw.filenames is missing. Please set raw.filenames’
1106 ‘as a list with the full path of original raw file.’)

ValueError: raw.filenames is missing. Please set raw.filenamesas a list with the full path of original raw file.

I guess this is simply a feature request, but it would make writing BIDS a lot easier :slight_smile:

Thanks again for the great work!

  • MNE-BIDS version: 0.7
  • operating system: Windows 10

Hi @timonmerk :wave:

Just a note that the way we handle coordinate systems for iEEG between BIDS and MNE is currently very much in flux :grimacing: some pointers:

Having that said, I think your problem may be solved in parallel to that :thinking: But I am not sure because I don’t know the details. Could you please open a new issue on mne-bids including a full description of what you want to do, where it breaks, and what you expected instead of the breakage? :slight_smile:

just adding a crossref of this being discussed here: Why does MNE-BIDS always need the raw.filename attribute? · Issue #404 · mne-tools/mne-bids · GitHub

I just realized that the later part of this issue: bug: write_raw_bids uses CapTrak coordsys for iEEG data (invalid) · Issue #723 · mne-tools/mne-bids · GitHub

probably discusses the problem in some way. Still - I think a new issue with a clear and concise description would help us to debug this / improve this. The other issue has unfortunately become quite a mess of many different issues that are hard to track.

Thanks @sappelhoff, both of your referenced issues I wrote on Github, so I think I will be patient and come back to this at a later stage :slight_smile: I was just too excited about the update and decided to name the main issues we’re still facing.


@sappelhoff I have the very same issue and I would be really happy for some help how to fix it! :slightly_smiling_face:

hi @moritz-gerster could you please open a detailed bug report on the mne-bids issue tracker on GitHub? It’s more likely that somebody can help you there (including myself). thanks! :slight_smile:

Dear @sappelhoff ,

Yes, I wrote one: Montage coordinate frames are saved wrongly · Issue #961 · mne-tools/mne-bids · GitHub


1 Like