Deleting multiples tracks at once? #1021
Closed
cosimogonnelli
started this conversation in
Ideas
Replies: 2 comments 1 reply
-
Hi @cosimogonnelli, We do not currently offer this in the GUI, but this is a great feature request. For the moment, you can programmatically delete tracks with the following template (in the sleap conda environment, run In [1]: import sleap
In [2]: ds = "path/to/slp"
In [3]: labels = sleap.load_file(ds)
In [4]: tracks = labels.tracks
In [5]: tracks
Out [5]:
[Track(spawned_on=10001, name='track_0'),
Track(spawned_on=10001, name='track_1'),
Track(spawned_on=0, name='track_0'),
Track(spawned_on=0, name='track_1'),
Track(spawned_on=3800, name='track_12'),
Track(spawned_on=3805, name='track_13')]
In [6]: track_indices_to_delete = [0, 2, 3] # Insert own indices here
In [7]: tracks_to_delete = [tracks[idx] for idx in track_indices_to_delete]
In [8]: tracks_to_delete
Out [8]:
[Track(spawned_on=10001, name='track_0'),
Track(spawned_on=0, name='track_0'),
Track(spawned_on=0, name='track_1')]
In [9]: for track in track_to_remove:
...: labels.remove_track(track)
...:
In [10]: tracks
Out [10]:
[Track(spawned_on=10001, name='track_1'),
Track(spawned_on=3800, name='track_12'),
Track(spawned_on=3805, name='track_13')]
In [11]: new_slp_path = "path/to/save/modified/slp/to" # To be safe, do not use the same path as the original
In [12]: sleap.Labels.save(labels, new_slp_path) |
Beta Was this translation helpful? Give feedback.
1 reply
-
To follow-up, we now have a Tracks > Delete Multiple > All or Unused option in the GUI. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi All,
Do you have any suggestions on how to delete multiples tracks at once?
In Sleap you provide a way to delete one or all tracks but in my case I have many tracks to delete and it becomes time consuming to do that manually.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions