Skip to content
Closed
Changes from all commits
Commits
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
59 changes: 59 additions & 0 deletions mne/viz/_brain/_timeviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ def __init__(self, brain, show_traces=False):
self.color_cycle = None
self.picked_points = {'lh': list(), 'rh': list()}
self._mouse_no_mvt = -1
self.icons = dict()
self.actions = dict()
self.orientation = [
'lateral',
'medial',
Expand Down Expand Up @@ -359,6 +361,7 @@ def __init__(self, brain, show_traces=False):
self.plotter = brain._renderer.plotter
self.main_menu = self.plotter.main_menu
self.window = self.plotter.app_window
self.tool_bar = self.window.addToolBar("toolbar")
self.status_bar = self.window.statusBar()
self.interactor = self.plotter.interactor
self.interactor.keyPressEvent = self.keyPressEvent
Expand All @@ -374,12 +377,14 @@ def __init__(self, brain, show_traces=False):
self.show_traces = show_traces
self.separate_canvas = False

self.load_icons()
self.configure_time_label()
self.configure_sliders()
self.configure_scalar_bar()
self.configure_playback()
self.configure_point_picking()
self.configure_menu()
self.configure_tool_bar()

# show everything at the end
self.toggle_interface()
Expand All @@ -394,6 +399,12 @@ def keyPressEvent(self, event):
def toggle_interface(self):
self.visibility = not self.visibility

# update tool bar icon
if self.visibility:
self.actions["visibility"].setText(self.icons["visibility_on"])
else:
self.actions["visibility"].setText(self.icons["visibility_off"])

# manage sliders
for slider in self.plotter.slider_widgets:
slider_rep = slider.GetRepresentation()
Expand Down Expand Up @@ -432,6 +443,13 @@ def restore_user_scaling(self):

def toggle_playback(self):
self.playback = not self.playback

# update tool bar icon
if self.playback:
self.actions["play"].setText(self.icons["pause"])
else:
self.actions["play"].setText(self.icons["play"])

if self.playback:
time_data = self.brain._data['time']
max_time = np.max(time_data)
Expand Down Expand Up @@ -755,6 +773,47 @@ def configure_point_picking(self):
self.on_pick
)

def load_icons(self):
self.icons["help"] = "❓"
self.icons["play"] = "⏯️"
self.icons["pause"] = "⏸️"
self.icons["scale"] = "📏"
self.icons["clear"] = "🗑️"
self.icons["restore"] = "↩️"
self.icons["screenshot"] = "📷"
self.icons["visibility_on"] = "👀"
self.icons["visibility_off"] = "👀"

def configure_tool_bar(self):
self.actions["screenshot"] = self.tool_bar.addAction(
self.icons["screenshot"],
self.plotter._qt_screenshot
)
self.actions["visibility"] = self.tool_bar.addAction(
self.icons["visibility_on"],
self.toggle_interface
)
self.actions["play"] = self.tool_bar.addAction(
self.icons["play"],
self.toggle_playback
)
self.actions["scale"] = self.tool_bar.addAction(
self.icons["scale"],
self.apply_auto_scaling
)
self.actions["restore"] = self.tool_bar.addAction(
self.icons["restore"],
self.restore_user_scaling
)
self.actions["clear"] = self.tool_bar.addAction(
self.icons["clear"],
self.clear_points
)
self.actions["help"] = self.tool_bar.addAction(
self.icons["help"],
self.help
)

def configure_menu(self):
# remove default picking menu
to_remove = list()
Expand Down