Skip to content

Fix starting new track_id by pressing 'M'#96

Merged
AnniekStok merged 3 commits into
mainfrom
84-bug-not-using-our-custom-new-labels-function-when-pressing-m
Jul 28, 2025
Merged

Fix starting new track_id by pressing 'M'#96
AnniekStok merged 3 commits into
mainfrom
84-bug-not-using-our-custom-new-labels-function-when-pressing-m

Conversation

@AnniekStok
Copy link
Copy Markdown
Collaborator

Fix for issue #84 (hopefully)
Allow the user to start a new track by pressing M on the TracksLabels layer, which should assign a color for the next available node id and add it to the colormap.

Steps to test:

  1. Press 'M' on a TracksLabels layer (any tool can be active). Verify that the 'label' value increments and a color is assigned.
  2. Verify that painting with the newly assigned label adds a new node.
  3. Verify that moving forward or backwards in time and painting again auto-increments the label with 1 and connects the nodes.
  4. Verify that pressing 'M' again assigns a new label, and allows you to start a new track_id.

Notes:
You can assign a new node id by pressing M even if the max value +1 in the array is equal to the currently selected label. The ensure_valid_label function automatically adds +1 to the selected_label when moving in time to ensure that you can continue a track_id without having to select it each time you go to a different time point. If the currently assigned label is larger than the max value +1 in the array, we should not allow the user to add a new label, as they should use the current one first.

…cksLabels layer, which should assign a color for the next available node id
@AnniekStok AnniekStok requested a review from cmalinmayor July 27, 2025 21:28
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jul 27, 2025

Codecov Report

❌ Patch coverage is 14.28571% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.44%. Comparing base (6140cb9) to head (3562f28).

Files with missing lines Patch % Lines
finn/track_data_views/views/layers/track_labels.py 14.28% 6 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main      #96   +/-   ##
=======================================
  Coverage   89.44%   89.44%           
=======================================
  Files         650      650           
  Lines       60169    60168    -1     
=======================================
+ Hits        53817    53818    +1     
+ Misses       6352     6350    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

new_selected_label = np.max(layer.data) + 1
if layer.selected_label == new_selected_label:
if layer.selected_label > new_selected_label:
show_info(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just set new track ID here instead of setting a new label? I think regardless you need to set a new track ID as well as a new label.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I think indeed don't need the if statements at all and can just (re)assign the selected_label to np.max(layer.data) + 1 if it isn't already (because of ensure_valid_label) and create a new track_id and color for it.

…a) + 1 (if it is not already) and assign a new track_id and color
Copy link
Copy Markdown
Contributor

@cmalinmayor cmalinmayor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent, I like it much more now! Thanks :)

@AnniekStok AnniekStok merged commit 57c10e0 into main Jul 28, 2025
4 checks passed
@AnniekStok AnniekStok deleted the 84-bug-not-using-our-custom-new-labels-function-when-pressing-m branch July 28, 2025 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants