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

File in Outlier_Movement__Location Folder Not Found for Analysis #294

Open nschapp opened 8 months ago

nschapp commented 8 months ago

When we go to analyze the ROI data, there is no file found in the outlier_movement_location folder. We do not know what file is supposed to be there, but it seems to be required for the process to continue. To reproduce: We imported data and video onto the GUI. We put in video parameters and performed outlier correction and ran it. We defined ROIs, then hit analyze ROI data aggregates (1 animal, body part 1 is set to center, probability threshold set to 0.02). Then we get this error: SIMBA NO FILES FOUND ERROR: No data files found in C:/Users/(username)/sleap/Simba\practice1\project_folder\csv\outlier_corrected_movement_location Expected behavior: should be a file at the given location specified for the error OS: Windows 10 Python: 3.6.13 We are using Anaconda Additional context: the actual folder in question is empty in the directory. We do not know when this exact is created or how it is supposed to get there. Looking for information on that specific issue. Screenshot 2023-10-09 150010

sronilsson commented 8 months ago

Hi @nschapp! After you have imported the data into your SimBA project, it lands in the project_folder/csv/input_csv directory. The next step in SimBA it to perform (or indicate to skip) outlier correction, as documented HERE. E.g., if you click this button:

image

This copies the files in the project_folder/csv/input_csv folder to the project_folder\csv\outlier_corrected_movement_location directory and formats the files into a standard format regardless of the pose-estimation tool you used suitable for whatever operation you want to do in SimBA.

nschapp commented 5 months ago

Hi again. This reply is coming a bit late, but we were unable to resolve the issue. The initial imported data does not appear to be showing up in the project_folder/csv/input_csv directory in the first place. We don't know where the data is going and how/what exactly to move to that location. If we can get the imported data to land there it should be fine. It should be noted that there is no completion message for "import tracking data" step nor an "error this already exists" message when trying to import again.

sronilsson commented 5 months ago

Hi @nschapp! Sorry might have asked before but just checking:

You say there is no completion message for "import tracking data", which makes me think it errors out unexpectedly. Just to confirm, I understand you don't see an error msg in the SimBA window, but do you see any error msg in the Windows terminal that you used to boot up SimBA?

nschapp commented 5 months ago

This appears to be what is seen Windows Terminal after booting up SimBa. image (4)

sronilsson commented 5 months ago

Thanks @nschapp! It seems to have some trouble with your sleap file. It would be easiest and fastest to solve by taking a look at the tracking data file - would you mind sharing the H5 file from sleap? You can zip it up and drag it into this chat (if not too large, if very big, you could share it through a gdrive link)

nschapp commented 5 months ago

https://drive.google.com/file/d/1s9pc1BEbm9I8-WIHHqtRp3lGXCDBAfF3/view?usp=sharing

Here is a google drive link for our H5 file. It is the one we've been using for all of this testing so far.

sronilsson commented 5 months ago

Thanks @nschapp - I can see an h5 file called best_model.h5. I've opened the best_model.h5, and it doesn't look like it contains body-part location predictions for a video file. Rather, it looks like a model file, that you can use within the SLEAP interface, to create the CSV or H5 files which in turn contains predictions for the locations of the body-parts within videos.

Once you create those files (the CSV or H5 files with body-part predictions) using the H5 you just shared, you can import those into SimBA. Let me know if that makes sense.

glinnes12 commented 4 months ago

Hi, I also have issues with importing the tracking data. Not sure though whether the error stems from SLEAP not saving the data as it should (bug on their side) or whether there might be an issue with SimBA importing the tracking data...

I tried importing an SLP file, which I thought was working, but I just noticed this traceback: image

There is also no input_csv file saved afterwards (which is needed for the outlier correction I assume). When I try to continue setting up and loading the project in SimBA, it seems to work up until the outlier correction. After trying to do that I receive the same error message as nschapp reported (SIMBA NO FILES FOUND ERROR: No datafiles found in C:/Users/User/Desktop/simba_test_v11\test\project_folder\csv\input_csv). But that is probably because of this initial traceback when importing the data?

I found this thread and then also tried to import the H5 file instead, but that gives me an error about a video file that cannot be found: image I believe that this person had a similar issue: https://github.com/sgoldenlab/simba/issues/53

Lastly, I also tried importing the tracking data from a CSV file, and doing that, my imported video shows up and I can select the two animals in my video (they don't show any tracking points however, and I am unsure whether they're supposed to...) image

However, after selecting and confirming the two animals shown in the video, I receive the following error message: image

As mentioned before, I think the error could perhaps also be with SLEAP (https://github.com/talmolab/sleap/issues/1681), but this thread and the one linked below from the SLEAP github seem to be the most similar to my issue.

Any help/tips would be very much appreciated :) Thank you!

sronilsson commented 4 months ago

Hi @glinnes12 ! Let me take a look - can you share an example SLP, CSV and H5 file from an example video (together with the video) and I can see whats going wrong?

glinnes12 commented 4 months ago

Hi Simon,

Thank you for your help! I 've uploaded the files on WeTransfer as they are a bit too large to send via email. Here's the link to that: https://we.tl/t-GWjiEXlmYw


