Correct head movements with cHPI🔗

Important

This example requires the meg_wiki package to download the sample dataset. This package can be installed with pip:

$ pip install git+https://github.com/fcbg-hnp-meeg/meg-wiki

Signal-Space Separation (SSS) and Maxwell filter[1][2] can be used to compensate for head movements during a recording. To run SSS, you can use either MEGIN’s software on the DANA or MNE-Python’s implementation.

Tip

The enhanced version available in MNE-Python is recommended. See mne.preprocessing.maxwell_filter(). The fine calibration file and the cross-talk correction are available in the sample dataset ( see meg_wiki.datasets.sample.data_path()).

from pathlib import Path

from matplotlib import pyplot as plt
from mne.chpi import (
    compute_chpi_amplitudes,
    compute_chpi_locs,
    compute_head_pos,
    filter_chpi,
)
from mne.datasets import fetch_fsaverage
from mne.io import read_raw_fif
from mne.preprocessing import maxwell_filter
from mne.viz import plot_alignment, plot_head_positions, set_3d_view

from meg_wiki.datasets import sample

Head Position Indicator (HPI)🔗

Head Position Indication (HPI) is a technique to measure the head position with respect to the MEG sensors. 5 coils are placed on the participant head and digitized (see this section about digitization) in the head coordinate frame. At the beginning of a recording, an electromagnetic pulse if delivered on the 5 coils at 5 unique frequencies. The coil position with respect to the MEG sensors is estimated by measuring the magnetic field produced by this pulse on the MEG sensors.

The initial HPI measurement is used to determine the device to head affine transformation matrix stored in raw.info["dev_head_t"].

raw = read_raw_fif(
    sample.data_path() / "recordings" / "sample-chpi-raw.fif", preload=True
)
raw.info["dev_head_t"]
<Transform | MEG device->head>
[[ 0.99706715 -0.0762954   0.00600351  0.00164202]
 [ 0.07619333  0.99696928  0.01570909 -0.00272158]
 [-0.00718385 -0.01520559  0.99985856  0.03805892]
 [ 0.          0.          0.          1.        ]]

The initial head position can be visualized within the sensor helmet with mne.viz.plot_alignment().

Note

The figure below uses fsaverage MRI from MNE-Python’s dataset, which does not correspond to the subject in the raw recording. In practice, the subject’s individual MRI should be used.

subjects_dir = Path(fetch_fsaverage()).parent
fig = plot_alignment(
    raw.info,
    trans="fsaverage",
    subject="fsaverage",
    subjects_dir=subjects_dir,
    surfaces="head-dense",
    meg=("helmet", "sensors"),
    dig="fiducials",
    show_axes=True,
)
set_3d_view(fig, 35, 70, distance=0.6, focalpoint=(0.0, 0.0, 0.0))
30 cHPI

continuous Head Position Indicator (cHPI)🔗

If the recording is short, if the participant behaves and is focused on the task, one can assume that the head remained still during the recording. In this case, the initial device to head transformation estimated during the HPI measurement can be assumed to be constant.

cHPI is a technique to continuously monitor the head position during the recording, useful when the previous assumption does not hold. When cHPI is enabled, the 5 HPI coils are continuously excited at 5 unique frequencies. The magnetic field produced by the coils is measured by the MEG sensors alongside brain activity.

fig = raw.plot(
    duration=4,
    n_channels=10,
    scalings=dict(grad=4e-10),
    show_scrollbars=False,
    show_scalebars=False,
)
fig.axes[0].axvline(1.492, color="darkgreen", linestyle="--")
fig.axes[0].text(
    1.492 - 0.992, fig.axes[0].get_ylim()[0] * 0.05, "cHPI OFF", fontsize=18
)
fig.axes[0].text(1.492 + 1.1, fig.axes[0].get_ylim()[0] * 0.05, "cHPI ON", fontsize=18)
plt.show()
30 cHPI
raw.compute_psd(fmin=280, fmax=340).plot()
plt.show()
Gradiometers, Magnetometers

The signal produced by the HPI coils can be used to estimate the position of the 5 emitting coils at different time points, and thus to track the time-varying head position.

Estimating the head position🔗

In MNE-Python, the head position is estimated through 3 steps:

Note

The function mne.chpi.compute_head_pos() returns an array of shape (n_pos, 10) containing the translations as (x, y, z) and the rotations as quaternions (q1, q2, q3). The translations and rotations can be converted to translation and rotation matrixes with mne.chpi.head_pos_to_trans_rot_t().

/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.000:    0/5 good HPI fits, cannot determine the transformation (0.12, 0.06, 0.06, 0.08, 0.08 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.010:    0/5 good HPI fits, cannot determine the transformation (0.12, 0.08, 0.06, 0.07, 0.08 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.020:    0/5 good HPI fits, cannot determine the transformation (0.10, 0.08, 0.08, 0.08, 0.08 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.030:    0/5 good HPI fits, cannot determine the transformation (0.11, 0.08, 0.08, 0.08, 0.08 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.040:    0/5 good HPI fits, cannot determine the transformation (0.09, 0.06, 0.08, 0.07, 0.06 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.050:    0/5 good HPI fits, cannot determine the transformation (0.09, 0.06, 0.08, 0.09, 0.07 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.060:    0/5 good HPI fits, cannot determine the transformation (0.07, 0.06, 0.07, 0.08, 0.05 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.070:    0/5 good HPI fits, cannot determine the transformation (0.08, 0.05, 0.09, 0.08, 0.08 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.080:    0/5 good HPI fits, cannot determine the transformation (0.12, 0.07, 0.10, 0.09, 0.10 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.090:    0/5 good HPI fits, cannot determine the transformation (0.10, 0.08, 0.07, 0.08, 0.08 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.100:    0/5 good HPI fits, cannot determine the transformation (0.10, 0.08, 0.08, 0.05, 0.05 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.110:    0/5 good HPI fits, cannot determine the transformation (0.10, 0.06, 0.09, 0.07, 0.06 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.120:    0/5 good HPI fits, cannot determine the transformation (0.09, 0.07, 0.11, 0.08, 0.10 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.130:    0/5 good HPI fits, cannot determine the transformation (0.10, 0.06, 0.11, 0.06, 0.08 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.140:    0/5 good HPI fits, cannot determine the transformation (0.10, 0.07, 0.10, 0.06, 0.06 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.150:    0/5 good HPI fits, cannot determine the transformation (0.08, 0.08, 0.11, 0.06, 0.06 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.160:    0/5 good HPI fits, cannot determine the transformation (0.07, 0.08, 0.11, 0.09, 0.07 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.170:    0/5 good HPI fits, cannot determine the transformation (0.06, 0.07, 0.07, 0.08, 0.07 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.180:    0/5 good HPI fits, cannot determine the transformation (0.07, 0.06, 0.07, 0.06, 0.10 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.190:    0/5 good HPI fits, cannot determine the transformation (0.07, 0.07, 0.06, 0.07, 0.10 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.200:    0/5 good HPI fits, cannot determine the transformation (0.07, 0.07, 0.05, 0.07, 0.07 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.210:    0/5 good HPI fits, cannot determine the transformation (0.08, 0.06, 0.06, 0.08, 0.09 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.220:    0/5 good HPI fits, cannot determine the transformation (0.08, 0.06, 0.08, 0.07, 0.07 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.230:    0/5 good HPI fits, cannot determine the transformation (0.09, 0.12, 0.08, 0.07, 0.06 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.240:    0/5 good HPI fits, cannot determine the transformation (0.08, 0.10, 0.11, 0.07, 0.07 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.250:    0/5 good HPI fits, cannot determine the transformation (0.09, 0.08, 0.11, 0.09, 0.07 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.260:    0/5 good HPI fits, cannot determine the transformation (0.08, 0.08, 0.14, 0.10, 0.06 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.270:    0/5 good HPI fits, cannot determine the transformation (0.07, 0.08, 0.11, 0.12, 0.05 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.280:    0/5 good HPI fits, cannot determine the transformation (0.09, 0.07, 0.10, 0.10, 0.06 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.290:    0/5 good HPI fits, cannot determine the transformation (0.10, 0.07, 0.11, 0.09, 0.08 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.300:    0/5 good HPI fits, cannot determine the transformation (0.09, 0.07, 0.10, 0.08, 0.06 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.310:    0/5 good HPI fits, cannot determine the transformation (0.09, 0.06, 0.13, 0.09, 0.07 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.320:    0/5 good HPI fits, cannot determine the transformation (0.09, 0.06, 0.15, 0.09, 0.05 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.330:    0/5 good HPI fits, cannot determine the transformation (0.09, 0.06, 0.14, 0.10, 0.05 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.340:    0/5 good HPI fits, cannot determine the transformation (0.08, 0.07, 0.10, 0.09, 0.14 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.350:    0/5 good HPI fits, cannot determine the transformation (0.08, 0.07, 0.06, 0.06, 0.08 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.360:    0/5 good HPI fits, cannot determine the transformation (0.10, 0.08, 0.07, 0.08, 0.08 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.370:    0/5 good HPI fits, cannot determine the transformation (0.11, 0.08, 0.07, 0.05, 0.06 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.380:    0/5 good HPI fits, cannot determine the transformation (0.07, 0.08, 0.05, 0.08, 0.06 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.390:    0/5 good HPI fits, cannot determine the transformation (0.06, 0.08, 0.07, 0.08, 0.07 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.400:    0/5 good HPI fits, cannot determine the transformation (0.08, 0.08, 0.07, 0.10, 0.08 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.410:    0/5 good HPI fits, cannot determine the transformation (0.07, 0.08, 0.06, 0.07, 0.07 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.420:    0/5 good HPI fits, cannot determine the transformation (0.08, 0.12, 0.06, 0.06, 0.07 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.430:    0/5 good HPI fits, cannot determine the transformation (0.08, 0.09, 0.10, 0.11, 0.08 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.440:    0/5 good HPI fits, cannot determine the transformation (0.09, 0.08, 0.07, 0.10, 0.09 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.450:    0/5 good HPI fits, cannot determine the transformation (0.10, 0.08, 0.07, 0.09, 0.10 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.460:    0/5 good HPI fits, cannot determine the transformation (0.10, 0.07, 0.10, 0.09, 0.11 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.470:    0/5 good HPI fits, cannot determine the transformation (0.12, 0.07, 0.12, 0.11, 0.11 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.480:    0/5 good HPI fits, cannot determine the transformation (0.12, 0.07, 0.07, 0.08, 0.14 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.490:    0/5 good HPI fits, cannot determine the transformation (0.09, 0.08, 0.08, 0.08, 0.13 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.500:    0/5 good HPI fits, cannot determine the transformation (0.08, 0.09, 0.06, 0.10, 0.08 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.510:    0/5 good HPI fits, cannot determine the transformation (0.08, 0.08, 0.08, 0.08, 0.10 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.520:    0/5 good HPI fits, cannot determine the transformation (0.08, 0.07, 0.05, 0.07, 0.12 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.530:    0/5 good HPI fits, cannot determine the transformation (0.09, 0.08, 0.06, 0.07, 0.12 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.540:    0/5 good HPI fits, cannot determine the transformation (0.09, 0.09, 0.06, 0.08, 0.10 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.550:    0/5 good HPI fits, cannot determine the transformation (0.09, 0.07, 0.08, 0.09, 0.07 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.560:    0/5 good HPI fits, cannot determine the transformation (0.11, 0.07, 0.09, 0.07, 0.08 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.570:    0/5 good HPI fits, cannot determine the transformation (0.11, 0.08, 0.13, 0.07, 0.09 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.580:    0/5 good HPI fits, cannot determine the transformation (0.09, 0.08, 0.12, 0.07, 0.13 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.590:    0/5 good HPI fits, cannot determine the transformation (0.06, 0.07, 0.10, 0.07, 0.13 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.600:    0/5 good HPI fits, cannot determine the transformation (0.07, 0.06, 0.08, 0.07, 0.11 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.610:    0/5 good HPI fits, cannot determine the transformation (0.08, 0.07, 0.09, 0.06, 0.06 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.620:    0/5 good HPI fits, cannot determine the transformation (0.06, 0.08, 0.09, 0.05, 0.08 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.630:    0/5 good HPI fits, cannot determine the transformation (0.08, 0.06, 0.09, 0.06, 0.10 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.640:    0/5 good HPI fits, cannot determine the transformation (0.05, 0.07, 0.12, 0.08, 0.09 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.650:    0/5 good HPI fits, cannot determine the transformation (0.05, 0.07, 0.11, 0.08, 0.11 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.660:    0/5 good HPI fits, cannot determine the transformation (0.07, 0.09, 0.08, 0.08, 0.08 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.670:    0/5 good HPI fits, cannot determine the transformation (0.07, 0.06, 0.07, 0.07, 0.09 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.680:    0/5 good HPI fits, cannot determine the transformation (0.10, 0.10, 0.08, 0.06, 0.06 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.690:    0/5 good HPI fits, cannot determine the transformation (0.10, 0.10, 0.07, 0.08, 0.07 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.700:    0/5 good HPI fits, cannot determine the transformation (0.10, 0.07, 0.05, 0.13, 0.06 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.710:    0/5 good HPI fits, cannot determine the transformation (0.10, 0.07, 0.05, 0.10, 0.08 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.720:    0/5 good HPI fits, cannot determine the transformation (0.09, 0.08, 0.08, 0.08, 0.08 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.730:    0/5 good HPI fits, cannot determine the transformation (0.08, 0.09, 0.07, 0.11, 0.10 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.740:    0/5 good HPI fits, cannot determine the transformation (0.10, 0.11, 0.08, 0.06, 0.08 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.750:    0/5 good HPI fits, cannot determine the transformation (0.06, 0.12, 0.09, 0.08, 0.09 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.760:    0/5 good HPI fits, cannot determine the transformation (0.06, 0.10, 0.09, 0.07, 0.10 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.770:    0/5 good HPI fits, cannot determine the transformation (0.07, 0.10, 0.08, 0.07, 0.08 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.780:    0/5 good HPI fits, cannot determine the transformation (0.07, 0.08, 0.08, 0.08, 0.08 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.790:    0/5 good HPI fits, cannot determine the transformation (0.08, 0.06, 0.08, 0.06, 0.09 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.800:    0/5 good HPI fits, cannot determine the transformation (0.08, 0.07, 0.06, 0.09, 0.09 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.810:    0/5 good HPI fits, cannot determine the transformation (0.06, 0.08, 0.10, 0.08, 0.10 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.820:    0/5 good HPI fits, cannot determine the transformation (0.07, 0.07, 0.12, 0.08, 0.09 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.830:    0/5 good HPI fits, cannot determine the transformation (0.07, 0.05, 0.10, 0.08, 0.09 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.840:    0/5 good HPI fits, cannot determine the transformation (0.08, 0.07, 0.11, 0.10, 0.07 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.850:    0/5 good HPI fits, cannot determine the transformation (0.09, 0.07, 0.10, 0.07, 0.08 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.860:    0/5 good HPI fits, cannot determine the transformation (0.09, 0.08, 0.10, 0.10, 0.07 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.870:    0/5 good HPI fits, cannot determine the transformation (0.07, 0.07, 0.08, 0.10, 0.06 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.880:    0/5 good HPI fits, cannot determine the transformation (0.12, 0.07, 0.07, 0.08, 0.06 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.890:    0/5 good HPI fits, cannot determine the transformation (0.12, 0.07, 0.08, 0.11, 0.09 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.900:    0/5 good HPI fits, cannot determine the transformation (0.10, 0.07, 0.09, 0.08, 0.12 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.910:    0/5 good HPI fits, cannot determine the transformation (0.09, 0.08, 0.08, 0.09, 0.14 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.920:    0/5 good HPI fits, cannot determine the transformation (0.11, 0.07, 0.09, 0.09, 0.12 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.930:    0/5 good HPI fits, cannot determine the transformation (0.06, 0.06, 0.07, 0.08, 0.07 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.940:    0/5 good HPI fits, cannot determine the transformation (0.06, 0.06, 0.06, 0.06, 0.07 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.950:    0/5 good HPI fits, cannot determine the transformation (0.07, 0.07, 0.06, 0.07, 0.08 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.960:    0/5 good HPI fits, cannot determine the transformation (0.06, 0.06, 0.09, 0.06, 0.07 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.970:    0/5 good HPI fits, cannot determine the transformation (0.06, 0.07, 0.08, 0.07, 0.06 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.980:    0/5 good HPI fits, cannot determine the transformation (0.08, 0.06, 0.08, 0.09, 0.07 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=38.990:    0/5 good HPI fits, cannot determine the transformation (0.11, 0.07, 0.08, 0.07, 0.10 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.000:    0/5 good HPI fits, cannot determine the transformation (0.10, 0.05, 0.09, 0.08, 0.09 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.010:    0/5 good HPI fits, cannot determine the transformation (0.08, 0.08, 0.07, 0.08, 0.07 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.020:    0/5 good HPI fits, cannot determine the transformation (0.16, 0.06, 0.06, 0.08, 0.08 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.030:    0/5 good HPI fits, cannot determine the transformation (0.16, 0.07, 0.07, 0.07, 0.07 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.040:    0/5 good HPI fits, cannot determine the transformation (0.14, 0.10, 0.09, 0.06, 0.07 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.050:    0/5 good HPI fits, cannot determine the transformation (0.15, 0.08, 0.09, 0.06, 0.07 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.060:    0/5 good HPI fits, cannot determine the transformation (0.11, 0.10, 0.08, 0.06, 0.09 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.070:    0/5 good HPI fits, cannot determine the transformation (0.13, 0.07, 0.08, 0.10, 0.05 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.080:    0/5 good HPI fits, cannot determine the transformation (0.11, 0.07, 0.09, 0.09, 0.07 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.090:    0/5 good HPI fits, cannot determine the transformation (0.08, 0.06, 0.08, 0.08, 0.06 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.100:    0/5 good HPI fits, cannot determine the transformation (0.07, 0.06, 0.08, 0.10, 0.09 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.110:    0/5 good HPI fits, cannot determine the transformation (0.07, 0.06, 0.09, 0.08, 0.08 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.120:    0/5 good HPI fits, cannot determine the transformation (0.06, 0.10, 0.08, 0.09, 0.07 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.130:    0/5 good HPI fits, cannot determine the transformation (0.06, 0.08, 0.06, 0.09, 0.09 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.140:    0/5 good HPI fits, cannot determine the transformation (0.08, 0.09, 0.08, 0.10, 0.07 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.150:    0/5 good HPI fits, cannot determine the transformation (0.10, 0.08, 0.09, 0.10, 0.09 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.160:    0/5 good HPI fits, cannot determine the transformation (0.07, 0.10, 0.10, 0.10, 0.07 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.170:    0/5 good HPI fits, cannot determine the transformation (0.07, 0.10, 0.09, 0.08, 0.12 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.180:    0/5 good HPI fits, cannot determine the transformation (0.07, 0.10, 0.07, 0.07, 0.10 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.190:    0/5 good HPI fits, cannot determine the transformation (0.08, 0.09, 0.09, 0.08, 0.11 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.200:    0/5 good HPI fits, cannot determine the transformation (0.07, 0.15, 0.08, 0.11, 0.11 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.210:    0/5 good HPI fits, cannot determine the transformation (0.08, 0.10, 0.10, 0.09, 0.08 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.220:    0/5 good HPI fits, cannot determine the transformation (0.10, 0.10, 0.10, 0.06, 0.08 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.230:    0/5 good HPI fits, cannot determine the transformation (0.11, 0.08, 0.10, 0.08, 0.09 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.240:    0/5 good HPI fits, cannot determine the transformation (0.08, 0.06, 0.09, 0.09, 0.11 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.250:    0/5 good HPI fits, cannot determine the transformation (0.08, 0.06, 0.10, 0.10, 0.07 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.260:    0/5 good HPI fits, cannot determine the transformation (0.06, 0.06, 0.10, 0.08, 0.07 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.270:    0/5 good HPI fits, cannot determine the transformation (0.07, 0.07, 0.10, 0.08, 0.10 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.280:    0/5 good HPI fits, cannot determine the transformation (0.09, 0.10, 0.14, 0.07, 0.12 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.290:    0/5 good HPI fits, cannot determine the transformation (0.12, 0.09, 0.13, 0.07, 0.10 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.300:    0/5 good HPI fits, cannot determine the transformation (0.14, 0.08, 0.10, 0.06, 0.08 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.310:    0/5 good HPI fits, cannot determine the transformation (0.13, 0.08, 0.09, 0.08, 0.08 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.320:    0/5 good HPI fits, cannot determine the transformation (0.12, 0.08, 0.09, 0.07, 0.07 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.330:    0/5 good HPI fits, cannot determine the transformation (0.12, 0.06, 0.07, 0.09, 0.06 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.340:    0/5 good HPI fits, cannot determine the transformation (0.12, 0.07, 0.08, 0.10, 0.07 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.350:    0/5 good HPI fits, cannot determine the transformation (0.23, 0.31, 0.34, 0.20, 0.22 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.360:    0/5 good HPI fits, cannot determine the transformation (0.22, 0.33, 0.33, 0.30, 0.31 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.370:    0/5 good HPI fits, cannot determine the transformation (0.47, 0.43, 0.39, 0.40, 0.42 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.380:    0/5 good HPI fits, cannot determine the transformation (0.92, 0.51, 0.42, 0.49, 0.51 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.390:    0/5 good HPI fits, cannot determine the transformation (0.94, 0.63, 0.50, 0.63, 0.56 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.400:    0/5 good HPI fits, cannot determine the transformation (0.96, 0.78, 0.61, 0.76, 0.55 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.410:    0/5 good HPI fits, cannot determine the transformation (0.97, 0.83, 0.78, 0.90, 0.65 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.420:    2/5 good HPI fits, cannot determine the transformation (0.99, 0.86, 0.98, 0.99, 0.95 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.440:    1/5 good HPI fits, cannot determine the transformation (0.98, 0.87, 0.95, 0.96, 0.91 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.460:    1/5 good HPI fits, cannot determine the transformation (0.99, 0.93, 0.94, 0.95, 0.93 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)
/home/runner/work/meg-wiki/meg-wiki/tutorials/30_cHPI.py:148: RuntimeWarning:     t=39.480:    2/5 good HPI fits, cannot determine the transformation (0.99, 0.96, 0.98, 0.98, 0.97 GOF)!
  head_pos = compute_head_pos(raw.info, chpi_locs)

The estimated head position can be plotted in function of time with mne.viz.plot_head_positions().

  • Position (mm), Rotation (quat)
  • 30 cHPI

Compensate head movements🔗

Now that the head position at different timepoints, this information can be used to compensate for the head movements during the recording. The function mne.preprocessing.maxwell_filter() uses the returned head positions in the argument head_pos to apply the compensation and estimate the signal at every sensor position as if the head was still, i.e., in the position measured by the initial HPI measurement.

Tip

It is important to first remove the cHPI signal from the recording and to mark bad channels.

raw = filter_chpi(raw)
raw.info["bads"] = [  # strict selection for this example
    "MEG1531",
    "MEG1532",
    "MEG1533",
    "MEG1542",
    "MEG1522",
    "MEG1541",
    "MEG1321",
]
calibration = sample.data_path() / "calibration" / "sss_cal.dat"
cross_talk = sample.data_path() / "cross-talk" / "ct_sparse.fif"
raw_sss = maxwell_filter(
    raw, calibration=calibration, cross_talk=cross_talk, head_pos=head_pos
)

Let’s visualize the effect on a triplet of sensors located on the top of the head. Note however that this represents the effect of SSS and movemvent compensation together.

f, ax = plt.subplots(3, 1, sharex=True, figsize=(10, 5), layout="constrained")
times = raw.times[raw.time_as_index(30)[0] :]
picks = ["MEG0711", "MEG0712", "MEG0713"]
for k, pick in enumerate(picks):
    data = raw.get_data(picks=pick, tmin=30).squeeze()
    ax[k].plot(times, data, label="Raw" if k == 0 else None)
    data = raw_sss.get_data(picks=pick, tmin=30).squeeze()
    ax[k].plot(times, data, color="red", label="SSS" if k == 0 else None)
    ax[k].set_title(f"{'MAG:' if k == 0 else 'GRAD:'} {pick}")
plt.show()
MAG: MEG0711, GRAD: MEG0712, GRAD: MEG0713

Magnetometers which are more sensitive to distant fields and thus to environmental artifacts are more affected by SSS than gradiometers.

Note

Note that on top of movement compensation, SSS can also transform the signal as if it was emitted from a different head position, through the argument destination. This can be useful to compare signal between subjects in sensor space or to bring back a tilted head to a more upright position.

References🔗

Total running time of the script: (2 minutes 30.568 seconds)

Estimated memory usage: 786 MB

Gallery generated by Sphinx-Gallery