Skip to content

Fix find_bad_channels_maxwell and maxwell_filter cHPI indexing - #14142

Open
christianbrodbeck wants to merge 11 commits into
mne-tools:mainfrom
christianbrodbeck:fix/maxwell-head_pos
Open

Fix find_bad_channels_maxwell and maxwell_filter cHPI indexing#14142
christianbrodbeck wants to merge 11 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
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.

2 participants