Skip to content

Commit

Permalink
Changed all widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
paddyroddy committed Jul 27, 2023
1 parent 2ab6adb commit 506f4aa
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 81 deletions.
33 changes: 11 additions & 22 deletions btrack/napari/widgets/_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,30 @@

from qtpy import QtWidgets

import magicgui
import napari


def create_input_widgets() -> dict[str, QtWidgets.QWidget]:
"""Create widgets for selecting labels layer and TrackerConfig"""

segmentation_tooltip = (
# TODO: annotation=napari.layers.Labels,
segmentation = QtWidgets.QComboBox()
segmentation.setName("segmentation")
segmentation.setToolTip(
"Select a 'Labels' layer to use for tracking.\n"
"To use an 'Image' layer, first convert 'Labels' by right-clicking "
"on it in the layers list, and clicking on 'Convert to Labels'"
)
segmentation = magicgui.widgets.create_widget(
annotation=napari.layers.Labels,
name="segmentation",
label="segmentation",
options={"tooltip": segmentation_tooltip},
)
widgets = {"segmentation": segmentation}

config_tooltip = (
config = QtWidgets.QComboBox()
config.addItems(["cell", "particle"])
config.setName("config")
config.setTooltip(
"Select a loaded configuration.\n"
"Note, this will update values set below."
)
config = magicgui.widgets.create_widget(
value="cell",
name="config",
label="config name",
widget_type="ComboBox",
options={
"choices": ["cell", "particle"],
"tooltip": config_tooltip,
},
)
widgets["config"] = config

return [segmentation, config]
return widgets


def create_update_method_widgets() -> dict[str, QtWidgets.QWidget]:
Expand Down
90 changes: 31 additions & 59 deletions btrack/napari/widgets/_motion.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

from qtpy import QtWidgets

import magicgui


def _make_label_bold(label: str) -> str:
"""Generate html for a bold label"""
Expand All @@ -14,81 +12,55 @@ def _make_label_bold(label: str) -> str:
def _create_sigma_widgets() -> dict[str, QtWidgets.QWidget]:
"""Create widgets for setting the magnitudes of the MotionModel matrices"""

P_sigma_tooltip = (
P_sigma = QtWidgets.QDoubleSpinBox()
P_sigma.setName(f"max({_make_label_bold('P')})")
P_sigma.setToolTip(
"Magnitude of error in initial estimates.\n"
"Used to scale the matrix P."
)
P_sigma = magicgui.widgets.create_widget(
value=150.0,
name="P_sigma",
label=f"max({_make_label_bold('P')})",
widget_type="FloatSpinBox",
options={"tooltip": P_sigma_tooltip},
)
P_sigma.setValue(150.0)
widgets = {"P_sigma": P_sigma}

G_sigma_tooltip = (
G_sigma = QtWidgets.QDoubleSpinBox()
G_sigma.setName(f"max({_make_label_bold('G')})")
G_sigma.setToolTip(
"Magnitude of error in process.\n Used to scale the matrix G."
)
G_sigma = magicgui.widgets.create_widget(
value=15.0,
name="G_sigma",
label=f"max({_make_label_bold('G')})",
widget_type="FloatSpinBox",
options={"tooltip": G_sigma_tooltip},
)
G_sigma.setValue(15.0)
widgets["G_sigma"] = G_sigma

R_sigma_tooltip = (
R_sigma = QtWidgets.QDoubleSpinBox()
R_sigma.setName(f"max({_make_label_bold('R')})")
R_sigma.setToolTip(
"Magnitude of error in measurements.\n Used to scale the matrix R."
)
R_sigma = magicgui.widgets.create_widget(
value=5.0,
name="R_sigma",
label=f"max({_make_label_bold('R')})",
widget_type="FloatSpinBox",
options={"tooltip": R_sigma_tooltip},
)
R_sigma.setValue(5.0)
widgets["R_sigma"] = R_sigma

return [
P_sigma,
G_sigma,
R_sigma,
]
return widgets


def create_motion_model_widgets() -> dict[str, QtWidgets.QWidget]:
"""Create widgets for setting parameters of the MotionModel"""

motion_model_label = magicgui.widgets.create_widget(
label=_make_label_bold("Motion model"),
widget_type="Label",
gui_only=True,
)
motion_model_label = QtWidgets.QLabel()
motion_model_label.setName(_make_label_bold("Motion model"))
widgets = {"motion_model": motion_model_label}

sigma_widgets = _create_sigma_widgets()
widgets |= _create_sigma_widgets()

accuracy_tooltip = "Integration limits for calculating probabilities"
accuracy = magicgui.widgets.create_widget(
value=7.5,
name="accuracy",
label="accuracy",
widget_type="FloatSpinBox",
options={"tooltip": accuracy_tooltip},
)
accuracy = QtWidgets.QDoubleSpinBox()
accuracy.setName("accuracy")
accuracy.setToolTip("Integration limits for calculating probabilities")
accuracy.setValue(7.5)
widgets["accuracy"] = accuracy

max_lost_frames_tooltip = (
max_lost_frames = QtWidgets.QSpinBox()
max_lost_frames.setName("max lost")
max_lost_frames.setToolTip(
"Number of frames without observation before marking as lost"
)
max_lost_frames = magicgui.widgets.create_widget(
value=5,
name="max_lost",
label="max lost",
widget_type="SpinBox",
options={"tooltip": max_lost_frames_tooltip},
)
max_lost_frames.setValue(5)
widgets["max_lost"] = max_lost_frames

return [
motion_model_label,
*sigma_widgets,
accuracy,
max_lost_frames,
]
return widgets

0 comments on commit 506f4aa

Please sign in to comment.