9
9
from .unit_templates import UnitTemplatesWidget
10
10
from ..core import Templates
11
11
12
+
12
13
class DriftingTemplatesWidget (BaseWidget ):
13
14
"""
14
15
Plot a drifting templates object to explore motion
15
16
16
17
Parameters
17
18
----------
18
- drifting_templates :
19
+ drifting_templates :
19
20
A drifting templates object
20
21
scale : float, default: 1
21
22
Scale factor for the waveforms/templates (matplotlib backend)
@@ -45,7 +46,7 @@ def plot_ipywidgets(self, data_plot, **backend_kwargs):
45
46
check_ipywidget_backend ()
46
47
47
48
# self.next_data_plot = data_plot.copy()
48
- self .drifting_templates = data_plot [' drifting_templates' ]
49
+ self .drifting_templates = data_plot [" drifting_templates" ]
49
50
50
51
cm = 1 / 2.54
51
52
@@ -68,9 +69,9 @@ def plot_ipywidgets(self, data_plot, **backend_kwargs):
68
69
69
70
self .slider = widgets .IntSlider (
70
71
orientation = "horizontal" ,
71
- value = arr .shape [0 ]// 2 ,
72
+ value = arr .shape [0 ] // 2 ,
72
73
min = 0 ,
73
- max = arr .shape [0 ]- 1 ,
74
+ max = arr .shape [0 ] - 1 ,
74
75
readout = False ,
75
76
continuous_update = True ,
76
77
layout = widgets .Layout (width = f"100%" ),
@@ -91,13 +92,13 @@ def plot_ipywidgets(self, data_plot, **backend_kwargs):
91
92
if backend_kwargs ["display" ]:
92
93
display (self .widget )
93
94
94
- def _change_unit (self , change = None ):
95
+ def _change_unit (self , change = None ):
95
96
self ._update_ipywidget (keep_lims = False )
96
97
97
- def _change_displacement (self , change = None ):
98
+ def _change_displacement (self , change = None ):
98
99
self ._update_ipywidget (keep_lims = True )
99
100
100
- def _update_ipywidget (self ,keep_lims = False ):
101
+ def _update_ipywidget (self , keep_lims = False ):
101
102
if keep_lims :
102
103
xlim = self .ax .get_xlim ()
103
104
ylim = self .ax .get_ylim ()
@@ -119,10 +120,9 @@ def _update_ipywidget(self,keep_lims=False):
119
120
probe = self .drifting_templates .probe ,
120
121
)
121
122
122
- UnitTemplatesWidget (templates , unit_ids = unit_ids , scale = 5 ,
123
- plot_legend = False ,
124
- backend = "matplotlib" , ax = self .ax , same_axis = True )
125
-
123
+ UnitTemplatesWidget (
124
+ templates , unit_ids = unit_ids , scale = 5 , plot_legend = False , backend = "matplotlib" , ax = self .ax , same_axis = True
125
+ )
126
126
127
127
displacement = self .drifting_templates .displacements [displacement_index ]
128
128
self .ax .set_title (f"{ displacement_index } :{ displacement } - untis:{ unit_ids } " )
@@ -134,4 +134,3 @@ def _update_ipywidget(self,keep_lims=False):
134
134
fig = self .ax .get_figure ()
135
135
fig .canvas .draw ()
136
136
fig .canvas .flush_events ()
137
-
0 commit comments