Customize create_labeled_video: add presence of behavior

Hi,

I have produced a new boolean column in the pandas dataframe (dlc2 output from analyze_videos) that indicates when a behavior is present. I would like to add a rectangle in the upper right corner of the labeled video that changes color depending on the absence or presence of the behavior during that frame. This will provide me with a customized labeled video that will facilitate debugging and adjusting my pipeline. I think this might be a desirable thing to have for other people also.

Since It is just another column in the pandas dataframe I guess one solution is to use the option save_frames of create_labeled_video and then run a piece of matplotlib code that will make the rectangle in all frames, and then produce the video (as suggested by the documentation). But I was wondering if there is a simpler and faster way to do it.

Maybe create_labeled_video can be modified in a future version to include the possibility of passing some code that will be plotted? If this is possible, please give me any idea on how to accomplish this. Also I will be grateful for any other recommendation or workaround.

Thanks!

1 Like

For now, you can edit create_labeled_video here to add another plot: https://github.com/AlexEMG/DeepLabCut/blob/aa5acdc29df9f7c8de968e9f01195674ca49a024/deeplabcut/utils/make_labeled_video.py#L89

I guess you want to do something like case study 7 here: http://www.mousemotorlab.org/deeplabcut; There may be some helper code on DLCUtils, https://github.com/AlexEMG/DLCutils - and I can add the scripts from case study 7 to DLCUtils too…

1 Like

Ok, I will try modifying it, thanks for pointing the code line to me. I will check the case study 7 code once you upload it. Thanks so much!

uploaded! https://github.com/AlexEMG/DLCutils

Hi, I am about to start working on the edit of create_labeled_video. Is there any update that I should consider given that there have been some important updates from the dlc2 of the date I posted this to dlc 2.0.5?

Thanks,

Yes, I would look at 2.0.5 code, thanks!