movement icon indicating copy to clipboard operation
movement copied to clipboard

Add support for loading time coordinates from file

Open sfmig opened this issue 9 months ago • 9 comments

Is your feature request related to a problem? Please describe. Right now we derive the time stamps:

  • relative to the start of the video
  • using the provided fps
  • assuming all frames are consecutive

Describe the solution you'd like It would be nice if the user can pass a vector of timestamps too.

Describe alternatives you've considered \

Additional context Related to the comment under this thread

sfmig avatar Mar 06 '25 14:03 sfmig

@Lauraschwarz is prepping some nice behavioural experiments with time-synced sensors logged with harp.

It would be nice if we provided support to load timestamps exported by harp.

Both Laura and Aeon are using Bonsai to fetch the harp data.

Also harp has a nice Python API that would be very relevant

sfmig avatar Mar 06 '25 14:03 sfmig

Also @sannatitus is planning to collect synced behaviour + neural data in the crab dome (see her bonsai workflow using harp here)

sfmig avatar Mar 24 '25 15:03 sfmig

Also @sannatitus is planning to collect synced behaviour + neural data in the crab dome (see her bonsai workflow using harp here)

Just in case it's relevant to anything, we'll be aligning the TTLs (timestamps) post-acquistion with a python script (we haven't tried this yet, but I should be fine as it seems well documented and straightforward!).

sannatitus avatar Mar 24 '25 16:03 sannatitus

To add support for user-provided time coordinates, I recommend the approach to first modify the dataset loading functions to accept an optional parameter time cords.

  • Validate that its length matches the number of frames and that the values are monotonic.
  • Assign this vector as the time coordinate of the xarray Dataset;
  • if no Dataset, fallback to generating timestamps using the FPS and consecutive frame assumption. Let me know if I am on the right track would be happy to contribute in any capacity

demoncoder-crypto avatar Mar 28 '25 12:03 demoncoder-crypto

Image

demoncoder-crypto avatar Mar 28 '25 12:03 demoncoder-crypto

Now I do understand @tomatochocolate12 has done an implementation already, I just wanted to provide an Overview of my understanding with a rough implementation to hopefully add some value in this

demoncoder-crypto avatar Mar 28 '25 12:03 demoncoder-crypto

Thanks for your input @demoncoder-crypto, but given that we are already working on this in #479, better not to duplicate efforts. But feel free to chime in on the discussion under that PR.

niksirbi avatar Mar 28 '25 14:03 niksirbi

I've played with datetime indices for xarray in this project, and I have some fresh perspective on this matter.

I've tried to summarise my thoughts in an extensive comment to this PR.

niksirbi avatar May 30 '25 14:05 niksirbi

Issue #669 has the most up-to-date description of my plan for handling time coordinates. Nevertheless, I will keep this issue open, specifically to track loading timestamps from files (such as the ones output by Bonsai-Harp), which is not part of #669 but depends on it. I've renamed this issue accordingly.

niksirbi avatar Aug 26 '25 17:08 niksirbi