Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No matching video found when generating grid movie #173

Open
Chap5732 opened this issue Oct 10, 2024 · 9 comments
Open

No matching video found when generating grid movie #173

Chap5732 opened this issue Oct 10, 2024 · 9 comments

Comments

@Chap5732
Copy link

I am runing the kpm pipeline on my deeplabcut analyzed data with 10 individuals' position. When I run the generate grid movie function I encounter such error:

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
Input In [22], in <cell line: 1>()
----> 1 kpms.generate_grid_movies(results, project_dir, model_name, coordinates=coordinates, **config());

File [~/.conda/envs/kpm-oppa/lib/python3.9/site-packages/keypoint_moseq-0.4.9-py3.9.egg/keypoint_moseq/viz.py:1193](http://127.0.0.1:8889/lab/workspaces/auto-H/tree/~/.conda/envs/kpm-oppa/lib/python3.9/site-packages/keypoint_moseq-0.4.9-py3.9.egg/keypoint_moseq/viz.py#line=1192), in generate_grid_movies(results, project_dir, model_name, output_dir, video_dir, video_paths, rows, cols, filter_size, pre, post, min_frequency, min_duration, dot_radius, dot_color, quality, window_size, coordinates, centroids, headings, bodyparts, use_bodyparts, sampling_options, video_extension, max_video_size, skeleton, overlay_keypoints, keypoints_only, keypoints_scale, fps, plot_options, use_dims, keypoint_colormap, downsample_rate, **kwargs)
   1191 if not keypoints_only:
   1192     if video_paths is None:
-> 1193         video_paths = find_matching_videos(
   1194             results.keys(),
   1195             video_dir,
   1196             as_dict=True,
   1197             video_extension=video_extension,
   1198         )
   1199     check_video_paths(video_paths, results.keys())
   1200     videos = {k: OpenCVReader(path) for k, path in video_paths.items()}

File [~/.conda/envs/kpm-oppa/lib/python3.9/site-packages/keypoint_moseq-0.4.9-py3.9.egg/keypoint_moseq/util.py:170](http://127.0.0.1:8889/lab/workspaces/auto-H/tree/~/.conda/envs/kpm-oppa/lib/python3.9/site-packages/keypoint_moseq-0.4.9-py3.9.egg/keypoint_moseq/util.py#line=169), in find_matching_videos(keys, video_dir, as_dict, recursive, recording_name_suffix, video_extension)
    164 for key in keys:
    165     matches = [
    166         v
    167         for v in videos_to_paths
    168         if os.path.basename(key).startswith(v + recording_name_suffix)
    169     ]
--> 170     assert len(matches) > 0, fill(f"No matching videos found for {key}")
    172     longest_match = sorted(matches, key=lambda v: len(v))[-1]
    173     video_paths.append(videos_to_paths[longest_match])

AssertionError: No matching videos found for DEMO1croppedshortDLC_HrnetW32_oppamousetr
ackerAug23shuffle13_detector_250_snapshot_200_individual1
print(list(coordinates.keys()))
['DEMO1croppedshortDLC_HrnetW32_oppamousetrackerAug23shuffle13_detector_250_snapshot_200_individual1', 'DEMO1croppedshortDLC_HrnetW32_oppamousetrackerAug23shuffle13_detector_250_snapshot_200_individual2', 'DEMO1croppedshortDLC_HrnetW32_oppamousetrackerAug23shuffle13_detector_250_snapshot_200_individual3', 'DEMO1croppedshortDLC_HrnetW32_oppamousetrackerAug23shuffle13_detector_250_snapshot_200_individual4', 'DEMO1croppedshortDLC_HrnetW32_oppamousetrackerAug23shuffle13_detector_250_snapshot_200_individual5', 'DEMO1croppedshortDLC_HrnetW32_oppamousetrackerAug23shuffle13_detector_250_snapshot_200_individual6', 'DEMO1croppedshortDLC_HrnetW32_oppamousetrackerAug23shuffle13_detector_250_snapshot_200_individual7', 'DEMO1croppedshortDLC_HrnetW32_oppamousetrackerAug23shuffle13_detector_250_snapshot_200_individual8', 'DEMO1croppedshortDLC_HrnetW32_oppamousetrackerAug23shuffle13_detector_250_snapshot_200_individual9', 'DEMO1croppedshortDLC_HrnetW32_oppamousetrackerAug23shuffle13_detector_250_snapshot_200_individual10']
@calebweinreb
Copy link
Contributor

How are the videos named, where are they stored, and how did you set video_dir in the config?

@Chap5732
Copy link
Author

Hi, here is my video_dir

config()["video_dir"]
'/ssd01/user_acc_data/oppa/deeplabcut/projects/oppamousetracker-Oppa-2024-08-23/analyze_videos/shuffle13/Contact/NosetoNose/croppedshort/track_ellipse'

which includes the analysis result and labeled video from dlc.
image

@calebweinreb
Copy link
Contributor

The problem is that the labeled video from DLC has stuff in the name ("_el_id_p60_labeled") that is not in the name of the keypoint file you uploaded. kpms expects the video names to be prefixes of the keypoint file names.

@IkjotSidhu
Copy link

I am having the same issue in my SLEAP data analysis. My labels are stored in a file named - CS2T_04-18-2024_00-20-05.h5 and the video file is named - CS2T_04-18-2024_00-20-05.mkv. My error says - AssertionError: No matching videos found for CS2T_04-18-2024_00-20-05_track0 . This error does not make sense because my video name here actually contains the keypoint file name as a prefix.
Screenshot 2024-10-10 at 5 09 18 PM
Screenshot 2024-10-10 at 5 09 34 PM

@calebweinreb
Copy link
Contributor

This is because mkv is not included among the default video extensions. To get around that issue you have to pass video_extension="mkv" to noise_calibation (as well as when generating grid movies). You still encounter errors at that point with reading the video (we haven't tested mkv) but we can cross that bridge then.

@IkjotSidhu
Copy link

I just tried adding video_extension="mkv" to noise_calibration as a parameter and it still fails to run. I believe that ".mkv" video format does not work right now.
Screenshot 2024-10-11 at 2 27 23 PM

@calebweinreb
Copy link
Contributor

calebweinreb commented Oct 14, 2024

Hi

I'm sorry the reason it still isn't working is because of a bug on our end. I corrected that bug in the main branch of this repo. If you install from the repo you can make use of the bug fix. I could also release a new version of the package if that would be easier, although before doing so I'd like to confirm that the mkv files will be readable once kpms finds them.

To check the latter, can you run the following?

from vidio.read import OpenCVReader
reader = OpenCVReader("path/to/video/file.mkv")
print(reader[0].shape)

@IkjotSidhu
Copy link

Hi, Sorry for the late response. I ran the command that you shared and I think it is working. The mkv video file appears to be readable now. Please check the screenshot below for reference -
Screenshot 2024-10-16 at 1 35 29 PM

@calebweinreb
Copy link
Contributor

Great. If you update to the latest version of keypoint-moseq (released today) everything should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants