How to share mf_destination across multiple tasks in a single MEG session?

Hi everyone,

I’m currently preprocessing MEG data using mne-bids-pipeline and I’m running into a couple of issues related to handling multiple tasks and split recordings.

Multiple tasks in the same session

I have three tasks (rest, task1, and task2) that were recorded sequentially within the same session, without the participant leaving the MEG. I would like all three tasks to share the same mf_destination.

One of my goals is to perform sensor-level MVPA, so having consistent head position compensation across tasks is important. Ideally, I would use a time-weighted average head position computed across all three tasks. However, it seems that this is not currently supported in mne-bids-pipeline.

How do you usually handle this situation in practice?

Issue with split files and mf_destination='twa'

Related but more specific: for a single task (task1), the data are split across four files:

sub-001_ses-01_task-task1_run-02_split-01_meg.fif
sub-001_ses-01_task-task1_run-01_split-01_meg.fif
sub-001_ses-01_task-task1_run-02_split-02_meg.fif
sub-001_ses-01_task-task1_run-01_split-02_meg.fif

When I set mf_destination = 'twa' and run the preprocessing/head_pos step of the pipeline, I encounter the following error:

│15:48:11│ :hourglass_not_done: sub-001 ses-01 run-02 Adding cHPI SNR and head positions to report.
│15:48:13│ :hourglass_not_done: sub-001 ses-01 run-02 Saving report: /path/to/derivatives/report.html
│15:48:14│ :hourglass_not_done: sub-001 ses-01 Computing time-weighted average head position
│15:48:31│ :repeat_single_button: sub-001 ses-01 A critical error occurred. The error message was: Number of head positions (2) must match the number of raw instances (4)

My assumption is that this is related to the data being split, but I’m not sure how this is supposed to be handled within the pipeline.

Any insights or suggestions would be greatly appreciated. Thanks in advance!


  • MNE version: 1.11
  • MNE-BIDS-pipeline version: 1.9.0
  • operating system: Rocky Linux 9.6 (Blue Onyx)

I also tried the current dev versions for both, it did not solve the problems.