sgoldenlab / simba

SimBA (Simple Behavioral Analysis), a pipeline and GUI for developing supervised behavioral classifiers
https://simba-uw-tf-dev.readthedocs.io/
GNU General Public License v3.0
273 stars 137 forks source link

Total distance traveled and velocity #307

Closed IsabelleSajonia closed 8 months ago

IsabelleSajonia commented 8 months ago

I tried to make a path plot and look at movement data like total distance and velocity to compare them to Ethovision (for validation). I'm seeing that my total distance looks very different than ethovision but they are both in cm and standardized to the same known distance. The plot path also looks a little off compared to the original raw video, and when I look at the frames that aren't being tracked, the labels look ok in sleap. I'm not sure what the issue might be but if you have any ideas of what I could try in order to compare Ethovision to simba let me know. Thank you!

sronilsson commented 8 months ago

Hi @IsabelleSajonia! - it sounds like the tracking is off in, SimBA and we should figure out why.

Can you tell me what you mean here?

when I look at the frames that aren't being tracked, the labels look ok in sleap

There is a few ways the tracking could become mangled when imported it into SimBA, I have written about some HERE.

There is a method accessable in the tools menu described HERE. If you use that tool, and point it too the videos in the project_folder/csv/outlier_corrected_movement_location, how does it look?

IsabelleSajonia commented 8 months ago

activity_valid - Trim.zip I'm attaching a trimmed version of what I see when I do this. I know that my resolution is correct in simba but I'll check fps. I used criterion within the recommended range but I could try decreasing it. I do have frames where a body part is not visible so using sleap I train pose estimation to toggle visibility in frames where those points aren't present. I didn't apply any smoothing so that could be part of the problem, although the body parts are present in many of the frames that look bad here. Let me know what you think, thank you!

sronilsson commented 8 months ago

Thanks @IsabelleSajonia - that video is very helpful. I think it related to point 3 HERE:

Say you perform outlier correction, but you apply a criterion that is too stringent. SimBA will then remove body-part movements that are true body-part movement, and the animal body-part location predictions can appear to be “stuck” in the video while the animal is actually moving.

If your tracking looks alright in SLEAP, how does the tracking look if you don't apply outlier correction (click the skip button) ?

IsabelleSajonia commented 8 months ago

activity_valid - Trim.zip This looks much better! Should I make criterion much lower for correction or is there a downside to skipping it in general if I'm confident in the tracking data?

sronilsson commented 8 months ago

Yes that looks better, I can see you have some jumps to (0,0) (top left corner for missing body-parts). I don't know if you used interpolation, but you can try using Interpolation body-part nearest to get rid of them and then skip outlier correction. Interpolation is described HERE and there is an image HERE that describes what happens, you can think of the red parts as your missing data.

Often, in pose-estimation, there is some "jitter" - animals are standing still but the pose-estimate body-part location is jumping a few pixels here and there, which can cause some overestimation of the animal movement compared to whatever method Ethovision is using (I don't know how they do it at Noldus, I can't see their code, if you know please let me know). To reduce jitter, you can use smoothing.

IsabelleSajonia commented 8 months ago

I'll look into that thank you!