@@ -110,7 +110,7 @@ def _extend_sgns_simple(gfp, sgns, dilation):
110110 return sgns_extended
111111
112112
113- def gfp_annotation (prefix , default_stat = "mean " ):
113+ def gfp_annotation (prefix , default_stat = "median " ):
114114 gfp = imageio .imread (f"{ prefix } _GFP_resized.tif" )
115115 sgns = imageio .imread (f"{ prefix } _SGN_resized_v2.tif" )
116116 pv = imageio .imread (f"{ prefix } _PV_resized.tif" )
@@ -148,20 +148,38 @@ def gfp_annotation(prefix, default_stat="mean"):
148148 # 1.) The widget for selcting the statistics to be used and displaying the histogram.
149149 stat_widget = _create_stat_widget (statistics , default_stat )
150150
151- # 2.) The widget for setting the threshold and updating the positive / negative classification based on it .
151+ # 2.) Precompute statistic ranges .
152152 stat_names = stat_widget .stat_names
153- step = 1
154153 all_values = statistics [stat_names ].values
155154 min_val = all_values .min ()
156155 max_val = all_values .max ()
157156
157+ # 3.) The widget for printing the intensity of a selected cell.
158+ @magicgui (
159+ value = {"label" : "value" , "enabled" : False , "widget_type" : "FloatSpinBox" , "min" : 0.0 , "max" : max_val },
160+ call_button = "Pick Value"
161+ )
162+ def pick_widget (viewer : napari .Viewer , value : float = 0.0 ):
163+ layer = viewer .layers ["SGNs-extended" ]
164+ selected_id = layer .selected_label
165+
166+ stat_name = stat_widget .param_box .currentText ()
167+ label_ids = statistics .label_id .values
168+ if selected_id not in label_ids :
169+ return {"value" : 0.0 }
170+
171+ vals = statistics [stat_name ].values
172+ picked_value = vals [label_ids == selected_id ][0 ]
173+ pick_widget .value .value = picked_value
174+
175+ # 4.) The widget for setting the threshold and updating the positive / negative classification based on it.
158176 @magicgui (
159177 threshold = {
160178 "widget_type" : "FloatSlider" ,
161179 "label" : "Threshold" ,
162180 "min" : min_val ,
163181 "max" : max_val ,
164- "step" : step ,
182+ "step" : 1 ,
165183 },
166184 call_button = "Apply" ,
167185 )
@@ -180,6 +198,7 @@ def threshold_widget(viewer: napari.Viewer, threshold: float = (max_val - min_va
180198
181199 # Bind the widgets.
182200 v .window .add_dock_widget (stat_widget , area = "right" )
201+ v .window .add_dock_widget (pick_widget , area = "right" )
183202 v .window .add_dock_widget (threshold_widget , area = "right" )
184203 stat_widget .setWindowTitle ("GFP Histogram" )
185204
0 commit comments