Mne_bids: writing files only works, if data are unloaded

Dear everybody,

is there a specific reason why mne-bids only writes raw files, if the data are not loaded.

In my opinion this unnecessarily complicates things if you want to save them after a processing step that requires loading of data (i.e. resampling, filters, epoching, etc.).

How do you handle that problem? Are you performing a temporary save and point to that one in order to be able to save correctly? Am I missing something here?

If not, would it make sense for you to have mne-bids perform the above mentioned interim-step?

Thanks for your advice!

Rudi K.

Hello @RuKrei,

the reasoning behind this is simple: currently, MNE-BIDS does not support working with what BIDS calls “derivatives”, i.e. processed data. This means all it’s currently intended to do is read and write “raw”, i.e. unprocessed, data.

Take for example the MNE Study Template, a processing pipeline that operates on BIDS data. Looking at the code, you will see that only in the very first step we load the data using MNE-BIDS, and after that we read and write it using “plain” MNE-Python.

I know this can be frustrating for certain use cases, but as long as we don’t have “proper” derivatives support, this is just how it is.

@sappelhoff, I lost track – how far along is the BIDS derivatives specification, anyway? When can we start adding support to MNE-BIDS? :slight_smile:

…thanks for the quick reply.
No worries, it’s easily possible to circumvent the problem by pointing BIDS path to derivatives-folder and working with processing flags.

Thanks for the effort you are putting into mne-bids, it has come a long way already :slight_smile:


the “common derivatives” are there: BIDS Derivatives - Brain Imaging Data Structure v1.4.1

but that’s currently not very helpful for MEEG and s/iEEG data. :man_shrugging: we’ll have to push

however, apart from annotations (which would be reasonably simple to add, perhaps as an extension to events.tsv with some added conventions and good tools), it’s unclear to me what direction we should push in, and who the “we” is :slight_smile:

We == the MNE-BIDS folks :sweat_smile:
I was thinking that we could start with a write_derivative() function, which would allow storing data (that may even have been pre-loaded) in derivatives/. But we should probably discuss this over at the MNE-BIDS issue tracker…

I think there is another slightly obscure technical reason for not allowing to writing anything beyond a “raw” file. That is, we don’t have reliable writers for most of the file formats. We can write to fif and brainvision reasonably well for now but not for the other formats. For the other formats, mne-bids copies and extracts metadata.

We could potentially allow writing for fif and BV but again … I agree with Richard and Stefan that it’s better to stick to the standard as far as possible.


1 Like