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

Issues importing sleap data #284

Open IsabelleSajonia opened 10 months ago

IsabelleSajonia commented 10 months ago

error Hi, I'm trying to start a new project and import labels from sleap. I tried importing as a .slp file and a H5 file I had. Neither worked and I get the following message. The video and predictions from sleap match, and I put both of these into a new file that just has what I want to import into simba. Any ideas what is wrong? Also why use a .slp file vs H5? I see in the sleap tutorial they say to export predictions as a H5.

IsabelleSajonia commented 10 months ago

Unrelated but I had another question about labeling- when I'm creating a new project there does not seem to be a function to zoom in when I'm labeling body parts on my mouse. We record in somewhat large operant chambers, so the mouse is small in the frame, and this makes the body part nodes much too large to accurately label in Simba. Is there a way I can zoom in?

sronilsson commented 10 months ago

Hi @IsabelleSajonia ! Thanks for posting the screengrab. The video you imported seems to be called eating_3g_pellet_5min (.mp4 or .avi..), but the data file you import seems to be called Sleap_test_08172023.000_eating 3g pellet 5min.analysis. SimBA needs a way of telling which data files goes with which video files, if you rename the files to have the same name, how does it look?

sronilsson commented 10 months ago

When you create a new body-part configuration in SimBA, the image is used for visualization purposes only - it is an image to pair with your pose-estimation body-part schema to show in the menus. It is not used for any calculations, so you do not have to be exact, you can click anywhere!

IsabelleSajonia commented 10 months ago

Ah yes changing the names to match fixed this! And the visualization makes sense I just wanted to make sure this wouldn't cause issues. Thank you.

IsabelleSajonia commented 10 months ago

One last question (sorry I'm just starting to use this and troubleshooting), when I try to extract features I see the following error message: error2 (1)

The outlier csv is in the project folder and I haven't moved anything around but the csv does look empty. I'm not sure what the problem is.

sronilsson commented 10 months ago

Got it - Before extracting features, SimBA wants you to indicate how or if you want to correct outliers:

image

And documented HERE in Step 4. Once you have performed (or indicated to skip outlier correction), the directory project_folder/csv/outlier_corrected_movement_location will be populated with CSV files where the outliers are corrected (or skipped if clicked SKIP). Before you do this step, the project_folder/csv/outlier_corrected_movement_location is empty. The feature extraction looks inside of the project_folder/csv/outlier_corrected_movement_location directory for files to extract features for, in your case it seems to find none.

EDIT: Sorry just saw that you performed outlier correction... do you see any files inside the project_folder/csv/outlier_corrected_movement_location directory or the project_folder/csv/outlier_corrected_movement folders?

IsabelleSajonia commented 10 months ago

No, this directory is empty even though I did run outlier correction and got the "complete" message.

IsabelleSajonia commented 10 months ago

I'm trying outlier correction again now and I get the messages "outlier correction settings updated" and "log for corrected "movement outliers" saved in project_folder/logs. Looking in my logs folder, I do see these csv files but they are empty (no data) other than the column headers (video, animal, body-part, etc.). I do see that my video_info csv is updated so that part did work!

sronilsson commented 10 months ago

When you fix outliers, it is a two step process: first simba looks for any movement outliers and corrects them. Second, SimBA looks for a any location outliers and corrects them. The second part of is noticeably slower, especially if you have a lot of outliers, you can see the elapsed times:

image

In your screengrab, it looks like the only outlier process that ran was the first step (movement outliers). If you check the main Windows terminal, do you see any error msg being printed after the movement outliers are complete?

IsabelleSajonia commented 10 months ago

image I see this error in my terminal.

sronilsson commented 10 months ago

Do you see any CSV files inside the project_folder/input_csv directory?

IsabelleSajonia commented 10 months ago

I do not see anything in that directory

sronilsson commented 10 months ago

👍🏻 Alright. Let's take a step back. The project_folder/input_csv directory is the location where the data ends up once it has been imported into SimBA. It should be a file in there names something like eating_3g_pellet_5min.csv. When you are importing your SLEAP data into SimBA, did you see any errors in the Windows terminal?

IsabelleSajonia commented 10 months ago

Ok yes I think that is the issue I'm trying to import my H5 again and I get the following: image

I am selecting a folder on my desktop that just has the H5 file and the video clip that goes with it (both named the same thing).

sronilsson commented 10 months ago

Alright, do you happen to have a .slp file as well with the predictions?

I noticed earlier that the H5 file had a suffix with .analysis, which I am not too familiar with so just want to make sure the H5 data file actually contains the pose-estimation predictions for the video frames and is not something else related to your SLEAP project.

IsabelleSajonia commented 10 months ago

image Ok I tried the .slp file (and confirmed there are predictions in sleap) and now it is going through the frames but I get this error when it reaches the last one.

sronilsson commented 10 months ago

Almost there! :)

