Skip to content
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

Access start times of tracks #30

Open
mastrof opened this issue Dec 12, 2021 · 2 comments
Open

Access start times of tracks #30

mastrof opened this issue Dec 12, 2021 · 2 comments

Comments

@mastrof
Copy link

mastrof commented Dec 12, 2021

Is there a way to access the time (frame) at which a given track starts?

I was writing a function to produce customized animations (with Plots.jl) of the tracks, and realized that I could not find a direct way to access the time at which a given track begins.

(Following the notation in the bird tracking example) When I evaluate traces = trace(result, minlife=minlife), I get the coordinates that make up each track but the information on the frame at which the first point of each track occurs is lost.
The workaround I'm using right now to find the initial time of a track goes as follows:

for trace in traces
    t0 = findfirst(map(x -> trace[1] ∈ x, result.coordinates))
end

that is, I compare the first point of the track with the list of all coordinates and see the frame where it first occurs.
But it's quite hackish. And of course it will not work well in the general case (different tracks might go through the exact same coordinates at different times).

Since the already implemented methods to output videos are able to display tracks at the right time, I'm sure there is a better way to do this. I just can't find it.

Thanks for help (and thanks for the package!)

@baggepinnen
Copy link
Owner

baggepinnen commented Dec 13, 2021

Hello! There is probably no nice way to do this at the moment, other than to do the time stepping using the low-level interface. The videos can display tracks with correct starting point since they are created frame by frame during the time stepping. The main loop is rather simple, so it should be easy to extend

for (ind,img) in enumerate(buffer)

We could potentially also add the birth time to the Blob definition, that would probably make sense.

@mastrof
Copy link
Author

mastrof commented Dec 13, 2021

Thank you for pointing out where the output is produced.
Yes I would say that having the birth time inside Blob would be a nice addition: while I see the convenience of producing the output during timestepping, in general it will be useful to be able to do analysis and plotting independently.
Also, direct access to blob birth might also be needed for some other kind of analysis.

An alternative or complementary solution could also be to somehow provide the birth time along with the traces when trace is called; maybe traces could even deserve a type of their own, with birth time (or even the whole lifespan, as it would be just the UnitRange birth:death) and coordinates?

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

No branches or pull requests

2 participants