11import sys
22import param
33import boto3
4+ import time
5+ from copy import deepcopy
46
57import panel as pn
68
1517from .utils import Tee
1618
1719
20+ displayed_unit_properties = ["decoder_label" , "firing_rate" , "y" , "snr" , "amplitude_median" , "isi_violation_ratio" ]
21+ default_curation_dict = {
22+ "label_definitions" : {
23+ "quality" :{
24+ "label_options" : ["good" , "MUA" , "noise" ],
25+ "exclusive" : True ,
26+ },
27+ },
28+ "manual_labels" : [],
29+ "merge_unit_groups" : [],
30+ "removed_units" : [],
31+ }
32+
1833class EphysGuiView (param .Parameterized ):
1934
2035 def __init__ (self , analyzer_path , recording_path , ** params ):
@@ -53,6 +68,7 @@ def __init__(self, analyzer_path, recording_path, **params):
5368
5469 def _initialize (self ):
5570 if self .analyzer_input .value != "" :
71+ t_start = time .perf_counter ()
5672 spinner = pn .indicators .LoadingSpinner (value = True , sizing_mode = "stretch_width" )
5773 # Create a TextArea widget to display logs
5874 log_output = pn .widgets .TextAreaInput (value = "" , sizing_mode = "stretch_both" )
@@ -75,6 +91,8 @@ def _initialize(self):
7591 self .win = self ._create_main_window ()
7692 self .layout [1 ] = self .win
7793 print ("Ephys GUI initialized successfully!" )
94+ t_stop = time .perf_counter ()
95+ print (f"Initialization time: { t_stop - t_start :.2f} seconds" )
7896 sys .stdout = sys .__stdout__ # Reset stdout
7997 sys .stderr = sys .__stderr__ # Reset stderr
8098
@@ -115,10 +133,22 @@ def _check_if_s3_folder_exists(self, location):
115133
116134 def _create_main_window (self ):
117135 if self .analyzer is not None :
136+ # prepare the curation data using decoder labels
137+ curation_dict = deepcopy (default_curation_dict )
138+ curation_dict ["unit_ids" ] = self .analyzer .unit_ids
139+ if "decoder_label" in self .analyzer .sorting .get_property_keys ():
140+ decoder_labels = self .analyzer .get_sorting_property ("decoder_label" )
141+ noise_units = self .analyzer .unit_ids [decoder_labels == "noise" ]
142+ curation_dict ["removed_units" ] = list (noise_units )
143+ for unit_id in noise_units :
144+ curation_dict ["manual_labels" ].append ({"unit_id" : unit_id , "quality" : ["noise" ]})
145+
118146 win = run_mainwindow (
119147 analyzer = self .analyzer ,
120148 curation = True ,
121149 skip_extensions = ["waveforms" ],
150+ displayed_unit_properties = displayed_unit_properties ,
151+ curation_dict = curation_dict ,
122152 backend = "panel" ,
123153 start_app = False ,
124154 make_servable = False ,
0 commit comments