Skip to content

Use weighted cHPI coils during position fitting#14034

Open
larsoner wants to merge 3 commits into
mne-tools:mainfrom
larsoner:chpiw
Open

Use weighted cHPI coils during position fitting#14034
larsoner wants to merge 3 commits into
mne-tools:mainfrom
larsoner:chpiw

Conversation

@larsoner

@larsoner larsoner commented Jul 8, 2026

Copy link
Copy Markdown
Member

Closes #11330

This turned out to way simpler than I realized:

  1. Use a linear ramp from gof_limit to 1.
  2. Combine this with the dist_limit coil goodness estimate
  3. Pass these weights to our quat fitting function, which already supports weights

Implementation drafted with Opus 4.8 but I edited and vouch for all code.

Adapting the minimal example from the linked issue (data available there):

Minimial code
import mne
raw_file = 'te01a1.fif'
raw = mne.io.read_raw_fif(raw_file)
chpi_amps = mne.chpi.compute_chpi_amplitudes(raw, t_step_min=0.25, t_window=0.5)
chpi_locs = mne.chpi.compute_chpi_locs(raw.info, chpi_amps)
head_pos = mne.chpi.compute_head_pos(raw.info, chpi_locs, weighted=False)
mne.viz.plot_head_positions(head_pos)
head_pos = mne.chpi.compute_head_pos(raw.info, chpi_locs, weighted=True)
mne.viz.plot_head_positions(head_pos)
weighted=False weighted=True
image image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unstable estimation of the head position based on the HPI coils

1 participant