From b088dbf5c75b85e1acd7baa246fac971ccdbf7e5 Mon Sep 17 00:00:00 2001 From: Patrick Roddy Date: Mon, 7 Aug 2023 17:30:45 +0100 Subject: [PATCH] Don't set widget values in the widgets (as done from file) (#379) * Remove unnecessary `.setValue` calls * Check status done by config file --- btrack/napari/widgets/_general.py | 2 -- btrack/napari/widgets/_hypothesis.py | 17 +---------------- btrack/napari/widgets/_motion.py | 4 ---- 3 files changed, 1 insertion(+), 22 deletions(-) diff --git a/btrack/napari/widgets/_general.py b/btrack/napari/widgets/_general.py index 3c6273b6..ab69ea40 100644 --- a/btrack/napari/widgets/_general.py +++ b/btrack/napari/widgets/_general.py @@ -86,7 +86,6 @@ def create_update_method_widgets() -> dict[str, tuple[str, QtWidgets.QWidget]]: max_lost_frames.setToolTip( "Number of frames without observation before marking as lost" ) - max_lost_frames.setValue(5) widgets["max_lost"] = ("max lost", max_lost_frames) not_assign = QtWidgets.QDoubleSpinBox() @@ -94,7 +93,6 @@ def create_update_method_widgets() -> dict[str, tuple[str, QtWidgets.QWidget]]: not_assign.setRange(0, 1) not_assign.setStepType(QtWidgets.QAbstractSpinBox.AdaptiveDecimalStepType) not_assign.setToolTip("Default probability to not assign a track") - not_assign.setValue(0.1) widgets["prob_not_assign"] = ( "P(not track)", not_assign, diff --git a/btrack/napari/widgets/_hypothesis.py b/btrack/napari/widgets/_hypothesis.py index 07f3a170..a35c5b87 100644 --- a/btrack/napari/widgets/_hypothesis.py +++ b/btrack/napari/widgets/_hypothesis.py @@ -23,7 +23,6 @@ def _create_hypotheses_widgets() -> dict[str, tuple[str, QtWidgets.QWidget]]: widget.addItems([f"{h.replace('_', '(')})" for h in hypotheses]) flags = QtCore.Qt.ItemFlags(QtCore.Qt.ItemIsUserCheckable + QtCore.Qt.ItemIsEnabled) for i, tooltip in enumerate(tooltips): - widget.item(i).setCheckState(QtCore.Qt.CheckState.Checked) widget.item(i).setFlags(flags) widget.item(i).setToolTip(tooltip) @@ -32,18 +31,12 @@ def _create_hypotheses_widgets() -> dict[str, tuple[str, QtWidgets.QWidget]]: QtCore.Qt.ItemIsUserCheckable, ) - # # P_merge should be disabled by default - widget.item(hypotheses.index("P_merge")).setCheckState( - QtCore.Qt.CheckState.Unchecked - ) - return {"hypotheses": ("hypotheses", widget)} def _create_scaling_factor_widgets() -> dict[str, tuple[str, QtWidgets.QWidget]]: """Create widgets for setting the scaling factors of the HypothesisModel""" - widget_values = [5.0, 3.0, 10.0, 50.0] names = [ "lambda_time", "lambda_dist", @@ -64,11 +57,10 @@ def _create_scaling_factor_widgets() -> dict[str, tuple[str, QtWidgets.QWidget]] ] scaling_factor_widgets = {} - for value, name, label, tooltip in zip(widget_values, names, labels, tooltips): + for name, label, tooltip in zip(names, labels, tooltips): widget = QtWidgets.QDoubleSpinBox() widget.setStepType(QtWidgets.QAbstractSpinBox.AdaptiveDecimalStepType) widget.setToolTip(tooltip) - widget.setValue(value) scaling_factor_widgets[name] = (label, widget) return scaling_factor_widgets @@ -83,7 +75,6 @@ def _create_threshold_widgets() -> dict[str, tuple[str, QtWidgets.QWidget]]: "A threshold distance from the edge of the field of view to add an " "initialization or termination hypothesis." ) - distance_threshold.setValue(20.0) widgets = {"theta_dist": ("distance threshold", distance_threshold)} time_threshold = QtWidgets.QDoubleSpinBox() @@ -92,7 +83,6 @@ def _create_threshold_widgets() -> dict[str, tuple[str, QtWidgets.QWidget]]: "A threshold time from the beginning or end of movie to add " "an initialization or termination hypothesis." ) - time_threshold.setValue(5.0) widgets["theta_time"] = ("time threshold", time_threshold) apoptosis_threshold = QtWidgets.QSpinBox() @@ -101,7 +91,6 @@ def _create_threshold_widgets() -> dict[str, tuple[str, QtWidgets.QWidget]]: "Number of apoptotic detections to be considered a genuine event.\n" "Detections are counted consecutively from the back of the track" ) - apoptosis_threshold.setValue(5) widgets["apop_thresh"] = ("apoptosis threshold", apoptosis_threshold) return widgets @@ -116,7 +105,6 @@ def _create_bin_size_widgets() -> dict[str, tuple[str, QtWidgets.QWidget]]: "Isotropic spatial bin size for considering hypotheses.\n" "Larger bin sizes generate more hypothesese for each tracklet." ) - distance_bin_size.setValue(40.0) widgets = {"dist_thresh": ("distance bin size", distance_bin_size)} time_bin_size = QtWidgets.QDoubleSpinBox() @@ -125,7 +113,6 @@ def _create_bin_size_widgets() -> dict[str, tuple[str, QtWidgets.QWidget]]: "Temporal bin size for considering hypotheses.\n" "Larger bin sizes generate more hypothesese for each tracklet." ) - time_bin_size.setValue(2.0) widgets["time_thresh"] = ("time bin size", time_bin_size) return widgets @@ -149,11 +136,9 @@ def create_hypothesis_model_widgets() -> dict[str, tuple[str, QtWidgets.QWidget] "Miss rate for the segmentation.\n" "e.g. 1/100 segmentations incorrect gives a segmentation miss rate of 0.01." ) - segmentation_miss_rate.setValue(0.1) widgets["segmentation_miss_rate"] = ("miss rate", segmentation_miss_rate) relax = QtWidgets.QCheckBox() - relax.setChecked(True) # noqa: FBT003 relax.setToolTip( "Disable the time and distance thresholds.\n" "This means that tracks can initialize or terminate anywhere and" diff --git a/btrack/napari/widgets/_motion.py b/btrack/napari/widgets/_motion.py index ee27e23f..a4f1893b 100644 --- a/btrack/napari/widgets/_motion.py +++ b/btrack/napari/widgets/_motion.py @@ -12,14 +12,12 @@ def _create_sigma_widgets() -> dict[str, tuple[str, QtWidgets.QWidget]]: P_sigma.setToolTip( "Magnitude of error in initial estimates.\nUsed to scale the matrix P." ) - P_sigma.setValue(150.0) widgets = {"P_sigma": ("max(P)", P_sigma)} G_sigma = QtWidgets.QDoubleSpinBox() G_sigma.setRange(0, 500) G_sigma.setStepType(QtWidgets.QAbstractSpinBox.AdaptiveDecimalStepType) G_sigma.setToolTip("Magnitude of error in process\nUsed to scale the matrix G.") - G_sigma.setValue(15.0) widgets["G_sigma"] = ("max(G)", G_sigma) R_sigma = QtWidgets.QDoubleSpinBox() @@ -28,7 +26,6 @@ def _create_sigma_widgets() -> dict[str, tuple[str, QtWidgets.QWidget]]: R_sigma.setToolTip( "Magnitude of error in measurements.\nUsed to scale the matrix R." ) - R_sigma.setValue(5.0) widgets["R_sigma"] = ("max(R)", R_sigma) return widgets @@ -43,7 +40,6 @@ def create_motion_model_widgets() -> dict[str, tuple[str, QtWidgets.QWidget]]: accuracy.setRange(0.1, 10) accuracy.setStepType(QtWidgets.QAbstractSpinBox.AdaptiveDecimalStepType) accuracy.setToolTip("Integration limits for calculating probabilities") - accuracy.setValue(7.5) widgets["accuracy"] = ("accuracy", accuracy) return widgets