Skip to content

Commit

Permalink
Don't set widget values in the widgets (as done from file) (#379)
Browse files Browse the repository at this point in the history
* Remove unnecessary `.setValue` calls

* Check status done by config file
  • Loading branch information
paddyroddy authored Aug 7, 2023
1 parent 99301cc commit b088dbf
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 22 deletions.
2 changes: 0 additions & 2 deletions btrack/napari/widgets/_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,13 @@ 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()
not_assign.setDecimals(3)
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"] = (
"<b>P</b>(not track)",
not_assign,
Expand Down
17 changes: 1 addition & 16 deletions btrack/napari/widgets/_hypothesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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",
Expand All @@ -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
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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
Expand All @@ -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()
Expand All @@ -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
Expand All @@ -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"
Expand Down
4 changes: 0 additions & 4 deletions btrack/napari/widgets/_motion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(<b>P</b>)", 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(<b>G</b>)", G_sigma)

R_sigma = QtWidgets.QDoubleSpinBox()
Expand All @@ -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(<b>R</b>)", R_sigma)

return widgets
Expand All @@ -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

0 comments on commit b088dbf

Please sign in to comment.