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
289 stars 141 forks source link

Missing one animal tracking #286

Open DorianBattivelli opened 1 year ago

DorianBattivelli commented 1 year ago

Hello,

I'm using SimBA 1.73.2, on windows, from H5 DLC files.

I'm tracking pairs of mice interacting in 2 adjacent and connected compartments during 600 sec (mice travel from one to the other compartment). To measure the amount of time each mouse has been tracked, I calculate the sum of the time this mouse spent in each compartment. For all my animals, but one, I indeed get around 600 sec. But for one animal I have 0 sec tracked in each compartment. I precise that the other mouse of this pair is tracked for 600 sec as expected.

On DLC, each animal is detected.

On SimBA I run: Interpolation: Bodyafter quadratic Smoothing: Savitzky Golay = 400 Outlier correction: 1 and 2 for movement and location criterion, respectively, using tail baise and nose as referent BPs.

When looking at the output csv files, it looks that both animals are well detecred. Here I attach the csv. files for this pair. The problematic animal is UM. LM is fine.

Can you ideentify what cause the issue?

Thank you :)

Corrected_location-Hyb-B8(urine)-Ph1-T1.2-LS_MS.csv Corrected_movement-Hyb-B8(urine)-Ph1-T1.2-LS_MS.csv INPUT_CSV-Hyb-B8(urine)-Ph1-T1.2-LS_MS.csv

sronilsson commented 1 year ago

Hi @DorianBattivelli - yes I can see the issue, thanks for sharing the CSV file.

Looking at the body-part locations for UM, appears to be stuck in a single location throughout the video (which is the first frame of your DLC tracking data):

UM_Ear_left
UM_Center
UM_Lat_left
UM_Lat_right_1

Some of these body-parts are stuck on large pixel value potentially at the edge of the video (e.g., UM_Center) and also outside of your ROI drawings (pixel 2413, 1967) - and could cause 0 values for entire video.

Something appears to have happened during initial few seconds of tracking which messes up the outlier correction in this video - I can see for example that the DLC tracked UM center (and other body-parts) jumps thousand pixels just during the first few frames of the video:

image

Could there be an experimenter hand in the video or camera moving after the recording has started?

If you clip out the first 1s of the video, then run it through DLC and import it to your SimBA project again, does that fix it?

DorianBattivelli commented 1 year ago

Thank you for answering.

No hand on the video, but indeed on the first frame the tracking of UM (purple dots) is bad: Frame1

But then later on the video, it looks that both animals are well tracked... or I'm wrong?

FrameLater

sronilsson commented 1 year ago

No it does look well tracked - I'd say from frame number 5 and onwards. Not entirely sure why it causes the error: but those initial huge movements in the first 5 frames will be used to calculate the mean movement of the animal in the frames and influence the outlier criterion.

DorianBattivelli commented 1 year ago

Makes sense, I trimed the first sec, and run analysis. I keep you posted,

Thanks!

sronilsson commented 1 year ago

Cheers let me know!

DorianBattivelli commented 1 year ago

So, the results of this video is better but still problematic, cause UM is tracked 174 sec out of 600. Here the files for this new outcome Hyb-B8(urine)-Ph1-T1.2-LS_MS.csv Hyb- [Hyb-B8(urine)-Ph1-T1.2-LS_MS.csv](https://github.com/sgoldenlab/simba/files/12706509/Hyb-B8.urine.-Ph1-T1.2-LS_MS.csv) B8(urine)-Ph1-T1.2-LS_MS.csv

Do you see what is wrong / what fix I could try? Thank you!

sronilsson commented 1 year ago

I will take a look but might take till the beginning of next week - if you visualize the ROI tracking, does that give any idea of what's going on?

DorianBattivelli commented 1 year ago

So running analysis without outlier correction solved the issue, and when I visualize ROI tracking, I find it good. I'll do this to fix tracking with this pair,

Thank you for the tips! Best,