-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
MRG, ENH/FIX: Make cHPI calculation code public #7290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## master #7290 +/- ##
==========================================
+ Coverage 89.71% 89.99% +0.28%
==========================================
Files 447 449 +2
Lines 80571 81502 +931
Branches 12873 13451 +578
==========================================
+ Hits 72281 73348 +1067
+ Misses 5441 5312 -129
+ Partials 2849 2842 -7 |
|
Hit a UTF8 encoding problem on Windows with the modernized ProgressBar that #7155 would allow us to avoid having to fix ourselves... |
|
New tutorial showing the API: https://17855-1301584-gh.circle-artifacts.com/0/dev/auto_tutorials/preprocessing/plot_59_head_positions.html |
|
That offset appears to be 1 mm. I find that acceptable. |
|
fair enough |
|
Api changes look good. I'll hopefully have time today to look closer and to
test on some Artemis data.
…On Fri, Feb 7, 2020, 7:13 AM Marijn van Vliet ***@***.***> wrote:
fair enough
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#7290?email_source=notifications&email_token=ABKTXHPBFAFTIFNTNWDHLJTRBVF6PA5CNFSM4KQOFXU2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELCXE2Q#issuecomment-583365226>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABKTXHLYDYO6IBCMJDGFX3DRBVF6PANCNFSM4KQOFXUQ>
.
|
agramfort
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for MRG assuming the CI errors are unrelated
|
Great, thanks for looking and testing @wmvanvliet and @bloyl |
|
On artemis data I don't have ground truth to compare with so quantitative testing is harder. Qualitatively, i've looked and computing dev_head transforms a few of our datasets and I'd say that when I have good data the fits are qualitatively similar. One issue I did have is when I have bad data the new code returns a significantly higher GOF which makes it hard to catch the bad data and the suspect For instance in the following figure shows the topo for the 4 coils. the 1st and 4th have good topos and localize, unfortunately the 2nd and 3rd don't give good localizations but still have I don't know if this is a problem or an improvement of the GOF code but it is a difference. @larsoner if your interested I can probably share a dataset and code with you. Also I think i can acquire a CTF dataset that would enable a comparison between CTF fitting code and the MNE code. I hope to get on the scanner early next week to acquire it. |
|
My guess is that those coils are actually being localized ( If they're not, you might consider quantifying the coil SNR (can use PSD at the EDIT: apologies for typos, on mobile |
|
But yes feel free to share code and I can do some coil quality quantification. Along the lines of annotate_movement, I've been using pairwise coil distance code to estimate the number of usable coils and could make a PR to add it at some point. We also quantify coil SNR as a function of time and I could add that, too. |
Back to a keyboard where I can actually type. In other words:
The pairwise distances might give us some insight, so if you can share that potentially coil-2-/coil-3-problematic dataset that would help. We should see that in I'm happy to check these things if you share the data. |
|
From talking to @bloyl it seems likely that having access to the actual amplitude estimates could also be useful for QA purposes. So the steps are now split just a little bit more:
Making it so that @bloyl in changing this API I found ways of unifying things again, can you look in particular at I also added some basic pairwise-distance code back in, as I think eventually @bloyl might want it for Artemis123, we'll probably want it for QA code, and it's another nice sanity check. |
|
From an regular user point of view: I'm fine with the extra API steps as long as the |
I'd rather not do this for the following reasons:
TL;DR: I'd argue in the opposite direction, that |
bloyl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just made a first pass through, here are my initial comments. I'll hopefully have more time tomorrow to dig into it.
| hpi_dig_dev_rrs = apply_trans( | ||
| invert_transform(info['dev_head_t'])['trans'], | ||
| _get_hpi_initial_fit(info, adjust=adjust_dig)) | ||
| last = dict(sin_fit=None, coil_fit_time=sin_fits['times'][0] - 1, | ||
| coil_dev_rrs=hpi_dig_dev_rrs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How important is having this initial guess as a requirement?
In the case of the artemis data it needs to be faked before we can do a head localization. You do this now in the reader. but in my actual code I don't use the reader's head localization so that I have a more flexability over which time windows i choose to localize.
This is minor since I doubt we'll do head localization in too many other systems. but figured I'd mention it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the guesses code in there now using a grid, it probably does not matter much unless you are quite far out of the helmet (and even then might not matter)
agramfort
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bloyl i will let you merge if happy
| assert_allclose(chpi_locs['gofs'][0], coil_gof, atol=0.3) # XXX not good | ||
|
|
||
| # check moment | ||
| # XXX our forward and theirs differ by an extra mult by _MAG_FACTOR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bloyl coil moments added. Feel free to look and merge if you're happy
As a side note, I don't know why our calculation and MaxFilter's differ by _MAG_FACTOR (1e-7). I'm guessing that they accidentally double-multiply by it? cc @agramfort in case you know.
|
Thanks @larsoner |
* ENH: Expose calculate_head_pos_chpi * FIX: Many fixes to move toward MF equiv * FIX: Dist limit * ENH: Speed up by skipping more * MAINT: Unify computations * FIX: Revert analytical solution, use COBYLA * MAINT: Simplifications * ENH: Add interference suppression * FIX: Two-pass simplification * ENH: Better ProgressBar * FIX: Refactor after rebase * API: Refactor into two stages * API: Cleaner return and API * ENH: Add guesses * ENH: Rename * ENH: Tutorials * DOC: Tutorial * FIX: Test * DOC: Link * FIX: Unicode * FIX: Try another * FIX: Dep * API: Refactor more clean naming * DOC: Returns * DOC: Clearer [ci skip] * MAINT: Revert progressbar changes * FIX: But fix ProgressBar docstrings * WIP: Refactor but its much slower * FIX: Separate out amplitude step * DOC: Correct links * DOC: One more * FIX: Restore amplitude * ENH: Add coil moments
* ENH: Expose calculate_head_pos_chpi * FIX: Many fixes to move toward MF equiv * FIX: Dist limit * ENH: Speed up by skipping more * MAINT: Unify computations * FIX: Revert analytical solution, use COBYLA * MAINT: Simplifications * ENH: Add interference suppression * FIX: Two-pass simplification * ENH: Better ProgressBar * FIX: Refactor after rebase * API: Refactor into two stages * API: Cleaner return and API * ENH: Add guesses * ENH: Rename * ENH: Tutorials * DOC: Tutorial * FIX: Test * DOC: Link * FIX: Unicode * FIX: Try another * FIX: Dep * API: Refactor more clean naming * DOC: Returns * DOC: Clearer [ci skip] * MAINT: Revert progressbar changes * FIX: But fix ProgressBar docstrings * WIP: Refactor but its much slower * FIX: Separate out amplitude step * DOC: Correct links * DOC: One more * FIX: Restore amplitude * ENH: Add coil moments

I spent a lot of time revamping our cHPI localization code to match what MaxFilter does. In particular I needed to:
After this, the 398 recordings I tested (each between 5 and 20 minutes) all match MaxFilter very well. In places that they don't, our code produces a less "noisy" result, which is an improvement as I have seen MaxFilter's estimates oscillate between two position estimates at times.
@bloyl there are a ton of changes and fixes here, it would be good if you could re-check your use cases to see if they still work properly. I did have to change some of the "spot check" values in the tests. Most were subtle, but one changed from
[0.054, 0.009, 0.037]with GOF0.075to[-0.065, 0.075, 0.000]with GOF 0.9323 -- so way better GOF but quite far from the old value. I'm inclined to assume that the new value is correct and the old one was wrong.Also contains changes to ProgressBar that motivated #7155. In this PR things are nicer but not as nice (or maintainable) as in #7155. So my preference is to roll back the changes here and merge #7155, but if we're going to kill #7155 these changes are useful.