Sun Yiqi, Zhang Jie, Wang Qianyun, Ni Jianguang
State Key Laboratory of Brain Function and Disorders, MOE Frontiers Center for Brain Science, Department of Neurosurgery, Huashan Hospital, Institutes of Brain Science, Fudan University, Shanghai, 200032, China.
Sci Rep. 2025 Aug 11;15(1):29429. doi: 10.1038/s41598-025-14693-7.
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 inflexible for customization, while current open-source tools are often lack of real-time functionality and suffer from steep learning curve. To address these issues, we developed RpiBeh, an open-source, cost-effective, and versatile software tailored for rodent neuroethological research. The software features an intuitive interface with 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 for precise synchronization with external devices. For real-time tracking and locomotion pattern 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. RpiBeh was validated in single animal real-time tracking and locomotion pattern detection, demonstrating flexibility and effectiveness in configurating behavior-triggered closed-loop reinforcement experiments including passive place avoidance task and social fear conditioning tasks. It achieved the same level of performance in tracking and locomotion pattern detection comparing to benchmark software including ANY-maze and DeepLabCut, with superior customization and expandability. Consequently, RpiBeh offers an efficient, affordable, and open-source solution for video tracking and behavior-driven closed-loop experiments.
The online version contains supplementary material available at 10.1038/s41598-025-14693-7.
高精度行为跟踪和闭环干预对于研究认知和行为的神经基础至关重要。现有的商业系统成本高昂且定制缺乏灵活性,而当前的开源工具往往缺乏实时功能且学习曲线陡峭。为了解决这些问题,我们开发了RpiBeh,这是一款专为啮齿动物神经行为学研究量身定制的开源、经济高效且通用的软件。该软件具有直观的界面和广泛的定制选项。RpiBeh利用树莓派和摄像头进行视频流传输,实现行为驱动的闭环控制。此外,它还提供逐帧视频时间戳输出,以便与外部设备精确同步。为了进行实时跟踪和运动模式分析,RpiBeh采用了几种新颖的算法并集成了新开发的深度学习方法。具体而言,我们引入了两种算法:一种用于实时位置跟踪的背景减法方法(BSM)和一种用于冻结行为检测的帧差(FD)算法。RpiBeh在单动物实时跟踪和运动模式检测中得到了验证,证明了其在配置行为触发的闭环强化实验(包括被动位置回避任务和社交恐惧条件任务)中的灵活性和有效性。与包括ANY-maze和DeepLabCut在内的基准软件相比,它在跟踪和运动模式检测方面达到了相同的性能水平,同时具有卓越的定制性和可扩展性。因此,RpiBeh为视频跟踪和行为驱动的闭环实验提供了一种高效、经济且开源的解决方案。
在线版本包含可在10.1038/s41598-025-14693-7获取的补充材料。