I am a new user of mne-bids and am getting set up to convert raw .fif files to the mne-bids format. After that I will try out the mne-bids-pipeline for preprocessing and beyond.
I have 18 subjects, each with 6 task .fif files collected in 1 session. For just 1 of 18 subjects, 1 of 6 task files was recorded in two parts (data recording accidently stopped then restarted during acquisition). My question is how to accommodate these 2 files during the bids conversion and into the mne-bids-pipeline? At what stage should I concatenate the files?
My initial thought was to read in the two .fif files as separate runs during bids conversion and then concatenate. Then I would have 1 task file as for all other tasks and all other subjects to take forward to the mne-bids-pipeline. But I’m not sure this is appropriate and I’m also unclear how I would name the concatenated raw file.
Alternatively ought the two files remain separate during conversion, into the mne-bids-pipeline and through the preprocessing (i.e. for maxfiltering, filtering, ICA etc)?
Regarding the file naming, if the two files are identified by run number (run-01, run-02), do all subjects need to have run specified for that task(i.e. run-01 for the equivalent single task file)? Do I need to include run number (run-01) for the other tasks?
With many thanks for advice so I adopt best practices.
Strictly speaking, I’d think that these are then two acquisition runs, hence should be treated as two separate runs. But practically speaking, I think it would make sense to concatenate these two runs. Problem is that this introduces an “edge” in the data, but MNE-Python marks it as such via an annotation. When writing to BIDS, you must ensure that this annotation is preserved (it must end up in events.tsv), and ideally you document that the data was concatenated. If you use MNE-BIDS, the edge annotation should be written to events.tsv automatically, but please double-check this.
Just name it like a normal run.
This is possible too – the pipeline should handle varying numbers of runs for each participant.
For consistency, I’d add the run entity to the filenames for all participants, yes.
I concatenated the two files but then when I tried to write to bids I got the following error:
ValueError: The raw data you want to write contains more time points than the raw data on disk. It is possible that you concatenated your data, which write_raw_bids() won’t accept. If you believe you have a valid use case that should be supported, please reach out to the developers at Issues · mne-tools/mne-bids · GitHub
Based on your experience, do you think I have a valid use case?! Thank you for your advice.
the MNE-BIDS error message isn’t very helpful and we should improve it.
I suggest you preload the data and write it while passing the parameters allow_preload=True, format='FIF' to write_raw_bids(). Here’s a minimal example that demonstrates this:
Thank you @richard. This worked smoothly and the bids files have been written.
However, looking at the events.tsv file it seems that the edge annotation you described earlier has not been automatically written. Please can you advise how to deal with this?
Lucy, can you perhaps provide a minimal working example (MWE) to replicate your problem, using one of the datasets shipped with MNE-Python, preferably the one called sample?
I can get the annotations to the _events.tsv if I use your minimal code but have not managed to get the combination of actual events / trigger codes and annotations. I tried to include the events of interest in the following way:
Hello again @richard. Unfortunately I still haven’t been able to get the annotations (from concatenation) to show alongside the events in the _tsv file so I wonder if you could please help?
Perhaps I’m missing something simple or maybe I’m reading the events (triggers) incorrectly (see minimal example using sample data). As I said earlier, the annotations show if I’m not also detailing the events defined by triggers. Thanks for any advice or pointers.