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: Link brains with _LinkViewer and plot_linked_brains #7227

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4000837
Build first prototype
GuillaumeFavelier Jan 17, 2020
e69cea5
Fix docstring
GuillaumeFavelier Jan 17, 2020
e9f2005
Synchronize the slider handle
GuillaumeFavelier Jan 20, 2020
62e12a6
Add representation memory to IntSlider and ShowView
GuillaumeFavelier Jan 20, 2020
4ffb901
Introduce SmartSlider
GuillaumeFavelier Jan 20, 2020
e8ea40f
Update time callback
GuillaumeFavelier Jan 20, 2020
dc51a27
Update orientation callback
GuillaumeFavelier Jan 20, 2020
c817c17
Change default name of the time slider
GuillaumeFavelier Jan 20, 2020
e26c53a
Update smoothing call
GuillaumeFavelier Jan 20, 2020
0ca06ca
Update fmin/fmid/fmax callbacks
GuillaumeFavelier Jan 20, 2020
b7f2d51
Update fscale callback
GuillaumeFavelier Jan 20, 2020
ffab732
Improve performance for auto_scaling
GuillaumeFavelier Jan 20, 2020
12b2e81
Merge branch 'master' into time_viewer_plot_linked_brains
GuillaumeFavelier Jan 20, 2020
8b87a13
Use local _update_slider_callback
GuillaumeFavelier Jan 20, 2020
e27016c
Improve plot_linked_brains docstring
GuillaumeFavelier Jan 20, 2020
7ff6eb9
Add plot_linked_brains to reference
GuillaumeFavelier Jan 20, 2020
7028bce
Link play and playback speed
GuillaumeFavelier Jan 20, 2020
0a2399e
Update docstring
GuillaumeFavelier Jan 20, 2020
ec9cbc1
Add plot_linked_brains to tests
GuillaumeFavelier Jan 20, 2020
1bfd529
Add _LinkViewer to tests
GuillaumeFavelier Jan 20, 2020
227e7b7
Rename plot_linked_brains into link_brains
GuillaumeFavelier Jan 22, 2020
5d78f05
Remove local patch for normalized coordinate system
GuillaumeFavelier Jan 22, 2020
a5e068c
Fix double _TimeViewer wrapping
GuillaumeFavelier Jan 22, 2020
bb304fc
Fix issue with slider placement
GuillaumeFavelier Jan 23, 2020
76e2e83
Fix UI inconsistency
GuillaumeFavelier Jan 23, 2020
361d273
Change playback speed title to short version
GuillaumeFavelier Jan 23, 2020
ffbd9a7
Update latest and overview table
GuillaumeFavelier Jan 23, 2020
8a74730
Merge branch 'master' into time_viewer_plot_linked_brains
GuillaumeFavelier Jan 23, 2020
d44e9c9
Fix name spelling
GuillaumeFavelier Jan 23, 2020
612ac90
Merge branch 'master' into time_viewer_plot_linked_brains
GuillaumeFavelier Jan 24, 2020
6d664d5
Implement reviews
GuillaumeFavelier Jan 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changes/latest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ Changelog

- Add ``border`` argument to :func:`mne.viz.plot_topomap`. ``border`` controls the value of the edge points to which topomap values are extrapolated. ``border='mean'`` sets these points value to the average of their neighbours. By `Mikołaj Magnuski`_

- Add function :func:`mne.viz.link_brains` to link time properties of multiple brain objects interactively by `Guillaume Favelier`_

Bug
~~~
Expand Down
1 change: 1 addition & 0 deletions doc/python_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ Visualization
plot_sensors_connectivity
plot_snr_estimate
plot_source_estimates
link_brains
plot_volume_source_estimates
plot_vector_source_estimates
plot_sparse_source_estimates
Expand Down
30 changes: 30 additions & 0 deletions mne/viz/_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from itertools import cycle
import os.path as op
import warnings
import collections
from functools import partial

import numpy as np
Expand Down Expand Up @@ -1536,6 +1537,35 @@ def _plot_mpl_stc(stc, subject=None, surface='inflated', hemi='lh',
return fig


def link_brains(brains):
"""Plot multiple SourceEstimate objects with PyVista.

Parameters
----------
brains : list, tuple or np.ndarray
The collection of brains to plot.
"""
from .backends.renderer import get_3d_backend
if get_3d_backend() != 'pyvista':
raise NotImplementedError("Expected 3d backend is pyvista but"
" {} was given.".format(get_3d_backend()))
from ._brain import _Brain, _TimeViewer, _LinkViewer
Copy link
Member

Choose a reason for hiding this comment

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

do we need to do a check that this function requires pyvista backend?

if not isinstance(brains, collections.Iterable):
brains = [brains]
if len(brains) == 0:
raise ValueError("The collection of brains is empty.")
for brain in brains:
if isinstance(brain, _Brain):
# check if the _TimeViewer wrapping is not already applied
if not hasattr(brain, 'time_viewer') or brain.time_viewer is None:
brain = _TimeViewer(brain)
else:
raise TypeError("Expected type is Brain but"
" {} was given.".format(type(brain)))
# link brains properties
_LinkViewer(brains)


@verbose
def plot_source_estimates(stc, subject=None, surface='inflated', hemi='lh',
colormap='auto', time_label='auto',
Expand Down
3 changes: 2 additions & 1 deletion mne/viz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
plot_vector_source_estimates, plot_evoked_field,
plot_dipole_locations, snapshot_brain_montage,
plot_head_positions, plot_alignment, plot_brain_colorbar,
plot_volume_source_estimates, plot_sensors_connectivity)
plot_volume_source_estimates, plot_sensors_connectivity,
link_brains)
from .misc import (plot_cov, plot_csd, plot_bem, plot_events,
plot_source_spectrogram, _get_presser,
plot_dipole_amplitudes, plot_ideal_filter, plot_filter,
Expand Down
2 changes: 1 addition & 1 deletion mne/viz/_brain/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
# License: Simplified BSD

from ._brain import _Brain
from ._timeviewer import _TimeViewer
from ._timeviewer import _TimeViewer, _LinkViewer

__all__ = ['_Brain']
Loading