1
- import ipywidgets
1
+ import ipywidgets as widgets
2
2
from .. import ephys_report
3
3
import matplotlib .image as mpimg
4
4
import matplotlib .pyplot as plt
5
5
import pathlib
6
6
import typing as T
7
7
from IPython .display import display
8
+ from .. import ephys_no_curation as ephys
9
+ from skimage import io
8
10
9
11
10
- def _drop_down_wg (
11
- dj_table , * , description = "" , width = 100 , description_width = 100
12
- ) -> ipywidgets .Dropdown :
13
- return ipywidgets .Dropdown (
14
- options = dj_table .fetch ("KEY" , as_dict = True ),
15
- description = description ,
16
- disabled = False ,
17
- layout = ipywidgets .Layout (
18
- width = f"{ width } %" ,
19
- display = "flex" ,
20
- flex_flow = "row" ,
21
- justify_content = "space-between" ,
22
- grid_area = "processed_dropdown" ,
23
- ),
24
- style = {"description_width" : f"{ description_width } px" },
12
+ # Widgets
13
+ probe_dropdown_wg = widgets .Dropdown (
14
+ options = ephys .CuratedClustering & ephys_report .ProbeLevelReport .fetch ("KEY" ),
15
+ description = "Select Probe Insertion : " ,
16
+ disabled = False ,
17
+ layout = widgets .Layout (
18
+ width = "80%" ,
19
+ ),
20
+ style = {"description_width" : "150px" },
21
+ )
22
+
23
+ shank_dropdown_wg = widgets .Dropdown (
24
+ options = (ephys_report .ProbeLevelReport & probe_dropdown_wg .value ).fetch ("shank" ),
25
+ description = "Select Shank : " ,
26
+ disabled = False ,
27
+ layout = widgets .Layout (
28
+ width = "15%" ,
29
+ ),
30
+ style = {"description_width" : "100px" },
31
+ )
32
+
33
+ unit_dropdown_wg = widgets .Dropdown (
34
+ options = (
35
+ (ephys_report .UnitLevelReport & probe_dropdown_wg .value )
36
+ & "cluster_quality_label='good'"
37
+ ).fetch ("unit" ),
38
+ description = "Select Units : " ,
39
+ disabled = False ,
40
+ layout = widgets .Layout (
41
+ width = "15%" ,
42
+ ),
43
+ style = {"description_width" : "100px" },
44
+ )
45
+
46
+ # Update shank & unit dropdown according to probe change
47
+ def update_shank_options (change ):
48
+ probe_key = change .new
49
+ shank_dropdown_wg .options = (ephys_report .ProbeLevelReport & probe_key .value ).fetch (
50
+ "shank"
25
51
)
26
52
27
53
54
+ def update_unit_dropdown (change ):
55
+ probe_key = change .new
56
+ unit_dropdown_wg .options = (
57
+ (
58
+ (ephys_report .UnitLevelReport & probe_key .value )
59
+ & "cluster_quality_label='good'"
60
+ ).fetch ("unit" ),
61
+ )
62
+
63
+
64
+ probe_dropdown_wg .observe (update_shank_options , "value" )
65
+ probe_dropdown_wg .observe (update_unit_dropdown , "value" )
66
+
67
+
28
68
def plot_probe_level_report (probe_key : T .Dict [str , T .Any ]) -> None :
29
69
fig_name = (ephys_report .ProbeLevelReport & probe_key ).fetch1 ("drift_map_plot" )
30
70
fig , ax = plt .subplots (1 , 1 , figsize = (10 , 5 ))
@@ -35,16 +75,6 @@ def plot_probe_level_report(probe_key: T.Dict[str, T.Any]) -> None:
35
75
pathlib .Path (fig_name ).unlink ()
36
76
37
77
38
- def probe_widget () -> ipywidgets .interactive :
39
- drop_down_wg = _drop_down_wg (
40
- ephys_report .ProbeLevelReport ,
41
- description = "Select Probe Insertion : " ,
42
- width = 85 ,
43
- description_width = 150 ,
44
- )
45
- return ipywidgets .interactive (plot_probe_level_report , probe_key = drop_down_wg )
46
-
47
-
48
78
def plot_unit_level_report (unit_key : T .Dict [str , T .Any ]) -> None :
49
79
waveform_fig , autocorrelogram_fig , depth_waveform_fig = (
50
80
ephys_report .UnitLevelReport & unit_key
@@ -54,17 +84,7 @@ def plot_unit_level_report(unit_key: T.Dict[str, T.Any]) -> None:
54
84
depth_waveform_fig = go .FigureWidget (depth_waveform_fig )
55
85
56
86
display (
57
- ipywidgets .HBox (
58
- [ipywidgets .VBox ([waveform_fig , autocorrelogram_fig ]), depth_waveform_fig ]
87
+ widgets .HBox (
88
+ [widgets .VBox ([waveform_fig , autocorrelogram_fig ]), depth_waveform_fig ]
59
89
)
60
90
)
61
-
62
-
63
- def unit_widget () -> ipywidgets .interactive :
64
- drop_down_wg = _drop_down_wg (
65
- ephys_report .UnitLevelReport & "cluster_quality_label='good'" ,
66
- description = "Select Units : " ,
67
- width = 85 ,
68
- description_width = 150 ,
69
- )
70
- return ipywidgets .interactive (plot_unit_level_report , unit_key = drop_down_wg )
0 commit comments