soft-matter / trackpy

Python particle tracking toolkit
http://soft-matter.github.io/trackpy
Other
453 stars 132 forks source link

The number of trajectories is different from the number of unique particle IDs #732

Closed lxfhfut closed 1 year ago

lxfhfut commented 1 year ago

In the walkthrough tutorial, running the link function "t = tp.link(f, 5, memory=3)" returns "Frame 299: 624 trajectories present", where dataframe 't' contains an additional column, 'particle', identifying each feature with a label. My understanding is that we could run "t['particle'].nunique()" to get the number of tracks/trajecgtories, but this returns "13715" which is inconsistent with the message from running link function. I am confused about this. How can we get the data for each track/trajectory? Any help would be appreciated!

b-grimaud commented 1 year ago

This most likely means there are 624 trajectories in frame #299 but 13715 in the overall file. You should be able to check with : t[t.frame==299].particle.nunique()

lxfhfut commented 1 year ago

@BptGrm Thanks for your reply. Yes, 624 is the number of trajectories of the last frame. It seems to be caused by the behavior of generator used in 'link_iter' function. It is confusing to just show the track number of the last frame. The first time I ran 'link' function I was wondering why the number of resultant trajectories did not change for two quite different search ranges ;(