RpiBeh: a multi-purpose open-source solution for real-time tracking and behavior-driven closed-loop interventions in rodent neuroethology

Yiqi Sun,Jie Zhang,Qianyun Wang,Jianguang Ni
DOI: https://doi.org/10.1101/2024.12.02.626497
2024-12-05
Abstract:Background: High-precision behavior tracking and closed-loop intervention are essential for studying the neural basis of cognition and behavior. Existing commercial systems are costly and lack flexibility for customization, while current open-source tools often have limitations regarding real-time functionality, device synchronization, and ease of use. New method: We developed RpiBeh, an open-source, cost-effective, and versatile software tailored for rodent neuroethological research. The software features an intuitive user interface and offers extensive customization options. RpiBeh leverages a Raspberry Pi and camera for video streaming, enabling behavior-driven closed-loop control. Additionally, it provides frame-by-frame video timestamp output to achieve precise synchronization with external devices. For real-time tracking and locomotion analysis, RpiBeh utilizes several novel algorithms and integrated newly developed deep-learning method. Specifically, we introduced two algorithms: a Background Subtraction Method (BSM) for real-time position tracking and a Frame Difference (FD) algorithm for freezing behavior detection. Results: RpiBeh was validated in single animal real-time tracking and locomotion pattern detection, and proved to be flexible and effective for configurating behavior-triggered closed-loop reinforcement experiments including passive place avoidance task and social fear conditioning tasks. Comparison with existing method(s): RpiBeh achieved the same level of tracking and locomotion pattern detection performance by using ANY-maze and DeepLabCut, with advantage in customization and expandability. Conclusions: RpiBeh offers an efficient, affordable, and open-source solution for video tracking and behavioral-driven closed-loop experiments.
Animal Behavior and Cognition
What problem does this paper attempt to address?