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

Distance visualisation #299

Open DorianBattivelli opened 11 months ago

DorianBattivelli commented 11 months ago

Hello,

I'm using SimBA 1.75.3 on Windows 10, from ma-DLC data.

I have some doubts about the accuracy of the quantification of distances.

1) Is there a way to visualise live the quantification of distance? When using thee "visualize ROI" function, I do not see the distance, but only thee different ROIs.

2) For now I'm using the smoothing function to reeducxe noise/signal ratio. Do you suggest other tools / strategy?

Thank you

sronilsson commented 11 months ago

Hi @DorianBattivelli!

(i) there is a tool for visualizing ROI features described HERE which should include distances to ROI centers. It should show, for each frame, how far the animals are from the center of each ROI. Let me know how it runs on your end.

(ii) It kind of depends on the noise. The very best way (but also the most time-consuming) is to improve the tracking model, and annotate frames where the model gets the body-parts wrong.

DorianBattivelli commented 11 months ago

@sronilsson thank you for the quick answer. I'm now trying the ROI feature option. I keep you update about the outcome.

Other point: I'm facing issue when trying to run "visualize distance" as reported here:

Screenshot 2023-10-20 alle 19 17 13

Can you identify the error?

sronilsson commented 11 months ago

Yep thanks for reporting this error @DorianBattivelli I appreciate it - I will see if I can replicate.

DorianBattivelli commented 11 months ago

Ok, I fixed the last bug: I had to select a resolution. Still I'm facing a problem when selecting only "create last frame" SimBA prompt returns that corresponding plot is saved in "line plot" folder, but no file is there. Saving works only when I select "create frames" . Is that expected?

sronilsson commented 11 months ago

@DorianBattivelli - which version of SimBA are you running? There shouldn't be a "As input" option and I can't see it in the latest version.

sronilsson commented 11 months ago

No - last frame should create a single image called something like MyVideoName_final_img.png located in /project_folder/frames/output/line_plot.

sronilsson commented 11 months ago

Ah hang on, I could replicate the error when the directory /project_folder/frames/output/line_plot doesn't exist and trying to write the file there, let me see if I can insert a fix.

DorianBattivelli commented 11 months ago

I'm using SimBA 1.75.3 on Windows 10

sronilsson commented 11 months ago

... or it turns out the file isn't saved when "multi-processed" is ticked.

DorianBattivelli commented 11 months ago

Yes in my case I ticked "multi-processed"

sronilsson commented 11 months ago

Yes, it turns out I forgot to pass save_img=True, when multiprocessing. It only stored the final image in memory..

How does it look in version 1.75.4? Thanks again.

sronilsson commented 11 months ago

But there should not be any "As input" option which is a little confusing that you see that... image

DorianBattivelli commented 11 months ago

It works! No "as input" in the list, and file saved with "create last frame" even with multi-processed ticked, thank you :)

sronilsson commented 11 months ago

Tha is for letting me know! Also let me know how the ROI features runs or if there are any issues.

DorianBattivelli commented 11 months ago

O, I realized that the issue for saving persists when I try to generate the last frame for "all the videos" instead of once at a time

sronilsson commented 11 months ago

Ah, thank you! Let's fix that.

sronilsson commented 11 months ago

It should be fixed in 1.75.5 but please let me know, and please let me know if you see any other bugs.

DorianBattivelli commented 11 months ago

Thanks for the fix, I'll try it soon. Meantime, another error/issue I face: I tried to visualize features for one video, but the prompt returns:

Screenshot 2023-10-20 alle 21 55 04

And indeed, on this specific video, Up-HT is not present, but it is for other videos. Is that mandatory to have exactly the same ROIs for all videos of this project to be able to run this command?

sronilsson commented 11 months ago

It appears so! I could remove the requirement. But - the reason it is required is that the function mainly targets people who want to create features from ROIs for building classifiers. In this scenario, it is not possible to create some ROI-based features for some videos, and skip them for other videos.

I can remove it and print a warning instead.

DorianBattivelli commented 11 months ago

Yes it would be nice ;) thank you

DorianBattivelli commented 11 months ago

Also I was wondering, when ploting paths, would that be possible to set an option allowing to choose a frame from the video as background instead of a plain color?

sronilsson commented 11 months ago

Ah thats a good point. Yes I can insert that. I have to do the ROI feature plotting first. It will take a little longer because I realized you can't choose which body-parts to use in the pop-up menu, it says you have to analyze body-parts first which is not particularly good...

DorianBattivelli commented 11 months ago

Not sure to understand, in the path-plot menu, I can choose the BP to plote

Screenshot 2023-10-20 alle 22 47 26
sronilsson commented 11 months ago

Oh no, I mean the ROI feature plotting, where you visualize the distances between ROIs and the animals.

DorianBattivelli commented 11 months ago

Ah I see, instead I suggested frame background for the paths visualisation plots, would this be possible?

sronilsson commented 11 months ago

yes, that's possible we should include it, I let you know when done, but I can't get to it today.

DorianBattivelli commented 11 months ago

Amazing thank you !

sronilsson commented 11 months ago

@DorianBattivelli - before I go on, is this the sort of thing you are looking for:

You can select to use video as background. If you select video, you also get the option to set the opacity of the background (set it to a lower value if you want to make it a little less salient).

image

Right now it takes the first frame of the video as default, do you need an option to take a different frame?

The output looks something like this (I have a troubleshooting project with your name, but I have most likely I mixed up which tracking files belong to which videos).

HybCD1-B2-D6-Urine_final_frame

sronilsson commented 11 months ago

... or is that you want the entire video (updating frames) as background ?

DorianBattivelli commented 11 months ago

@DorianBattivelli - before I go on, is this the sort of thing you are looking for:

You can select to use video as background. If you select video, you also get the option to set the opacity of the background (set it to a lower value if you want to make it a little less salient).

image

Right now it takes the first frame of the video as default, do you need an option to take a different frame?

The output looks something like this (I have a troubleshooting project with your name, but I have most likely I mixed up which tracking files belong to which videos).

HybCD1-B2-D6-Urine_final_frame

This is the solution I need, if it's also possible to select a precise frame it's perfect

DorianBattivelli commented 11 months ago

And by any chance if it's also possible to specify a precise colore for traces from rgb palette it becomes paradise

sronilsson commented 11 months ago

Haha sounds good - something like this also, where you fill in the rgb values if set to Custom and option to set the exact frame index? Hang on, have to write some unit tests through... so users can't insert color crazy number,1999, -123 etc.

... this pop-up menu and methods is getting a life on its on, needs its own documentation page soon lol.

image
sronilsson commented 11 months ago

I included it in the latest version. Let me know if you get any errors or if anything is unclear though.

DorianBattivelli commented 11 months ago

Wo, it is really amazing, thank you very much :)