@@ -143,11 +143,11 @@ def __init__(self, viewer: "napari.viewer.Viewer", parent=None):
143143 self .thresholding_checkbox = ui .CheckBox (
144144 "Perform thresholding" , self ._toggle_display_thresh
145145 )
146- self .thresholding_checkbox .setChecked (True )
147146
148147 self .thresholding_slider = ui .Slider (
149- default = config .PostProcessConfig ().thresholding .threshold_value
150- * 100 ,
148+ default = config .MODEL_LIST [
149+ self .model_choice .currentText ()
150+ ].default_threshold ,
151151 divide_factor = 100.0 ,
152152 parent = self ,
153153 )
@@ -410,6 +410,13 @@ def _load_weights_path(self):
410410 )
411411 self ._update_weights_path (file )
412412
413+ def _set_default_threshold (self ):
414+ # Whenever a model is selected, set the default threshold from the model file
415+ model_name = self .model_choice .currentText ()
416+ threshold = config .MODEL_LIST [model_name ].default_threshold
417+ print (threshold )
418+ self .thresholding_slider .slider_value = threshold * 100
419+
413420 def _build (self ):
414421 """Puts all widgets in a layout and adds them to the napari Viewer."""
415422 # ui.add_blank(self.view_results_container, view_results_layout)
@@ -494,7 +501,8 @@ def _build(self):
494501 self .device_choice ,
495502 ],
496503 )
497- self .window_infer_params .setVisible (False )
504+ self .use_window_choice .setChecked (True )
505+ # self.window_infer_params.setVisible(False)
498506
499507 inference_param_group_w .setLayout (inference_param_group_l )
500508
@@ -539,14 +547,18 @@ def _build(self):
539547 # self.instance_param_container, # instance segmentation
540548 ],
541549 )
550+ # self.thresholding_slider.container.setVisible(False)
551+ self .thresholding_checkbox .setChecked (True )
542552 self ._toggle_crf_choice ()
543553 self .model_choice .currentIndexChanged .connect (self ._toggle_crf_choice )
554+ self .model_choice .currentIndexChanged .connect (
555+ self ._set_default_threshold
556+ )
544557 ModelFramework ._show_io_element (
545558 self .save_stats_to_csv_box , self .use_instance_choice
546559 )
547560
548561 self .anisotropy_wdgt .container .setVisible (False )
549- self .thresholding_slider .container .setVisible (False )
550562 self .instance_widgets .setVisible (False )
551563 self .crf_widgets .setVisible (False )
552564 self .save_stats_to_csv_box .setVisible (False )
0 commit comments