Skip to content

Commit

Permalink
WIP: Merge time viewer code into Brain (mne-tools#8352)
Browse files Browse the repository at this point in the history
* Move time viewer code into Brain

* Fix docstring

* Fix docstring

* Fix docstring
  • Loading branch information
GuillaumeFavelier authored Oct 8, 2020
1 parent 09513aa commit af671e7
Show file tree
Hide file tree
Showing 10 changed files with 1,256 additions and 1,215 deletions.
2 changes: 1 addition & 1 deletion mne/icons/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Documentation
=============

The icons are used in ``mne/viz/_brain`` for the toolbar of ``_TimeViewer``.
The icons are used in ``mne/viz/_brain/_Brain.py`` for the toolbar.
It is necessary to compile those icons into a resource file for proper use by
the application.

Expand Down
14 changes: 6 additions & 8 deletions mne/viz/_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -1557,19 +1557,17 @@ def link_brains(brains, time=True, camera=False, colorbar=True,
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
from ._brain import Brain, _LinkViewer
if not isinstance(brains, 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:
if not isinstance(brain, Brain):
raise TypeError("Expected type is Brain but"
" {} was given.".format(type(brain)))
# enable time viewer if necessary
brain.setup_time_viewer()
subjects = [brain._subject_id for brain in brains]
if subjects.count(subjects[0]) != len(subjects):
raise RuntimeError("Cannot link brains from different subjects.")
Expand Down Expand Up @@ -1949,8 +1947,8 @@ def _plot_stc(stc, subject, surface, hemi, colormap, time_label,
from surfer import TimeViewer
TimeViewer(brain)
else: # PyVista
from ._brain import _TimeViewer as TimeViewer
TimeViewer(brain, show_traces=show_traces)
brain.setup_time_viewer(time_viewer=time_viewer,
show_traces=show_traces)

return brain

Expand Down
1 change: 0 additions & 1 deletion mne/viz/_brain/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

from ._brain import Brain
from ._scraper import _BrainScraper
from ._timeviewer import _TimeViewer
from ._linkviewer import _LinkViewer

__all__ = ['Brain']
Loading

0 comments on commit af671e7

Please sign in to comment.