Dear community,
I’m currently working on building an analysis pipeline for computing the MEG forward model, but I have some uncertainties regarding the role of info["dev_head_t"]
in MNE.
In scenarios where MEG data are collected across multiple sessions for the same participant, each recording can have a different info["dev_head_t"]
transformation (i.e., a different device-to-head transformation matrix).
If we use the default MEG-to-head transform in the destination
parameter of mne.preprocessing.maxwell_filter
, then — as I understand it — MNE will incorporate this transformation when computing the forward model.
Based on this, I assume that it would be incorrect to reuse a forward model computed with one info["dev_head_t"]
for another recording that has a different dev_head_t
, since the forward solution is dependent on the head position relative to the sensors. Is this assumption correct?
If so, does this mean we should compute a separate forward model for each unique info["dev_head_t"]
? I’d appreciate confirmation or correction of this approach.
To illustrate my concern, here’s an example of code that shows a potentially incorrect usage: a forward model is computed from one head position but applied to data with a different dev_head_t
:
import numpy as np
from matplotlib import pyplot as plt
import mne
from mne.datasets import testing
from mne.io import read_info
data_dir = testing.data_path(download=True)
subjects_dir = data_dir / "subjects"
sample_meg_dir = data_dir / "MEG" / "sample"
raw_fname = sample_meg_dir / "sample_audvis_trunc_raw.fif"
fwd_fname = sample_meg_dir / "sample_audvis_trunc-meg-eeg-oct-6-fwd.fif"
bem_fname = subjects_dir / "sample" / "bem" / "sample-320-320-320-bem-sol.fif"
# Load data
raw = mne.io.read_raw_fif(raw_fname, allow_maxshield=True, verbose=False)
fwd = mne.read_forward_solution(fwd_fname)
# First head position
info_1 = raw.info.copy()
fwd_1 = mne.make_forward_solution(info_1, fwd["mri_head_t"], fwd["src"], bem_fname)
# Simulate a second recording with a modified head position
info_2 = raw.info.copy()
trans = info_2["dev_head_t"]['trans'].copy()
trans[0, 0] += 1e-1 # Modify the transform slightly
info_2["dev_head_t"] = mne.transforms.Transform(1, 4, trans=trans)
fwd_2 = mne.make_forward_solution(info_2, fwd["mri_head_t"], fwd["src"], bem_fname)
# Apply forward model with mismatched head position
noise_cov = mne.make_ad_hoc_cov(info_1)
inverse = mne.minimum_norm.make_inverse_operator(
info_1, fwd_2, noise_cov=noise_cov, loose="auto", depth=None, fixed=True
)
mne.minimum_norm.apply_inverse_raw(raw, inverse, lambda2=1.0 / 9.0)
Does this kind of mismatch invalidate the results ? If yes, wouldn’t it make sense for MNE to emit a warning or even an error in such cases (assuming that the necessary metadata survives up to that point to allow the verification)?
Any clarification or best practices would be greatly appreciated!
Best regards,
Related to this topic
- Operating system: windows
- MNE version : ‘0.20.dev0’