From: Simon Nilsson @.> Sent: 16 February 2024 18:22 To: sgoldenlab/simba @.> Cc: glinnes12 @.>; Mention @.> Subject: Re: [sgoldenlab/simba] File in Outlier_Movement__Location Folder Not Found for Analysis (Issue #294)

Hi @glinnes12https://github.com/glinnes12 ! Let me take a look - can you share an example SLP, CSV and H5 file from an example video (together with the video) and I can see whats going wrong?

— Reply to this email directly, view it on GitHubhttps://github.com/sgoldenlab/simba/issues/294#issuecomment-1948941836, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BGGVGPWJO2KPBFMEMT53CDLYT6IV5AVCNFSM6AAAAAA55TLTO2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNBYHE2DCOBTGY. You are receiving this because you were mentioned.Message ID: @.***>

sronilsson commented 4 months ago

Thanks @glinnes12 ! My computer unfortunately blocks WeTransfer, I am not allowed to go there for whatever reason. Could you share it through gdrive?

glinnes12 commented 4 months ago

Of course, here's the Google Drive link: https://drive.google.com/drive/folders/1S7yV9T8XclFAmB7-yPO30G6dgqUzofWK?usp=drive_link

sronilsson commented 4 months ago

Cheers! I've requested access

glinnes12 commented 4 months ago

Done! :)

sronilsson commented 4 months ago

Done! :)

Got it thanks!

sronilsson commented 4 months ago

@glinnes12 I opened the simba_test_v11.csv. This file suggests that the video you have generated predictions for contains at least 53438 frames. There are two animals, so with an optimal sleap tracking model, I would expect to see that simba_test_v11.csv contains 53438 x 2 = 106876 rows with body-part prediction data.

However, simba_test_v11.csv contains 231 rows, meaning that 106876 - 231 = 106645 animals are missing in the sleap prediction data.

When the data is missing, you can try to interpolate the data in SimBA. However, as we have 106645 frames x 8 body-parts = 853160 missing body-parts that would need to be interpolated, that interpolation is going to be very tough and likely interpolated inaccurately

When SimBA finds missing data, and no interpolation is done. It places the body-parts at the top left of the image at coordinate (0,0). If you look closely at the image at the bottom that you sent, where SimBA displays image 1 from the video, you’ll see the body-parts up there stuck on top of each other, as the SLEAP predictions don’t contain any data for this frame and no interpolation is done:

image

I will dig into the slp and h5 files, as you shouldn't be thrown these errors. However, downstream, you will encounter other errors or receive inaccurate results as the data is so sparse and mainly missing. Is there any way to go back to sleap to get accurate body-part predictions for at least the majority of the frames?

glinnes12 commented 4 months ago

Hmmm, this seems really strange! We got pretty accurate predictions in sleap (around 5-6 points in the inference score). The simba_test_v11.slp file should be predictions for 54'044/54'050 frames. the H5 file i cannot open for some reason...I wonder whether only my labelled frames were saved in the csv and H5?

sronilsson commented 4 months ago

Potentially, there are no probability scores associated with the body-part predictions. And the frames that the data contains in general seems to have both animals detected (there are only few frames with only one animal detected), that would be in agreement of these being human labelled I think?

image
glinnes12 commented 4 months ago

yes, this seems to be labelled data and corrected predictions, which is why they don't contain prediction and instance scores either. I must have missed some of the predictions where there's only one animal in the frame.

And the SLP file must then contain all of the computer's predictions, which are the ones we would like to use in SimBA.

sronilsson commented 4 months ago

Let me come back to you a little later to see what happened with the SLP file import.

Just a note on the SLP import as I am not sure if I mention it anywhere in the documentation:

It takes a fair amount of data wrangling to import the SLP data into SimBA compared to the H5 and CSV. I talked to the SLEAP developers some months back, and they helped improve the CSV and H5 import, but not the SLP import into SimBA. I therefore recommend the H5 and CSV over SLP, as it is so much quicker.

sronilsson commented 4 months ago

@glinnes12 - I tried with you H5 file and that imported fine, and seems to contain all data! but one thing to get it to work:

The h5 file is called labels.v002.bottomup.newskeleton.test.slp.240209_114949.predictions.000_simba_test_v11.analysis.h5 while the video file is called simba_test_v11.avi. SimBA needs a way of pairing each data file to the corresponding video file, and it does that by looking at the file names. I renamed labels.v002.bottomup.newskeleton.test.slp.240209_114949.predictions.000_simba_test_v11.analysis.h5 -> simba_test_v11.h5 and then imported it. Can you check if that works on your end?

sronilsson commented 4 months ago

PS. If you want to open and look at the h5, there is a desktop tool called HDFView that can be helpful. To read it in python to look at it, you can do:

import h5py

slp_path = r'/Users/simon/Desktop/envs/simba/troubleshooting/sleap_two_animals/h5_import/simba_test_v11.h5'
sleap_file = h5py.File(slp_path, "r")

## PRINT DATA IN FILE
print(sleap_file.keys())
glinnes12 commented 4 months ago

Collaborator

Renaming the H5 file seemed to work! Thanks a lot :)

sronilsson commented 4 months ago

Thanks @glinnes12! .. PS. Just remembered there should be a function call that automatically detects and renames the SLEAP tracking data file name to match the video name. Not sure why that didn't happen, and I will look into it.