denisecailab / ezTrack

Free, platform independent, behavior tracking software.
GNU General Public License v3.0
118 stars 41 forks source link

frames do not match #15

Closed adrianacancode closed 4 years ago

adrianacancode commented 4 years ago

Hi,

I'll get straight into my question:

Part 3 of FreezeAnalysis_Individual tells me that my video has about 61,000 frames which matches what I calculated by hand (60 FPS, ~17 min video).

I had set part 2 to analyze my entire video by having the 'end' be None. However, the x axis' on the motion graphs displayed on parts 4b and 5b only go a little further than 30,000 frames. I'm confused because this means I'm missing about 30,000 frames of my video.

Throughout my video, there are 6 shocks administered. What adds to my confusion is that I can see the points at which the shock was administered ( I see 6 huge bursts of motion) even though there are about 30,000 missing frames.

I want to be able to create a binned summary of the animals activity 30 seconds before they receive the shock, but I am having trouble because my idea of when the shocks were administered based on the original video and what is being displayed on motion graphs does not match in terms of frames.

I am new to python and loving ezTrack so far! Any help would be greatly appreciated!

Thank you!!

ZachPenn commented 4 years ago

Hi!

Glad you're liking ezTrack! I'm not entirely sure what is going on but I have a decent hunch based upon a similar experience another user had in the past.

The number of frames that is returned in Part 3 is extracted from video file metadata. It is not calculated by counting the the number of available frames, but rather, is simply reading the description in the file that was written upon saving. Unfortunately, there have been a few cases I've seen where this metadata does not accurately reflect the number of actual frames. It may have to do with the compression algorithm used when the video file was originally recorded, or with how ezTrack (or rather, OpenCV) extracts frames from the file type.

Given that your data is approximately half the expected size, and all of the behavioral events seem to be present (the reactions to the 6 shocks), I wonder if the 'true sampling rate' (i.e. the number of frames that can be decoded) is actually 30 fps. To test whether this is the case, after running 4b, create a cell with the following code:

len(Motion)

This will give you the number of processed frames. If you divide this by the number of seconds in your video and you get 30, or something ridiculously close to it, my guess is that this is the case (it could also be 20 or 25 fps, both popular). If you'd like to further confirm that it's not something specific ezTrack, you can use VLC media player (free software that reads lots of video file formats). With VLC you also have the ability to check how many frames have been decoded at the end of a video.

If it turns out that your video is actually 30 fps, I might just proceed as if this were the case.

I hope this helps. Let me know if you have any further questions.

Zach

adrianacancode commented 4 years ago

Hi Zach,

I was actually able to solve my issue by converting my video files from avi to mp4. Not sure exactly how this solved my issue, but it worked!

I'm really excited to keep going, and I really appreciate your help!

Best, Adriana