dattalab / keypoint-moseq

https://keypoint-moseq.readthedocs.io
Other
68 stars 28 forks source link

Issue with grid movies #37

Closed banchan86 closed 1 year ago

banchan86 commented 1 year ago

Hi caleb, we are running into an issue with the grid movies being really cropped and not showing any of the keypoints or the full frame image but crowd movies look fine image

We are running kp.moseq 0.1.0 on faces of headfixed animals (the same dataset i have been posting about this is Shawn from the stowers lab btw just switching to my own github account :) )

calebweinreb commented 1 year ago

You can use the window_size parameter to increase the window for grid movies. E.g. if your videos are 640px by 480px, you could use window_size=640 or something.

kpms.generate_grid_movies(name=name, project_dir=project_dir, **config(), window_size=640)
banchan86 commented 1 year ago

Hey caleb thanks for closing the issue yea I dont believe its a problem on kp-moseq end anymore but just wanted to add an update in case anyone runs into the same issue. It turns out that our movies were too big (1280x750) and playing around with the window size couldn't fix it ( as the full window size was too big to generate movies with our GPU) and downscaling the original video specifically for generating grid movies also didnt work, so we are starting from scratch downscaling the movies before putting them through the pose estimation.

calebweinreb commented 1 year ago

Hmm that seems like a very drastic solution! I can just add a downscaling option to the grid movie function... in fact I just did. In the new grid movies function, the window size is set automatically based on the size of the animal (so hopefully you no longer have to set it explicitly). I also added a max_video_size parameter that will limit the total size of the grid movies by downscaling the videos if necessary. You can use the new function by installing the dev branch:

pip install -U git+https://github.com/dattalab/keypoint-moseq@dev

and then generate grid movies with

kpms.generate_grid_movies(
    name=name, 
    project_dir=project_dir, 
    coordinates=coordinates, 
    max_video_size=1920,  
    **config())

Note that because of some other changes in the dev branch, the data-loading functions now output a list of bodyparts. So you will have to update those lines to avoid getting an error:

# if you're using dlc
coordinates, confidences, bodyparts = kpms.load_deeplabcut_results(dlc_results)

# if using sleap
coordinates, confidences, bodyparts = kpms.load_sleap_results(sleap_results)

Give it a try and let me know how it goes!

banchan86 commented 1 year ago

hey caleb wow thanks for the fast response, amazing work as always, it works like charm (and saves us a lot of time lol)!

just a minor issue i fixed quickly I ran into a " No module named 'tabulate' error while importing keypoint_moseq so probably need to update the dependencies

calebweinreb commented 1 year ago

Awesome! will update the dependencies