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

ROI analysis video quality #296

Open neurorie opened 11 months ago

neurorie commented 11 months ago

Describe the bug When visualising ROI data, the numbers on the video is not readable and the top output is cut Is there a way to fix this? Additionally, if I have generated several ROI analysis (e.g. nose tracking and left ear tracking), how can I check which data is being used to generate the video? Thank you in advance for always being such a great help!

To Reproduce Go to 'ROI'

Click on 'Visualize ROI Tracking'

Initial error: image

Expected behavior Video output with animal tracking based on ROI analysis of the desired bodypart

Desktop (please complete the following information):

OS: Windows 11 Enterprise Python Version Python 3.10.10 Are you using anaconda? Yes

sronilsson commented 11 months ago

Hi @neurorie - thanks for reporting this.

For the first question:

In the back, SimBA tries to guesstimate the best font sizes, text spacings using the resolution of your videos. Sometime this breaks down, particularly when the video resolution is small.

Unfortunately I don't have a graphical interface to control the ROI visualization text attributes, yet, as exist for the classification visualizations. However, you can go into the SimBA code and change and play around with the numbers to get it too look better in your use-case.

(i) First, update simba using pip install simba-uw-tf-dev --upgrade to make sure you are running version 1.74.9 or later.

(ii) Next, you can find out where the SimBA code lives by typing pip show simba-uw-tf-dev:

image

(iii) Go do that directory, and find the folder simba -> utils and open the enums.py in a text editor. On around line 207, you should see some numbers under TextOptions that SimBA uses to scale your text with some descriptions:

image

To start, I recommend decreasing the RESOLUTION_SCALER value, and increasing the FONT_SCALER and see if that solves it. Then save the file, open SimBA, and run it again and let me know how it works and please let me know if you have any issues.

For the second question:

Two days ago, I inserted an additional column in the ROI analysis in response to this issue. The ROI data now contains an additional column which states which body-part you used. Let me know if that solves the problem.

neurorie commented 11 months ago

Thank you, I will give it a try for the first suggestion! I will keep you posted.

The update for showing which body part was analysed is a great addition! Say if we analysed the location for centre, and then the nose, I believe by default creating videos will then create videos of nose (the most recent) ROI analysis. How can I let it create video tracking of other (not most recent) analysis?

sronilsson commented 11 months ago

That makes sense, let me insert some dropdowns so that you can choose, and get back to you.

sronilsson commented 11 months ago

Hi @neurorie - let me know if this is what you are looking for and how it works on your end, after I will update the documentation:

image

Select the number of animals you want to visualize ROI data for (in your case the only option is 1) and select the animal body-part you want to use from the drop-down and click RUN.

You should see it if you update to latest version 1.75.1 with pip install simba-uw-tf-dev --upgrade.

neurorie commented 11 months ago

This is exactly what I meant, amazing, thank you! Such a rapid fix too!

Also if it is possible, can the body part that is being tracked also be mentioned in the video (e.g. Part tracked: nose)? My picture is above, I got the example video from the website screenshot, which shows which body part is being tracked. image image

Lastly, if the changing the size of tag on the animal (the yellow dot) is a easy fix, I would like to know how to do that also!

For the video resolution, RESOLUTION_SCALER 700 and FONT_SCALER 1 works pretty good for me :)

sronilsson commented 11 months ago

Sure, I will insert the the body-part - you may have to play with the RESOLUTION_SCALER and FONT_SCALER again as the text will become longer and may eat in the the counters with the body-part name included.

To change the yellow dot size, change the RADIUS_SCALER, decrease the number to make it smaller:

image
neurorie commented 11 months ago

Hello again, I am realising that there may be a mismatch for chosen body part vs what is being analysed. The picture on the left is SIMBA, on the right is DLC from the same timepoint. I chose to track the nose on SIMBA, labelled in purple on DLC, but it seems to be tracking something else (maybe ear_left as it is the default choice on the "visualise ROI tracking" pop-up. image

sronilsson commented 11 months ago

Hi @neurorie ! Before digging, can we confirm that it is not the same issue as discussed in THIS thread? (only difference is that they have a different pose-configuration)

When you are using one of the in-built default pose-configurations in SimBA, it is expected that you have annotated your body-parts in a specific order, as shown by the numbers in this image:

image

I.e., the first annotated body-part is the left ear, followed by the right ear, and then the nose etc...

If you instead instead have annotated the nose first, then SimBA would put the label "left ear" on the nose data.

Let me know if this could be the case.

neurorie commented 11 months ago

This could very much be the case! Thank you for catching, I will check and get back to you.

sronilsson commented 11 months ago

👍🏻 There is a manual fix for it in THIS response.