When you selected the type of sleap file you are importing, did you select the .SLP kind from the dropdown?

image

IsabelleSajonia commented 10 months ago

yes I did!

sronilsson commented 10 months ago

Intresting, can you help with two things - if you do pip show simba-uw-tf-dev in the Windows terminal, which version number do you see?

Is there any way you can share the h5 file (not the slp file) it failed with first, and I can take a look whats going on? Maybe through a gdrive or drop it here in the chat if compressed to a zip file?

IsabelleSajonia commented 10 months ago

eating_3g_pellet_5_min.zip eating_3g_pellet_5_min (2).zip The first is the compressed h5 file and the second is the .slp file. And I'm seeing that its version 1.71.6

sronilsson commented 10 months ago

Thanks! I will take a look - in the meantime, you could try and update simba with pip install simba uw-tf-dev --upgrade, I tink latest version is 1.72.2, to confirm that you also see the same error.

IsabelleSajonia commented 10 months ago

I get the error "could not find a version that satisfies the requirement" with that line. For reference I installed simba a week or two ago following the anaconda installation doc

sronilsson commented 10 months ago

Do you have a screengrab or that error msg?

IsabelleSajonia commented 10 months ago

error2

sronilsson commented 10 months ago

gosh sorry forgot a hyphen pip install simba-uw-tf-dev --upgrade

But, I was able to replicate your error! So i can figure out what is going on.

sronilsson commented 10 months ago

The error comes from SLEAP normally having an entry called track_names, for whatever reason, your slp file has no track names. I haven't seen this before.. so we have to insert some code to handle that case.

Can I also ask for the SLP file?

sronilsson commented 10 months ago

... and just fyi watch out for your last body part (tail_3?), it doesn't seem to be tracked very well a lot of missing values.

IsabelleSajonia commented 10 months ago

I think the second zipped file I sent you is a .slp file with predictions. And yes I'm having issues tracking the tail! Our operant chamber has a white floor and it blends in with the tip of this mouse's tail (I struggle to label it myself) so I may need to rethink my skeleton

sronilsson commented 10 months ago

Ah yes of course, let me just make sure it works with that file too and then I will give you updated code.

sronilsson commented 10 months ago

If you run pip install simba-uw-tf-dev --upgrade, giving you version 1.72.3, how does it look on your end?

And I sggest importing the H5 instead of the slp file - it is quicker.

IsabelleSajonia commented 10 months ago

I just updated and used the H5 file and its working now! I can see that I have results in the features_extracted folder's csv. Thanks so much I really appreciate the help!

sronilsson commented 10 months ago

No problem and thanks! I wouldn't have known that the sleap h5 file could look like that if you hadn't let me know and shared the file.

IsabelleSajonia commented 10 months ago

Hopefully one last error- when I go to label behavior I get the following message:

Screenshot 2023-09-01 153414

Could this have to do with tracking issues or is this related to trying to import the video itself? I'm seeing that the csv are now filled so I think everything up until this step is working ok now.

sronilsson commented 10 months ago

Thanks @IsabelleSajonia - no, it's a logging bug I must have introduced earlier in the week. If you update simba again with pip install simba-uw-tf-dev --upgrade, how does it look?

IsabelleSajonia commented 10 months ago

That fixed it I'm able to open the annotation interface now!

sronilsson commented 10 months ago

Excellent, thanks for letting me know. It was a typo of mine including THIS for another user