Repository navigation
MRG: Refactor coreg transformations and fits - #4971
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4971 +/- ##
==========================================
+ Coverage 88% 88.01% +0.01%
==========================================
Files 356 356
Lines 64462 65128 +666
Branches 11018 11146 +128
==========================================
+ Hits 56729 57324 +595
- Misses 4950 4975 +25
- Partials 2783 2829 +46 |
13a192d to
9a6437e
Compare
|
Looks really good, I much enjoy the didactic twist of moving the MRI into the head point cloud, completely agree on moving away from nasion-centered transforms. Thank you for finally figuring out the EEG electrode situation (my failed attempt a few years back is still nagging :) I guess the "Save trans"-button is WIP? |
|
I errantly added that one, actually. The "Save as..." button saves only the trans if you did no scaling, and saves the surrogate + trans if you did scaling. I didn't realize it did the former until I had added the button, then forgot to remove it... |
|
Ah! Suggest going with "Save as..." then, instead of the current "Save Subject As..."; the latter implied to me that a scaled subject would be saved to BTW: Any idea how the HPI coil orientation is determined? I happen to get this one funky one on the rhs (looks like it's 90 deg rotated, pretty sure it wasn't during recording, I think I would have felt it!) |
|
It is determined by the orientation of the nearest surface point, in this
case must be on the ear.
|
|
Okay @cjayb @christianbrodbeck I think this fixes everything we talked about from the previous PR and adds a bunch of functionality (see top comment). Feel free to give it a try. @agramfort this might even fix things on your system! A good starting command is: |
|
I refactored a bunch of display params on Linux and now OSX can be unhappy. I'll set back to WIP and let people know when it's fixed. In the meantime you can still test it. |
|
Some initial thoughts on GUI elements:
Indeed my immediate trouble is with displaying (qt5, pyqt5, vtk8, os x 10.13.3)
cjb@hathor $ mne coreg --subject sample --subjects-dir=~/data/templates/MNE-sample-data/subjects --fif ~/data/templates/MNE-sample-data/MEG/sample/sample_audvis_raw.fif --trans ~/data/templates/MNE-sample-data/MEG/sample/sample_audvis_raw-trans.fif
/Users/cjb/miniconda_envs/mne3/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
from ._conv import register_converters as _register_converters
Triangle neighbors and vertex normals...
Triangle neighbors and vertex normals...
Exception occurred in traits notification handler.
Please check the log file for details.
Exception occurred in traits notification handler for object: <mne.gui._viewer.HeadViewController object at 0x1c2921a570>, trait: interaction, old value: trackball, new value: terrain
Traceback (most recent call last):
File "/Users/cjb/miniconda_envs/mne3/lib/python3.6/site-packages/traits/trait_notifiers.py", line 538, in _dispatch_change_event
self.dispatch( handler, *args )
File "/Users/cjb/miniconda_envs/mne3/lib/python3.6/site-packages/traits/trait_notifiers.py", line 501, in dispatch
handler( *args )
File "/Users/cjb/src/git/mne-python/mne/gui/_viewer.py", line 114, in on_set_interaction
self.scene.interactor.interactor_style
AttributeError: 'NoneType' object has no attribute 'interactor_style' |
I agree, but it was necessary to save space (shaved over 100 pixels from the left and right columns). The other problem I had before was that LPA/Nasion/RPA lined up with the X/Y/Z, which makes it visually confusing (they seem vertically related but aren't). These two things made it seem worth the switch even for extra clicks.
Yes this is a HiDPI resolution problem and on the todo list above. I need to refactor the there panels on the left into a single panel so that it, too, can scroll like the right one.
I ended up getting rid of the scene-size-saving step because of some TraitsUI limitations, so this bug is already "fixed". (You'll need to manually set your mne config values to fix it, but users of the final PR won't have that problem.)
This is a weird one, I don't get this on OSX or Linux. But it should be fixable by delaying the interactor-setting step. |
Yes, that's more or less how it's done in |
I agree that the drop-down menu for this seems clumsy
Maybe some less frequently used items like "interaction" and "Display options" could go into a menu bar to save space? I think it should be possible with traitsui: http://docs.enthought.com/traitsui/traitsui_user_manual/handler.html#menus-and-menu-bars |
Sorry, which parameter is it exactly?
Agree, the risk of automating the ICP iteration-process is risky, fine to let it be user-controlled |
|
Maybe even better would be to replace the mayavi toolbar that sits on top of the scene? I don't know if it's possible to modify it so that the x/y/z buttons line up with our coordinate system? |
I thought about removing this but that toolbar is pretty useful actually. You can tweak viz and save very easily which is nice.
MNE_COREG_SCENE_WIDTH / HEIGHT
I can move the scale and interaction mode into "Display options", and move that button somewhere that it doesn't add space (maybe to the right of top/right/front/left). I need to refactor that panel anyway.
To me the bigger concern than space (though I listed this second) was the false impression that the L/N/R were related to X/Y/Z due to visual vertical alignment. I'll try to find some way to avoid this while putting buttons back. |
Yeah that's why I was wondering whether it could be modified so that x/y/z work properly, or just by adding additional buttons... |
I basically get random behaviour setting these in |
|
Yes there is a height limitation due to the concatenation of three panels on the left. I'm going to fix it by:
|
|
Okay, layout works on HiDPI OSX now by tightening up the layout and relying a bit more on tooltips and implicit labels rather than explicit labels. Here is This PR: And when in MRI fiducial editing mode And this PR: I think it's ready for another look. @cjayb @christianbrodbeck you might need to set |
Here's a shot of my whole screen. If I Grab the window, the parts not show on-screen are visible on the screenshot :-/ Any suggestions on which config to flush...? Edit: Also, the scrolling works in the right pane but not left. |
|
@cjayb argh okay. I'll need to actually do the scrolling refactoring I mentioned (I hoped to avoid it by saving space). It's probably worthwhile anyway. BTW command-shift-4 then "space" on OSX will allow you to capture a single window. |
What if you put the view panel back below the scene? You could make it less tall by moving the view options to the side (or into a menu bar)? |
|
Or change the coordinate system to be consistent with Mayavi's x/y/z? Then the view buttons would not even be needed because the the Mayavi toolbar x/y/z buttons could be used instead? |
(in case two dialogs are open)
* TEST GUIs: raise exceptions in change handlers * RF use decorator for lazy import * fix * TEST: raise exceptions in change handlers in all mayavi tests
* remove gui.combine_kit_markers() (it is redundant with gui.kit2fiff()) * TEST kit2fiff-gui: set marker file * FIX kit2fiff gui point visualization & view * test_kit2fiff: update assert statements * STY
|
Okay everything should be working and I think everyone is happy with this. I'll go ahead and merge if CIs come back happy! |
|
ok !
|
|
Nothing like a +2,086 −1,572 PR to send us into the weekend :) |
* ENH: Refactor fitting and origins * FIX: Many fixes * FIX: Fix style * FIX: Dont save size * FIX: Multiple fixes * FIX: Fix highlighting * ENH: Save window size and add status bar * ENH: Refactor * FIX: Fix tests * FIX: Many fixes * FIX: Revert silly change * FIX: Tweak button size * FIX: Text and sizes * FIX: Opacity * ENH: Refactor options * ENH: ICP iterations * FIX: Tweak sizes * FIX: Fix scaling and units * FIX: Aesthetics * FIX: Allow 1-element scale * FIX?: Fix logic * FIX: Fix checks * ENH: Allow matching to surface * FIX: Tweak nasion [ci skip] * ENH: Better status updates * FIX: Add tests * fix status bar queue info * use Enum for coord_frame * sync bidirectionally with view options dialog (in case two dialogs are open) * Prevent double view options dialog * [WIP] FIX kit2fiff GUI (mne-tools#30) * TEST GUIs: raise exceptions in change handlers * RF use decorator for lazy import * fix * TEST: raise exceptions in change handlers in all mayavi tests * FIX: Dont scale sphere surfaces * FIX: kit2fiff * FIX: Fix parenting * FIX: Flake * FIX: Fix size * FIX: Actually copy reg files * [WIP] fix kit2fiff (mne-tools#31) * remove gui.combine_kit_markers() (it is redundant with gui.kit2fiff()) * TEST kit2fiff-gui: set marker file * FIX kit2fiff gui point visualization & view * test_kit2fiff: update assert statements * STY * FIX: Migrate to pytest * FIX: Fix test






This PR builds on #4966 so that must be merged first.This PR:
only ever transform the MRI points.be done in the_coreg_guimodule instead of the_viewer.pymodule / visuals.fit_point_cloud-based (which usesnearestcalculations on every objective function evaluation) to iterative-closest-point (ICP; computes nearest neighbors and does the fit using those matched pairs). This should replicate what people are presumably more accustomed to frommne_analyzeand in the MEG literature. It is fairly quick, so pressing it multiple times to see/watch fit convergence isn't bad and also has some pedagogical value I think.nearest_calcclass-based scheme that is sufficiently fastAlso:
spheresurfacesSave transbutton that was errantly addedSCENE_SCALEpersistuse high-res mesh for ICPmne_analyzeandmne coregICPmmnotmfix double window popup?see if latest libs avoid warnings_DistanceQuery