-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[ENH, MRG] Encapsulate warp elec image in function #9544
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
Everything in MNE should be regression tested -- it's an important part of the work and worth the effort! It's also a useful skill to learn in terms of how to take a complicated problem and distill it to something that proves things work properly, without taking too long to do so. One idea would be to fake This also lends itself nicely to testing other cases, for example if you color in a single voxel, you might not get this point back, and the function should warn -- and you can assert via |
Sounds good, I wrote that after a long day of working on too many PRs at once but also after thinking about it I don't think it's that cumbersome, it's 4 required arguments which is a lot but I think that's the best way for making it modular and making sure you can check step by step. I'm almost done with the test, will push soon. |
|
Ok, this should pass all the tests, but it does take 50 seconds locally to test. @larsoner if you have any ideas to make it faster that would be nice but I'm not sure I have any. Other than that, should be good to go. |
larsoner
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 a couple of high-level comments, I can look a bit deeper once you address those. Also 50sec will be too long, I can see if there are ways to speed it up later this week! If you want to try in the meantime, I would do something like add @profile to the top of the test function:
...
@pytest.mark.slowtest
@testing.requires_testing_data
@profile
def test_warp_montage_volume():
...
and do:
kernprof -lbv ~/.local/bin/pytest mne/tests/test_surface.py -k warp_montage
it should tell you which lines of the test are slow
|
Hmmm so raises but works with a tuple. I might fix that on this PR if that's okay |
|
Ok, now the test is down to 20 seconds :) |
|
Ok ready for review @larsoner, whenever you get a chance |
|
So I changed the tests so that the "Ground truth" (with Extra quick version (affine + SDR with low iterations) |
|
I'll try adding back translation and rigid and see how much of a time hit that is for the precision. |
|
Yes it's possible that the |
Great, I'll try that! |
|
Hmmm with |
|
I'll try messing with the parameters a bit more, it's possible that a few more translation iterations will fix things |
|
I would use |
|
(but maybe I underestimate how far off they are) |
|
Wait, I'm thinking in mm, they are off my ~1 cm 🤦 |
|
Oh good, I think |
|
Ok good to go but it was 28 seconds locally, I tried turning down the iterations and skipping steps but everything I did lost precision so I think this is about the best to be ~1 cm precise |
|
Ok this is good to go by me if it's okay with you |
to show Eric revert all Brain API changes, for another PR in progress in progress working version of montage warping function remove off-target
's comments
|
Will merge once CIs come back happy, thanks @alexrockhill! |
|
Pushed a commit to set (After doing that I realized that it doesn't matter much for this PR which coordinate frame things are plotted in, but it'll be useful when we combine with |
|
Ok, I think good to go! |
|
Indeed, thanks @alexrockhill ! Time for some fun rebasing elsewhere :) |
The plan is that the dominos fall perfectly! |
* upstream/main: [MRG, ENH] Find aseg labels near montage (mne-tools#9545) Add label to colorbar in GAT plot [skip actions] (mne-tools#9582) [ENH, MRG] Encapsulate warp elec image in function (mne-tools#9544) [DOC, MRG] Add "info" to `docdict` (mne-tools#9574) [MRG] Add `units` parameter to get_data for Evoked (mne-tools#9578) [MRG, ENH] Get annotation description from snirf stim name (mne-tools#9575) [MRG] ENH, FIX: Add tmin/tmax parameters to get_data methods, fix bug in find_bads_ecg (mne-tools#9556)
I thought the checks that the image warp worked properly and handling of the coordinate frames would be better handled by a function than leaving to copy paste. After writing it, the function seems rather cumbersome so it would be nice to get a review and maybe this isn't the best way to go about it. I tried splitting it into a piece for making an image and a piece for warping an image but that was cumbersome as well.
Also I didn't write a test because it is just too cumbersome but the example did work...