Skip to content

Commit

Permalink
Updated trail length viewing options (#1822)
Browse files Browse the repository at this point in the history
* updated trail length optptions

* Updated trail length options in the view menu

* Updated `prefs` to include length info from `preferences.yaml`

* Added trail length as method of `MainWindow`

* Updated trail length documentation

* black formatting

---------

Co-authored-by: Keya Loding <[email protected]>
  • Loading branch information
keyaloding and Keya Loding authored Jun 28, 2024
1 parent 0528362 commit 436b177
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/guides/gui.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Note that many of the menu command have keyboard shortcuts which can be configur

"**Edge Style**" controls whether edges are drawn as thin lines or as wedges which indicate the {ref}`orientation` of the instance (as well as the direction of the part affinity field which would be used to predict the connection between nodes when using a "bottom-up" approach).

"**Trail Length**" allows you to show a trail of where each instance was located in prior frames (the length of the trail is the number of prior frames). This can be useful when proofreading predictions since it can help you detect swaps in the identities of animals across frames.
"**Trail Length**" allows you to show a trail of where each instance was located in prior frames (the length of the trail is the number of prior frames). This can be useful when proofreading predictions since it can help you detect swaps in the identities of animals across frames. By default, you can only select trail lengths of up to 250 frames. You can use a custom trail length by modifying the default length in the `preferences.yaml` file. However, using trail lengths longer than about 500 frames can result in significant lag.

"**Fit Instances to View**" allows you to toggle whether the view is auto-zoomed to the instances in each frame. This can be useful when proofreading predictions.

Expand Down
3 changes: 3 additions & 0 deletions sleap/gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def __init__(
self.state["edge style"] = prefs["edge style"]
self.state["fit"] = False
self.state["color predicted"] = prefs["color predicted"]
self.state["trail_length"] = prefs["trail length"]
self.state["trail_shade"] = prefs["trail shade"]
self.state["marker size"] = prefs["marker size"]
self.state["propagate track labels"] = prefs["propagate track labels"]
Expand Down Expand Up @@ -221,6 +222,7 @@ def closeEvent(self, event):
prefs["edge style"] = self.state["edge style"]
prefs["propagate track labels"] = self.state["propagate track labels"]
prefs["color predicted"] = self.state["color predicted"]
prefs["trail length"] = self.state["trail_length"]
prefs["trail shade"] = self.state["trail_shade"]
prefs["share usage data"] = self.state["share usage data"]

Expand Down Expand Up @@ -1025,6 +1027,7 @@ def _load_overlays(self):
labels=self.labels,
player=self.player,
trail_shade=self.state["trail_shade"],
trail_length=self.state["trail_length"],
)
self.overlays["instance"] = InstanceOverlay(
labels=self.labels, player=self.player, state=self.state
Expand Down
4 changes: 3 additions & 1 deletion sleap/gui/overlays/tracks.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ def __attrs_post_init__(self):

@classmethod
def get_length_options(cls):
return (0, 10, 50, 100, 250)
if prefs["trail length"] != 0:
return (0, 10, 50, 100, 250, 500, prefs["trail length"])
return (0, 10, 50, 100, 250, 500)

@classmethod
def get_shade_options(cls):
Expand Down
4 changes: 4 additions & 0 deletions sleap/prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ def load_(self):
self._prefs = util.get_config_yaml(self._filename)
if not hasattr(self._prefs, "get"):
self._prefs = self._defaults
else:
self._prefs["trail length"] = self._prefs.get(
"trail length", self._defaults["trail length"]
)
except FileNotFoundError:
self._prefs = self._defaults

Expand Down

0 comments on commit 436b177

Please sign in to comment.