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

Successful but then empty CSV upon analysing ROI data #285

Closed neurorie closed 9 months ago

neurorie commented 10 months ago

Describe the bug When analysing ROI data, product is empty csv files

To Reproduce Steps to reproduce the behavior:

  1. Go to 'ROI'

  2. Click on 'Analyze ROI Data: Aggregates'

  3. Initial error: Screenshot 2023-09-08 161956

  4. Manually modified video names in the video_info files to match the shortened video names.

  5. No error given but empty csv files. Also, to check the ROI selection, I need to open csv before manually shortening it.

Screenshot 2023-09-08 162154

Expected behavior Filled ROI analysis data in csv files, which will allow me to analyse data and also to visualise video. When I try to visualise the video, potentially due to the empty csv, this error is given. Screenshot 2023-09-08 162301

Desktop (please complete the following information):

sronilsson commented 10 months ago

Hi @neurorie, thanks for reporting and the screengrabs, very helpful for troubleshooting.

Not sure entirely what is happening but appears to be a mixup between the CSV file names in your project, and the video files names in the project. SimBA uses the names of the videos to get them accurately paired with the respective data files.

Let's say I decide to draw ROIs for video named 10LfamDLC_resent_50_2023_JCRMSPRINT_2000labelled.mp4 and click draw here first:

image

After drawing, SimBA then saves all your drawing information for this video under the name "10LfamDLC_resent_50_2023_JCRMSPRINT_2000labelled" inside the project_folder/logs/measures/ROI_definitions.h5 of your project.

Next, you go on to click on Analyze ROI Data: Aggregates. SimBA loops over each CSV file you have in the project_folder/csv/outlier_corrected_movement_location. Let's say the first file is 10Lfam.csv. SimBA then looks inside the ROI_definitions.h5, for what kind of ROIs you have associated with 10Lfam. In this case there will be no ROIs, because the ROIs you drew are saved under the name 10LfamDLC_resent_50_2023_JCRMSPRINT_2000labelled. If this is the case for all videos, you end up with an empty CSV.

Let me know if this if this could be the reason!

neurorie commented 9 months ago

Hello, thank you for the response!

I have tried opening the H5 file with an online viewer and as I am concerned, there are no csv files. Or should I properly open with a viewer and check the content? Screenshot 2023-09-11 093057

In the project_folder/csv/outlier_corrected_movement_location, I have shortened name listed there with all csv files. Before, when it was working, I remember the shortened name was shown when drawing ROI so I am not sure why there is this discrepancy.

sronilsson commented 9 months ago

Hi @neurorie,

To open the ROI_definitions.h5 file, you can use THIS tool under the heading Extract ROI definitions to human-readable format.

However, this will only allow you to view the information for the ROIs you have drawn (including the video names), not to edit.

I suggest this:

(i) use the tool above to extract the ROI information, to confirm that you have drawn ROIs on videos names e.g., 10LfamDLC_resent_50_2023_JCRMSPRINT_2000labelled.

(ii) If true, then, delete all your ROi definitions with THIS button.

(iii) Rename your video names to be in agreement with file names: e,g., 10LfamDLC_resent_50_2023_JCRMSPRINT_2000labelled.mp4 is renamed to 10Lfam.mp4.

(iv) Redraw your ROIs and analyze your data.

If this is not possible (you have drawn so many ROIs that it would take ages to draw them again), let me know and I will give you code that renames the video names in the ROI_definitions.h5 file.

neurorie commented 9 months ago

Screenshot 2023-09-11 164046 Hello again, I cannot seem to find the button under the tools. My SimBA version is 1.62.3

sronilsson commented 9 months ago

If you update simba by typing pip install simba-uw-tf-dev --upgrade in the windows terminal, do you see it?

neurorie commented 9 months ago

Yes, perfect! I will try it now.

neurorie commented 9 months ago

image I got an error mid-way but I can see some ROI info for rectangle and it seems that I do need to delete ROI and rename the video. For this, I can just change the names in the videos file, right?

sronilsson commented 9 months ago

Thanks for posting the error, very helpful, the error is just a printing error typo by me that I will fix now and does not affect the output.

Yes, just change the video files names directly in the project_folder/videos directory.

neurorie commented 9 months ago

It worked perfectly, thank you so much :)