Skip to content

Fix find_bad_channels_maxwell and maxwell_filter cHPI indexing - #14142

Merged
larsoner merged 13 commits into
mne-tools:mainfrom
christianbrodbeck:fix/maxwell-head_pos
Aug 12, 2026
Merged

Fix find_bad_channels_maxwell and maxwell_filter cHPI indexing#14142
larsoner merged 13 commits into
mne-tools:mainfrom
christianbrodbeck:fix/maxwell-head_pos

Conversation

@christianbrodbeck

@christianbrodbeck christianbrodbeck commented Aug 8, 2026

Copy link
Copy Markdown
Member

What does this implement/fix?

In find_bad_channels_maxwell, _run_maxwell_filter is called for successive data chunks, but always with the same _MoveComp instance (mc). Inside _run_maxwell_filter , mc.initialize(...) sets up movement compensation starting at the beginning of the whole recording, rather than starting at the beginning of the relevant data chunk. This PR adds an argument to _run_maxwell_filter to use the appropriate data chunk index in the head movement recording.

Similarly, in maxwell_filter, _run_maxwell_filter processes successive data segments separated by annotations, but movement compensation previously advanced only across the processed samples. After a skipped segment, _MoveComp therefore resumed using head positions from before the skip rather than those corresponding to the next data segment. This PR resets movement compensation for each segment using its index in the full recording.

Additional information

Claude Opus 5 identified the issue and assisted in implementing a fix and test. Codex 5.6 Sol reviewed changes.

@larsoner

larsoner commented Aug 8, 2026

Copy link
Copy Markdown
Member

Nice! Can I push a commit to add/clean up a bit? Any reason still draft?

@christianbrodbeck

Copy link
Copy Markdown
Member Author

Now just waiting for CI to pass, feel free to push to clean it up @larsoner

@christianbrodbeck
christianbrodbeck marked this pull request as ready for review August 8, 2026 17:24
@christianbrodbeck

Copy link
Copy Markdown
Member Author

Updated the description for the second, related fix

@christianbrodbeck christianbrodbeck changed the title Fix find_bad_channels_maxwell cHPI correction Fix find_bad_channels_maxwell and maxwell_filter cHPI indexing Aug 9, 2026

@drammock drammock left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, @larsoner I'll let you merge if happy

@larsoner
larsoner enabled auto-merge (squash) August 12, 2026 18:52
@larsoner
larsoner merged commit d3a8eac into mne-tools:main Aug 12, 2026
31 checks passed
@christianbrodbeck
christianbrodbeck deleted the fix/maxwell-head_pos branch August 12, 2026 20:08
@larsoner

Copy link
Copy Markdown
Member

Thanks @christianbrodbeck !

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.

3 participants