-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: Prediction fails on empty frames #367
base: master
Are you sure you want to change the base?
Conversation
I ran into this issue when trying to link some particles into trajectories. I have stretches where the particles disappear from the frame for 10 frames or more which is much greater than my memory setting (memory=3). I fixed it by changing linking.py. From the current master: if self.predictor is not None:
# This only works for KDTree right now, because KDTree can store particle
# positions in a separate data structure from the PointND instances.
if not isinstance(prev_hash, TreeFinder):
raise NotImplementedError(
'Prediction works with the "KDTree" neighbor_strategy only.')
# Get the time of cur_level from its first particle
t_next = list(itertools.islice(cur_level, 0, 1))[0].t
targeted_predictor = functools.partial(self.predictor, t_next)
prev_hash.rebuild(coord_map=targeted_predictor) # Rewrite positions In empty frames if self.predictor is not None:
# This only works for KDTree right now, because KDTree can store particle
# positions in a separate data structure from the PointND instances.
if not isinstance(prev_hash, TreeFinder):
raise NotImplementedError(
'Prediction works with the "KDTree" neighbor_strategy only.')
# Get the time of cur_level from its first particle
try:
t_next = list(itertools.islice(cur_level, 0, 1))[0].t
except IndexError:
t_next = list(itertools.islice(prev_level, 0, 1))[0].t + 1
targeted_predictor = functools.partial(self.predictor, t_next)
prev_hash.rebuild(coord_map=targeted_predictor) # Rewrite positions It seems to work fine for my purposes perhaps because the length of time that the particles spend out of frame is longer than my current memory setting (which is fine with me). Also this might be a naive question but I don't understand the point of using |
Thanks, @pfigliozzi ! I think that you want to use But, taking a step back, I'm not sure that the value of The levels are usually lists, but for purposes of |
I really don't remember coming up with this Anyway, thanks for this suggestion @pfigliozzi. I think that this issue will be solved in the new linking implementation (over here https://github.com/soft-matter/trackpy/pull/414/files#diff-ef01253517b496f9c55faa898b68174bR693) as the linker is 'frame-number aware' anyway. We do have to finish the new linking implementation (currently stuck at PR #414). |
Sorry to have neglected #414! Skype probably isn't going to help until I actually attempt to debug it. I am planning do that later this week, and will let you know what I find.
On Feb 4, 2017, 1:32 PM -0800, Casper van der Wel <[email protected]>, wrote:
I really don't remember coming up with this islice 😕, but I agree that it is because prev_level is allowed to be non-indexable.
Anyway, thanks for this suggestion @pfigliozzi<https://github.com/pfigliozzi>. I think that this issue will be solved in the new linking implementation (over here https://github.com/soft-matter/trackpy/pull/414/files#diff-ef01253517b496f9c55faa898b68174bR693) as the linker is 'frame-number aware' anyway.
We do have to finish the new linking implementation (currently stuck at PR #414<#414>).
@nkeim<https://github.com/nkeim>, maybe we could have a quick skype session sometime to get that going?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#367 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AC2NbYCiinidjGPfWh3d8XOlgwctPdAiks5rZO5YgaJpZM4IefXK>.
|
This adds a test that points out an unwanted behavior: prediction fails on empty frames. It should at least print an informative error message; instead we just get an
IndexError
whenlink()
tries to read the frame number by inspecting the first particle.I am leaving this open without a fix for now, because I'd like to revisit it when I/we finish #333.