Skip to content

Conversation

@larsoner
Copy link
Member

When implementing the cHPI changes, I noticed some places that our use of matched-point fitting could be improved. Specifically:

  1. mne coreg uses matched point fitting in ICP. This now routes the code to use the analytical solution when possible.
  2. This required implementing _quat_to_euler and _euler_to_quat from standard formulas.
  3. Implementing the mne coreg caused me to look back at the ICP ref, then the original ref for the analytical transform, and realize that 1) it can include weights, and 2) it can compute a uniform scale factor, too. So I implemented those, which expanded the use cases for mne coreg.
  4. mne.io.ctf computed some transforms using its own matched point code, and also its own RAS-to-head. These now use transforms from mne.transforms instead.

So there ended up being more + than - in this PR, but we removed more functional code than we added -- a lot of the +` comefrom new tests.

mu_p = mean(p, axis=0) # eq 23
mu_x = mean(x, axis=0)
Sigma_px = np.dot(p.T, x) / p.shape[0] - np.outer(mu_p, mu_x) # eq 24
# (weighted) centroids
Copy link
Member

Choose a reason for hiding this comment

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

Maybe you can use np.average and the accepts weights ?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is in jit-ed code, and Numba does not support it. So not worth the speed loss :)

@codecov
Copy link

codecov bot commented Feb 14, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@9f3b76f). Click here to learn what that means.
The diff coverage is 100%.

@@            Coverage Diff            @@
##             master    #7325   +/-   ##
=========================================
  Coverage          ?   89.71%           
=========================================
  Files             ?      450           
  Lines             ?    81353           
  Branches          ?    12932           
=========================================
  Hits              ?    72983           
  Misses            ?     5519           
  Partials          ?     2851

@larsoner
Copy link
Member Author

Still some linalg bugs to sort out, will set to WIP until I do

@larsoner larsoner changed the title MRG, MAINT: Refactor and unify matched-point fitting WIP, MAINT: Refactor and unify matched-point fitting Feb 14, 2020
@larsoner larsoner mentioned this pull request Feb 15, 2020
@larsoner larsoner changed the title WIP, MAINT: Refactor and unify matched-point fitting MRG, MAINT: Refactor and unify matched-point fitting Feb 16, 2020
@larsoner
Copy link
Member Author

Okay this one should be ready to go

@larsoner
Copy link
Member Author

Travis failure is just a timeout due to non-BLAS NumPy prerelease wheels

@agramfort agramfort merged commit ee47fc3 into mne-tools:master Feb 17, 2020
@agramfort
Copy link
Member

Thx @larsoner

@larsoner larsoner deleted the transform branch February 17, 2020 17:06
AdoNunes pushed a commit to AdoNunes/mne-python that referenced this pull request Apr 6, 2020
* MAINT: Refactor and unify matched-point fitting

* FIX: Casts

* FIX: Try again

* ENH: Speed up 3D test a tiny bit

* FIX: Verbose

* DOC: Fix comment [ci skip]

* MAINT: From transforms
AdoNunes pushed a commit to AdoNunes/mne-python that referenced this pull request Apr 6, 2020
* MAINT: Refactor and unify matched-point fitting

* FIX: Casts

* FIX: Try again

* ENH: Speed up 3D test a tiny bit

* FIX: Verbose

* DOC: Fix comment [ci skip]

* MAINT: From transforms
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