mne-tools / mne-tools/mne-python

ENH: Movement correction for OPM data

Open
#11,275 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
3.5k
Forks
1.6k
Avg merge
1d 6h
Merged PRs (30d)
100

Description

Time-varying position / head-movement correction would be the next natural step after #10780 I think.

IIRC the procedure is/could be here:

  1. Extract time-varying rigid-body position + rotation of the system, typically using optical tracking: new mne.chpi.read_head_pos_optitrack, or mne.chpi.calculate_head_pos_optitrack, depending on the complexity of the problem (if optitrack directly gives pos+rot, or we actually need to do some calculation). It's a bit of a misnomer, but mne.chpi is where all our head-position related stuff lives, so the optitrack outputting pos+rot as a function of time is natural there. We could put it in a new mne.optitrack, or mne.preprocessing.opm or something if we want, but optical tracking seems pretty generic.
  2. Clean up position+rotation parameters: new mne.chpi.clean_head_positions or so? Or maybe this should be built into calculate_head_pos_optitrack. TBD.
  3. Add head positions to the raw data (as new channels) -- this is what maxwell_filter does, so it's natural for us to do it as well -- maybe mne.chpi.add_head_positions(raw, pos) and you can choose how to interpolate. (Under the hood this probably boils down to a mne.add_channels((raw, RawArray(...))) or so but we'll need to interpolate/upsample the positions+rotations, and setting the info correctly will be annoying -- so not totally trivial, thus worth wrapping.)
  4. Regressing can then be done immediately with regress_artifact I think. OPM-specific options we need, if any, should hopefully be useful for other types of regression and thus reasonably implemented there.

@neurofractal did you ever play around/try regressing quaternions rather than Euler angles for rotation angle (by my bad memory you use Euler for regression)? We can convert back and forth but the .pos files we use for position + rotation information in space store in quaternions, so if those work just as well or better than Euler angles it's a slightly more natural fit here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing issue #10780 and the existing maxwell_filter and regress_artifact entry points. The proposed scope spans optical-tracking input, head-position cleanup, adding interpolated positions to raw data, and regression; confirm the API design and OPM-specific requirements before implementation. Done means the agreed movement-correction workflow is implemented and tested.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.