how to deal with different runs associated with different head positions

I have a subject whose data has different runs associated with different head positions. if i want to analyze these data uniformly, how to use mne.preprocessing.maxwell_filter to realign the runs to a common head position?

Below are the error info when I tried to use mne.concatenate_epochs on epochs from different runs.

ValueError: epochs[1].info['dev_head_t'] differs. The instances probably come from different runs, and are therefore associated with different head positions. Manually change info['dev_head_t'] to avoid this message but beware that this means the MEG sensors will not be properly spatially aligned. See mne.preprocessing.maxwell_filter to realign the runs to a common head position.

Hello, you need to pick one run as a “reference” run and then use Maxwell filter to transform the head positions of the other runs to that reference run position (which we call the “destination”).

Something like:

destination = raw_ref.info["dev_head_t"]
raw_sss = mne.preprocessing.maxwell_filter(raw, destination=destination, ...)

Best wishes,
Richard

@agramfort @larsoner Do you think we could improve the error message? And I don’t think we currently cover this in our tutorials either

1 Like

Sure, PR welcome to improve the error message

And agreed we don’t cover it – I don’t think we have a good dataset to showcase the problem (and adding one just to do that seems like overkill).

1 Like

But wouldn’t you agree this is a very common use case? I only found the solution I posted above by looking at the code of MNE-BIDS-Pipeline

Thanks a lot for your answer!

For meg data recorded by ELEKTA , it is typically preprocessed using MaxFilter, and MNE can’t do maxwell filter again on data that had already been filterd.

So , I need to do maxwell filter by MNE directly on raw data from ELEKTA and make sure that it is the same as MaxFilter.

Are there any empirical steps or parameters that can be referenced? For example, I have obtained calibration and cross-talk files from the instrument platform, but I would still like some methods to confirm that using MNE for maxwell filter and using the software MaxFilter directly yield the same results.

Best wishes,
Ling

The Notes section at mne.preprocessing.maxwell_filter — MNE 1.5.1 documentation describes some similarities and differences between MaxFilter and MNE. Beyond that, I don’t know how similar or different the results from both applications are. I suppose @larsoner can help here.

Best wishes,
Richard

It occurred to me, can I use the mne.preprocessing.maxwell_filter function to align the data between different subjects?

My gut feeling is you shouldn’t do this, but this is outside of my area of expertise :slight_smile:

The results are not always identical but they should be very similar.

You can do this using the destination parameter, but keep in mind that the more you move a subject’s head position away from the one they were in during acquisition the more noise you will introduce. So if they all had sufficiently similar head positions you can transform them all to the same one, yeah.

1 Like

Thanks a lot ~