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

info on linked events regarding multiple animals occurring in ROI #291

Closed filos93 closed 11 months ago

filos93 commented 12 months ago

Is your feature request related to a problem? Please describe. First of all, thanks for the tool, it is great and really really useful, it would be fantastic to have the possibility to get combined info and summary data on linked events/actions (time in, time facing, movement in) performed by multiple animals and occurring simultaneously in the ROI domain

Describe the solution you'd like I would like the possibility to combine info regarding multiple animals' actions performed in the ROI with associated ROI CSV files (ROI entry, time, and movement data), for instance, the total sums (s) of animal 1 and animal 2 in ROI or when animal 1 and animal 2 are both facing the ROI or when animal 2 is facing the ROI and animal 1 is in the ROI (disjointed)

Describe alternatives you've considered You can already extract similar info after you append the ROI data to the feature file and the ROIdata### folder and CSV file are generated. There, you can combine the info using the booleans (0-1) regarding the two animals and their actions (in zone, facing zone) associated with the ROI, you can filter and get the total frames where the actions of the two animals are associated and dividing by the frame rate you can get the total time, but it remains very cumbersome and time-consuming (attached a screenshot) Screenshot (806)

Additional context THANKS IN ADVANCE :)

sronilsson commented 12 months ago

Hi @filos93 ! Yes I think I understand. To confirm: you want to compute aggregate summary statistics for multiple Boolean conditionals (e.g., to answer a question: for how many seconds are animal 1 and animal 2 concurrently facing rectangle X)?

We can do this! but won't get to it for a few days. It needs to be flexible to handle cases with more complicated rules to be of any use, and takes a bit of tinkering to get rule selection in graphical interface, but I think we already have the bits and pieces for it.

filos93 commented 12 months ago

@sronilsson yeah exactly that, it would be fantastic to get summary statistics for multiple animals' simultaneous actions in ROI, also when these are disjointed (eg, animal 1 facing ROI and animal 2 in ROI), thanks again for your reply, can't wait to use the new feature

sronilsson commented 12 months ago

@filos93 I did put in the methods, if you update SimBA with pip install simba-uw-tf-dev --upgrade you should see it. I haven't written documentation yet, would be good to get your feedback first:

Untitled

Choose the number of conditions you have in the `#RULES# dropdown.

In the above example, it will output how many seconds, and how many frames, in each video, where the animal called Simon is inside the shape called Rectangle_1 while also facing the shape Polygon_1, while at the same time animal JJ is outside the shape Rectangle_1 and directing towards Polygon_1.

filos93 commented 12 months ago

hey @sronilsson yes it looks great, thank you so much, unfortunately, I could not make it work even when upgrading to the latest version, I didn't understand if that was supposed to work or was just for visualizing it, thanks

sronilsson commented 12 months ago

@filos93 if you upgrade SimBA to the latest version, and launch SimBA, you should see this button with purple font named AGGREGATE BOOLEAN CONDITIONAL STATISTICS under the ROI tab. If you click on it, it brings up the pop-up to the left in the screengrab below:

image

In the # RULES dropdown, select how many conditional rules you have. For example, if you want when Animal_1 and Animal_2 is facing your shape at the same time, set this to 2. Next, set the two behavior drop-downs to Your_Shape Animal 1 facing and Your_Shape Animal 2 facing, and the two STATUS dropdown to TRUE.

Finally click RUN and a summary statistics file should be created in the project_folder/logs directory named something like Conditional_aggregate_statistics_{self.datetime}.csv, let me know how it goes!

filos93 commented 12 months ago

@sronilsson thanks for reply, unfortunately even upgrading I could not make it work, when I hit the "RUN" button nothing happens, no process neither CSV file, in the log file my action is not reported, please let me know if I have to run forced steps before entering the aggregate boolean conditional statistics, thank you so much

sronilsson commented 12 months ago

Hi @filos93 ! MY BAD! Sorry, I had commented out the run command lol, so no wonder... I will fix it and let you know.

sronilsson commented 12 months ago

I think I fixed it, if you run pip install simba-uw-tf-dev --upgrade, so you have version 1.73.9, how does it look?

filos93 commented 11 months ago

hey @sronilsson it works perfectly, everything went smoothly (attached some files) thank you so much, I was also wondering if it's possible to have entry and exit frames for the combined/aggregate information, something similar to what you get in the Detailed_ROIdata###.csv file, this information would give the user the possibility to directly check results accuracy on the video frames, please let me know what you think. Again, thanks in advance :)

Screenshot (824)

Screenshot (825)

sronilsson commented 11 months ago

Hi @filos93 - that's a good point!

If you update simba with pip install simba-uw-tf-dev --upgrade, you should get a second output file names something like Conditional_aggregate_detailed_20231009090249.csv with detailed data like the file below.

Can you let me know if it runs and looks as expected and if the values agrees with your calculations?

Conditional_aggregate_detailed_20231009090249.csv

filos93 commented 11 months ago

@sronilsson it looks fantastic (files in attachment), thank you so much :)

Screenshot (825) Screenshot (826) Screenshot (827)