Skip to content

MRG: Minor enhancements to coreg - #3935

Merged
larsoner merged 13 commits into
mne-tools:masterfrom
larsoner:tweak-coreg
Jan 28, 2017
Merged

larsoner merged 13 commits into
mne-tools:masterfrom
larsoner:tweak-coreg

Conversation

@larsoner

@larsoner larsoner commented Jan 26, 2017 •

Copy link
Copy Markdown
Member

This PR:

  1. Adds verbose option to the Coreg GUI.
  2. Sets surface normals for the head surface for better rendering.
  3. Turns on backface culling, which fixes a problem where rotating the head 180 degrees with alpha <1 previously made the head look very strange.
  4. Renames scaling params to None/Uniform/3-axis since it's a bit more descriptive.
  5. Reorders loading of parameters in CoregGUI.__init__ to avoid a bug where mne coreg -s whomever -f inst.fif wouldn't use whomever but rather the name guessed by inst.fif. Although you could pass --no-guess-mri to work around this bug, this shouldn't be necessary (if MRI is specified, it should be used)
  6. Reformats some of the Property calls to make it easier to visually track dependencies (should help refactoring)
  7. (edit) Command-line options for low-res head and head opacity.
  8. (edit) Removes freesurfer requirement for one of the tests.

Ready for review/merge @christianbrodbeck

@larsoner

Copy link
Copy Markdown
Member Author

It also now explicitly sets the focal point to the MRI origin

@larsoner larsoner modified the milestones: 0.14, 0.15 Jan 26, 2017
@codecov-io

codecov-io commented Jan 26, 2017 •

Copy link
Copy Markdown

Current coverage is 85.89% (diff: 87.01%)

Merging #3935 into master will increase coverage by 0.22%

@@             master      #3935   diff @@
==========================================
  Files           349        349          
  Lines         62113      62147    +34   
  Methods           0          0          
  Messages          0          0          
  Branches       9511       9513     +2   
==========================================
+ Hits          53211      53383   +172   
+ Misses         6233       6094   -139   
- Partials       2669       2670     +1   

Sunburst

Powered by Codecov. Last update 83b9ced...d8e9821

@larsoner

Copy link
Copy Markdown
Member Author

Also now added command-line options for head opacity and low/high-resolution head

@larsoner larsoner mentioned this pull request Jan 27, 2017
26 of 29 tasks
in particular, set —low-res-head option before loading the first head
@christianbrodbeck

Copy link
Copy Markdown
Member

I'm working on this, just a quick thought: instead of exposing a lot of options (like head opacity) in the command line, could the desired outcome also be achieved by remembering between sessions what the given setting was? I.e save on quit the head transparency and reload it on initialization?

@larsoner

Copy link
Copy Markdown
Member Author

Yes that could also work. But I'd prefer both, i.e. saving the option and allowing specification (as long as it's not too tricky to do so). Actually #3937 already moves us in that direction with config keys for width/height, so don't bother trying to implement that until this PR and #3937 are in

@christianbrodbeck

Copy link
Copy Markdown
Member

@Eric89GXL Sorry, I wanted to make a PR into your PR and accidentally pushed to your branch, I added reasoning/comments to each commit message. Other than those suggestions +1 for merge. Let me know if you prefer me to roll back and make a proper PR to discuss the individual changes.

@larsoner

Copy link
Copy Markdown
Member Author

Nah they look good to me. You +1 for merge, then? If so I'll merge once the CIs are happy and rebase #3937

@christianbrodbeck

Copy link
Copy Markdown
Member

Yes, merge when CIs are good.

@larsoner

Copy link
Copy Markdown
Member Author

Your changes broke the tests for me (and will break Travis and AppVeyor) because the "No Subjects Found" blocking dialog pops up in mne/gui/tests/test_coreg_gui.py:test_coreg_model. This happened before when I set the "use high res head" too early in the pipeline, and caused me to move a line. Can you double-check that you see the same thing locally and fix it? I had to step through my commits one-by-one to find it, because it's tricky...

@larsoner

Copy link
Copy Markdown
Member Author

Yeah it looks like you moved that line back up in this commit, which broke it:

82ab05f#diff-d574346a8560f3a1626d65763b124e41R1251

@christianbrodbeck

Copy link
Copy Markdown
Member

IIRC The reason for moving the line up was that without it, I would get a warning that there was no high res head shape for fsaverage even with --low-res-head.

The problematic dialog seems to pop up in test_coreg_gui (the line frame = CoregFrame()). I can patch the test by changing it to frame = CoregFrame(subjects_dir=subjects_dir), that should not lose too much coverage. But we could use an environment variable to disable blocking dialogs more generally.

However I noticed something else, why do we test CoregFrame at two places (end of test_coreg_model as well as test_coreg_gui? If you're ok with it I will combine the two into test_coreg_frame. Also, is it due to outdated limitations that only one of them sets os.environ['_MNE_GUI_TESTING_MODE']?

@christianbrodbeck

Copy link
Copy Markdown
Member

P. S. assert_raises(ValueError, CoregFrame, raw_path, 'Elvis', tempdir) also opens the dialog but seems mostly redundant with the subsequent line

@larsoner

Copy link
Copy Markdown
Member Author

I can patch the test by changing it to frame = CoregFrame(subjects_dir=subjects_dir), that should not lose too much coverage. But we could use an environment variable to disable blocking dialogs more generally.

Is the dialog popup supposed to be there, or no? If it's supposed to be there then we can add a skip in the code when in testing mode. If it's not supposed to be there then we should fix the code. But it sounds like you've already made it do the right thing, so a skip of blocking dialog would make sense.

As for the other testing questions, I haven't worked with them much so feel free to do what makes them work well.

@christianbrodbeck

Copy link
Copy Markdown
Member

Actually, hold on, this will not work in all cases, sorry

@christianbrodbeck

Copy link
Copy Markdown
Member

This should work. The warning dialog only pops up if subjects_dir is set to something.

@@ -146,22 +153,42 @@ def test_coreg_model():
finally:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Isn't this test above redundant? x._init_plot() should also be called below in frame.edit_traits()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@larsoner

larsoner commented Jan 28, 2017 via email

Copy link
Copy Markdown
Member Author

@christianbrodbeck

Copy link
Copy Markdown
Member

Ok I'll look into removing that test in a different PR so that we can keep going with this. The last was just a flake error. Should be good to go when CIs are done.

@larsoner
larsoner merged commit 4f948fa into mne-tools:master Jan 28, 2017
@larsoner
larsoner deleted the tweak-coreg branch January 28, 2017 02:51
@larsoner

Copy link
Copy Markdown
Member Author

Thanks for helping this along @christianbrodbeck

@agramfort

Copy link
Copy Markdown
Member

when running

"mne coreg -s sample -f ~/mne_data/MNE-sample-data/MEG/sample/sample_audvis_raw.fif --verbose --head-opacity=0.5 --low-res-head"

I get

File "/Users/alex/anaconda/envs/py35/lib/python3.5/site-packages/traitsui/qt4/enum_editor.py", line 433, in rebuild_editor
name = names[index]
TypeError: list indices must be integers or slices, not float

any idea?

@christianbrodbeck

Copy link
Copy Markdown
Member

@agramfort could you post a complete traceback? I can't reproduce with an equivalent command, what is your SUBJECTS_DIR?

@larsoner

Copy link
Copy Markdown
Member Author

I also can't reproduce (at least when I set SUBJECTS_DIR=~/mne_data/MNE-sample-data/subjects) on Linux x86_64

@agramfort

Copy link
Copy Markdown
Member
(py35) alex@:mne-python(master)$ export SUBJECTS_DIR=~/mne_data/MNE-sample-data/subjects/
(py35) alex@:mne-python(master)$ mne coreg -s sample -f ~/mne_data/MNE-sample-data/MEG/sample/sample_audvis_raw.fif --verbose --head-opacity=0.5 --low-res-head
Traceback (most recent call last):
  File "/Users/alex/work/src/mne-python/mne/commands/mne_coreg.py", line 61, in <module>
    run()
  File "/Users/alex/work/src/mne-python/mne/commands/mne_coreg.py", line 55, in run
    verbose=options.verbose)
  File "<string>", line 2, in coregistration
  File "/Users/alex/work/src/mne-python/mne/utils.py", line 708, in verbose
    return function(*args, **kwargs)
  File "/Users/alex/work/src/mne-python/mne/gui/__init__.py", line 84, in coregistration
    gui.configure_traits(view=view)
  File "/Users/alex/anaconda/envs/py35/lib/python3.5/site-packages/traits/has_traits.py", line 2156, in configure_traits
    kind, handler, id, scrollable, args )
  File "/Users/alex/anaconda/envs/py35/lib/python3.5/site-packages/traitsui/qt4/toolkit.py", line 213, in view_application
    id, scrollable, args )
  File "/Users/alex/anaconda/envs/py35/lib/python3.5/site-packages/traitsui/qt4/view_application.py", line 83, in view_application
    scrollable, args ).ui.result
  File "/Users/alex/anaconda/envs/py35/lib/python3.5/site-packages/traitsui/qt4/view_application.py", line 134, in __init__
    args       = self.args )
  File "/Users/alex/anaconda/envs/py35/lib/python3.5/site-packages/traitsui/view.py", line 433, in ui
    ui.ui( parent, kind )
  File "/Users/alex/anaconda/envs/py35/lib/python3.5/site-packages/traitsui/ui.py", line 222, in ui
    self.rebuild( self, parent )
  File "/Users/alex/anaconda/envs/py35/lib/python3.5/site-packages/traitsui/qt4/toolkit.py", line 155, in ui_live
    ui_live.ui_live( ui, parent )
  File "/Users/alex/anaconda/envs/py35/lib/python3.5/site-packages/traitsui/qt4/ui_live.py", line 39, in ui_live
    _ui_dialog(ui, parent, BaseDialog.NONMODAL)
  File "/Users/alex/anaconda/envs/py35/lib/python3.5/site-packages/traitsui/qt4/ui_live.py", line 59, in _ui_dialog
    BaseDialog.display_ui(ui, parent, style)
  File "/Users/alex/anaconda/envs/py35/lib/python3.5/site-packages/traitsui/qt4/ui_base.py", line 482, in display_ui
    ui.owner.init(ui, parent, style)
  File "/Users/alex/anaconda/envs/py35/lib/python3.5/site-packages/traitsui/qt4/ui_live.py", line 177, in init
    self.add_contents(panel(ui), bbox)
  File "/Users/alex/anaconda/envs/py35/lib/python3.5/site-packages/traitsui/qt4/ui_panel.py", line 255, in panel
    panel = _GroupPanel(content[0], ui).control
  File "/Users/alex/anaconda/envs/py35/lib/python3.5/site-packages/traitsui/qt4/ui_panel.py", line 545, in __init__
    self._add_splitter_items(content, splitter)
  File "/Users/alex/anaconda/envs/py35/lib/python3.5/site-packages/traitsui/qt4/ui_panel.py", line 623, in _add_splitter_items
    panel = _GroupPanel(item, self.ui, suppress_label=True).control
  File "/Users/alex/anaconda/envs/py35/lib/python3.5/site-packages/traitsui/qt4/ui_panel.py", line 590, in __init__
    layout = self._add_groups(content, inner)
  File "/Users/alex/anaconda/envs/py35/lib/python3.5/site-packages/traitsui/qt4/ui_panel.py", line 669, in _add_groups
    panel = _GroupPanel(subgroup, self.ui).control
  File "/Users/alex/anaconda/envs/py35/lib/python3.5/site-packages/traitsui/qt4/ui_panel.py", line 590, in __init__
    layout = self._add_groups(content, inner)
  File "/Users/alex/anaconda/envs/py35/lib/python3.5/site-packages/traitsui/qt4/ui_panel.py", line 669, in _add_groups
    panel = _GroupPanel(subgroup, self.ui).control
  File "/Users/alex/anaconda/envs/py35/lib/python3.5/site-packages/traitsui/qt4/ui_panel.py", line 592, in __init__
    layout = self._add_items(content, inner)
  File "/Users/alex/anaconda/envs/py35/lib/python3.5/site-packages/traitsui/qt4/ui_panel.py", line 860, in _add_items
    editor.prepare(inner)
  File "/Users/alex/anaconda/envs/py35/lib/python3.5/site-packages/traitsui/editor.py", line 156, in prepare
    self.init( parent )
  File "/Users/alex/anaconda/envs/py35/lib/python3.5/site-packages/traitsui/qt4/enum_editor.py", line 369, in init
    self.rebuild_editor()
  File "/Users/alex/anaconda/envs/py35/lib/python3.5/site-packages/traitsui/qt4/enum_editor.py", line 433, in rebuild_editor
    name = names[index]
TypeError: list indices must be integers or slices, not float

@larsoner

Copy link
Copy Markdown
Member Author

Do you have this problem before these commits, too? I suspect you have some conda package problem and it's not due to this PR

@agramfort

agramfort commented Jan 29, 2017 via email

Copy link
Copy Markdown
Member

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.

4 participants