Concerns about head position estimation using compute_head_pos

  • MNE-Python version: 0.22.0
  • operating system: Ubuntu 20.04.1 LTS

Dear experts,

I tried to get head position of a subject during MEG recording at rest. For this, I used raw data (no MaxFilter, motion correction, SSS/tSSS is applied to these data yet) and this tutorial: Annotate movement artifacts and reestimate dev_head_t — MNE 0.24.0 documentation

So my code looks like:
chpi_amplitudes = mne.chpi.compute_chpi_amplitudes(raw, t_step_min=0.5)
chpi_locs = mne.chpi.compute_chpi_locs(raw.info, chpi_amplitudes)
head_pos = mne.chpi.compute_head_pos(raw.info, chpi_locs)

The output looks fine, and what I actually wanted is to get (x,y,z) coordinates of head positions over time, to remove some outliers points, and choose optimal head position to transform raw data to this new head position.

I found that I can get (x,y,z) coordinates from head_pos in mm like this:

x = head_pos[:,4]*1000
y = head_pos[:,5]*1000
z = head_pos[:,6]*1000

I then plotted how (x,y,z) coordinates change during MEG recording (see Figure, B).

I also wanted to compare my plots with the ones provided in the tutorial:
fig = mne.viz.plot_head_positions(head_pos) - see Figure, A for the output

Surprisingly, I observed that the obtained pictures are quite different, although at least I thought that they should represent the same thing (I tried this for other subjects, situation is similar). These results seem confusing as they are both obtained using head_pos, so it seems they are basing on the same information about head positions, and I believe that mne.viz.plot_head_positions function represents changes in (x,y,z) coordinates during MEG recording (Figure,A), same as plots in Figure,B. Still, it seems like plots in Figure are inverted, or values are multiplied by -1, or something else…

Where could I make a mistake? Why this difference occurs?
My main aim was to get optimal (x,y,z) coordinates to transform my data to this new origin. And I see example of doing this in the tutorial, however, I just don’t understand should I believe this result or not, as they are inconsistent with (x,y,z) plots.
So I am also wondering which coordinates should I believe and choose for the analysis - the ones plotted by mne.viz.plot_head_positions function of the ones in head_pos variable?

Thanks for any help!


Victoria

Hello @okapi,

I don’t know the answer, but I’m tagging @larsoner, who might know.

Best wishes,
Richard

One is giving you the translation from the head-to-device transform (left/A), and the other is the translation from the device-to-head transformation (right/B). What is stored in read_head_pos is the time-varying device-to-head transformation parameters, but what plot_head_positions will do is invert the device-to-head transformation to get the head-to-device one. This is more readable because we think of the sensors as being fixed and the head as being the thing that moves.

For example, in the left plot, Z goes more negative, so you know the subject is moving out of the helmet (more negative in the Z axis in the device space). The same thing can be inferred from the right plot, too, it’s just more annoying to think about – namely, that the sensors are moving upward (+Z as a function of time) in the head coordinate frame.

2 Likes

Thank you, now it’s much more clear!