Skip to content
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

MRG+1: Enable interactivity inside notebook for pyvista backend #6437

Merged
merged 4 commits into from
Jun 8, 2019

Conversation

GuillaumeFavelier
Copy link
Contributor

What does this implement/fix?

Add basic interactivity inside a jupyter notebook for the PyVista backend. Please note that panel is required to achieve this.

Additional information

We obtain the following:

output

And this is the code used in the notebook:

from mne.viz import set_3d_backend
set_3d_backend("pyvista")

import mne
from mne.datasets import sample
data_path = sample.data_path()
raw_fname = data_path + '/MEG/sample/sample_audvis_raw.fif'
subjects_dir = data_path + '/subjects'
subject = 'sample'
trans = data_path + '/MEG/sample/sample_audvis_raw-trans.fif'
info = mne.io.read_info(raw_fname)
mne.viz.plot_alignment(info, trans, subject=subject, dig=True,
                       meg=['helmet', 'sensors'], subjects_dir=subjects_dir,
                       surfaces=['head-dense'])

@lgtm-com
Copy link

lgtm-com bot commented Jun 7, 2019

This pull request introduces 1 alert when merging 57fd24a into 066f6b9 - view on LGTM.com

new alerts:

  • 1 for Unused local variable

@codecov
Copy link

codecov bot commented Jun 7, 2019

Codecov Report

Merging #6437 into master will decrease coverage by <.01%.
The diff coverage is 55.55%.

@@            Coverage Diff             @@
##           master    #6437      +/-   ##
==========================================
- Coverage   89.27%   89.26%   -0.01%     
==========================================
  Files         411      411              
  Lines       74518    74534      +16     
  Branches    12317    12319       +2     
==========================================
+ Hits        66526    66536      +10     
- Misses       5135     5139       +4     
- Partials     2857     2859       +2

@GuillaumeFavelier
Copy link
Contributor Author

What do you think @larsoner , @agramfort ?

@GuillaumeFavelier GuillaumeFavelier changed the title Enable interactivity inside notebook for pyvista backend MRG: Enable interactivity inside notebook for pyvista backend Jun 7, 2019
py = __IPYTHON__ # noqa
return True
except NameError:
return False
Copy link
Member

Choose a reason for hiding this comment

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

Maybe this can be done more simply as return '__IPYTHON__' in globals()? Not sure if it's better or worse. But at the very least, I don't see why you would assign to py rather than just doing __IPYTHON__ directly (it seems to be what the ipython docs do in my minimal searches)

Copy link
Contributor Author

@GuillaumeFavelier GuillaumeFavelier Jun 8, 2019

Choose a reason for hiding this comment

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

Surprisingly, both '__IPYTHON__' in globals() and globals().get('__IPYTHON__', False) returns False inside a jupyter notebook in my testing.
I'll modify to use __IPYTHON__ directly, thank you.

@larsoner
Copy link
Member

larsoner commented Jun 8, 2019

Otherwise LGTM (but I did not test it)

@agramfort
Copy link
Member

your example above works great for me in the notebook with interaction.

+1 for MRG

@agramfort agramfort changed the title MRG: Enable interactivity inside notebook for pyvista backend MRG+1: Enable interactivity inside notebook for pyvista backend Jun 8, 2019
@larsoner larsoner merged commit a2c7590 into mne-tools:master Jun 8, 2019
@larsoner
Copy link
Member

larsoner commented Jun 8, 2019

Thanks @GuillaumeFavelier !

@GuillaumeFavelier GuillaumeFavelier deleted the pyvista_notebook branch July 2, 2019 13:38
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.

3 participants