Repository navigation
MRG [+1]: Add scale by distance, orient to surface for mne coreg - #4966
Conversation
|
And adding coloration based on points inside (yikes): This is consistent with After hitting "Fit using headshape" we get a bit better: I'm guessing that the fitting was done with ICP with no constraint on inside/outside. I bet we can get a better head<->MRI trans once we add such a constraint. Although looking at it, we will definitely need to add a limited version (e.g., permit up to N mm inside the head, might need a few mm for some datasets to be tolerant of MRI imperfections and so forth). |
Codecov Report
@@ Coverage Diff @@
## master #4966 +/- ##
==========================================
+ Coverage 87.84% 87.89% +0.05%
==========================================
Files 353 353
Lines 63068 63435 +367
Branches 10795 10853 +58
==========================================
+ Hits 55401 55758 +357
- Misses 4916 4919 +3
- Partials 2751 2758 +7 |
|
@christianbrodbeck @agramfort ready for review/merge from my end. You can test with: |
|
the trans file seems to be ignored for me. Even if I load it manually the plot does not seem to update. Do I miss something? |
|
If I run the code snippet I pasted above I see this: If I run it without the I see this: What do you see? Does everything work for you on |
|
This is probably caused by the subject not having MRI fiducials defined. In principle this should only disable fitting to fiducials and similar operations. Let's fix it separately because it's unrelated to these changes. In the meantime, you can fix it by actually defining the LPA/Nasion/RPA (by clicking edit, then LPA, click on image, click Nasion, click image, click RPA, click image, click lock then maybe save). |
|
@agramfort I can replicate but let's fix this problem separately. I have added this to #3934. In the meantime you can use the procedure I outlined above or just extract this Then the commands I pasted above should work. |
|
I have an sample-fiducials.fif in my bem folder and still running:
mne coreg --subjects-dir=~/mne_data/MNE-sample-data/subjects/ \
--subject sample --fif
~/mne_data/MNE-sample-data/MEG/sample/sample_audvis_raw.fif \
--trans
~/mne_data/MNE-sample-data/MEG/sample/sample_audvis_raw-trans.fif \
--head-opacity=0.5 --orient-to-surface --scale-by-distance
--mark-inside
does not work out of the box.
let's do a hangout tomorrow with share screen so you explain what I do
wrong.
|
|
I just wiped my Also I realized that this requirement of having MRI fiducials is brought on by the code relying on the transforms being nasion-centric. This can thus be fixed in #4971, where I make the transforms origins the standard Neuromag head coord origin and stardand Freesurfer surface RAS origin (rather than their respective nasion locations). |
| label="MRI"), | ||
| Item('hsp_obj', style='custom', | ||
| label="Head shape"), | ||
| label="Extra"), |
There was a problem hiding this comment.
I don't find "Extra" intuitive – we've been calling them head shape points because they come from the head shape recording, is that misleading in some way?
There was a problem hiding this comment.
Some places we call these "head shape", in others we call them "extra" because they are extra points during digitization. At some point we should standardize. I was moving toward standardizing around the Elekta standard but maybe we should stick with "head shape".
There was a problem hiding this comment.
I can def. see how 'extra' is not intuitive and in this context head shape is clearly more so. There is the common case however of EEG electrodes being the only 'head shape' information we have; here whatever points may be acquired (on an Elekta system at least) are likely to be on the face, and consequently more 'extra'-like. +1 for keeping 'head shape' from me though, it's the most natural in this context.
| self._initial_project_eeg = project_eeg | ||
| self._initial_orient_to_surface = orient_to_surface | ||
| self._initial_scale_by_distance = scale_by_distance | ||
| self._initial_mark_inside = mark_inside |
There was a problem hiding this comment.
Could we make this self._initial_kwargs?
| project_to_surface = Bool(False, label='Project') | ||
| orient_to_surface = Bool(False, label='Orient') | ||
| scale_by_distance = Bool(False, label='Dist.') | ||
| mark_inside = Bool(False, label='Mark') |
There was a problem hiding this comment.
I think you could add a desc parameter here to add fly-over help in the GUI?
|
On the PR I also get a lot of these which I don't get on master: |
|
That is probably a VTK6 bug, it shouldn't happen with newer ones |
I get it on vtk 8.1.0 too :(
|
|
I don't get it on OSX (8.1) or Linux (7.1). What version of Mayavi are you using? What is the command-line to reproduce? (I think I know a workaround, but it would be nice if I could reproduce locally instead of pinging you again to test.) |
|
Don't hesitate to ping, a tiny contribution to get this great tool polished! mayavi: Version: 4.5.1.dev0 (git master as on March 1st)
spews the ERROR (specifically: 6 times) into the terminal (tested earlier by starting the gui in an ipython shell). However, just adding the info source fif file make the errors go away:
|
That should be a benefit of an all conda env :) can you reproduce with this?
I just used |
|
Thanks for the tips on how to test. This has been fixed along with other comments in the latest commit. @christianbrodbeck @cjayb feel free to try again.
In |
|
I have a small layout suggestion in larsoner#28, otherwise I think it looks great and we'll do more thorough testing for #4971 |
|
Great thanks @christianbrodbeck I've merged that nice tweak. @cjayb will you have time to look again in the next couple of days? @agramfort can't test so I need to get one more +1 from someone else to merge :) Hopefully in #4971 we can also fix @agramfort's problem. |
|
I can confirm that the weird table range error is now gone. But it seems the Omit-button really is my nemesis (killed my PR a few years back):
The error below basically what snagged me back then: after the first omit, the list is no longer consistent with info. I recently thought that the way vertices as included into a source space, using an indexing list, might be a way to fix this, WDYT? This could also go into #4971 , maybe makes more sense with the new weights-implementation, your call, so a provisional +1 from me on this one! Coregistration: Excluding 5 head shape points with distance >= 0.010 m.
Coregistration: Excluding 4 head shape points with distance >= 0.005 m.
Exception occurred in traits notification handler for object: <mne.gui._coreg_gui.CoregFrame object at 0x8228b9048>, trait: omit_points, old value: <undefined>, new value: 0
Traceback (most recent call last):
File "/Users/cjb/miniconda_envs/mne3/lib/python3.6/site-packages/traits/trait_notifiers.py", line 359, in __call__
self.handler( *args )
File "/Users/cjb/src/git/mne-python/mne/gui/_coreg_gui.py", line 1563, in _omit_points_fired
self.model.omit_hsp_points(distance)
File "/Users/cjb/src/git/mne-python/mne/gui/_coreg_gui.py", line 439, in omit_hsp_points
new_filter[old_filter] = new_sub_filter
IndexError: boolean index did not match indexed array along dimension 0; dimension is 73 but corresponding boolean dimension is 78 |
I can confirm that this also happens on |
…-tools#4966) * WIP: Add distance scaling and orientation * FIX: Proper parameterization * ENH: Add HPI points and color of inside points * FIX: Add tests * FIX: Fix test * FIX: Many fixes * view options layout








This PR:
Still todo:
Using:
On current
master:On this PR with options
--scale-by-distance --orient-to-surface: