Skip to main page content
U.S. flag

An official website of the United States government

Dot gov

The .gov means it’s official.
Federal government websites often end in .gov or .mil. Before sharing sensitive information, make sure you’re on a federal government site.

Https

The site is secure.
The https:// ensures that you are connecting to the official website and that any information you provide is encrypted and transmitted securely.

Access keys NCBI Homepage MyNCBI Homepage Main Content Main Navigation
. 2021 Mar 31:15:647640.
doi: 10.3389/fnbeh.2021.647640. eCollection 2021.

New Open-Source Tools: Using Bonsai for Behavioral Tracking and Closed-Loop Experiments

Affiliations

New Open-Source Tools: Using Bonsai for Behavioral Tracking and Closed-Loop Experiments

Gonçalo Lopes et al. Front Behav Neurosci. .

Abstract

The ability to dynamically control a behavioral task based on real-time animal behavior is an important feature for experimental neuroscientists. However, designing automated boxes for behavioral studies requires a coordinated combination of mechanical, electronic, and software design skills which can challenge even the best engineers, and for that reason used to be out of reach for the majority of experimental neurobiology and behavioral pharmacology researchers. Due to parallel advances in open-source hardware and software developed for neuroscience researchers, by neuroscience researchers, the landscape has now changed significantly. Here, we discuss powerful approaches to the study of behavior using examples and tutorials in the Bonsai visual programming language, towards designing simple neuroscience experiments that can help researchers immediately get started. This language makes it easy for researchers, even without programming experience, to combine the operation of several open-source devices in parallel and design their own integrated custom solutions, enabling unique and flexible approaches to the study of behavior, including video tracking of behavior and closed-loop electrophysiology.

Keywords: behavior; neuroscience; open source; software; visual programming.

PubMed Disclaimer

Conflict of interest statement

GL is director at NeuroGEARS Limited. The remaining author declares that the research was conducted in the absence of any commercial or financial relationships that could be construed as a potential conflict of interest.

Figures

Figure 1
Figure 1
The canonical model for the interaction between a behavioral subject and its environment. The agent receives information about the state of the environment through a variety of sensors and can control the state of the environment through the use of actuators. Actions are chosen to minimize the difference between the perceived state of the world and the intended state of the world. The amount by which this difference is reduced is also sometimes referred to as the utility of an action.
Figure 2
Figure 2
Bonsai workflow for recording video from a single camera.
Figure 3
Figure 3
Bonsai workflow for correlating video from two cameras simultaneously.
Figure 4
Figure 4
Bonsai workflow for tracking the position (centroid) of a single animal in a well-lit arena, assuming a simple contrast threshold (black on white background).
Figure 5
Figure 5
Bonsai workflow for dynamic cropping of a region of interest around the center of the animal.
Figure 6
Figure 6
Bonsai workflow for tracking a specific body part using the Bonsai-DLC package.
Figure 7
Figure 7
Schematic of the shuttling box apparatus. Animals will forage for liquid reward in this environment, either sucrose or water if using water restriction, and will readily shuttle between the two ports (adapted from Lopes et al., 2016).
Figure 8
Figure 8
Bonsai workflow for controlling a single Arduino digital output.
Figure 9
Figure 9
Bonsai workflow for triggering a digital output based on a region of interest.
Figure 10
Figure 10
Bonsai workflow for triggering a digital output based on movement.
Figure 11
Figure 11
Closed-loop patch-clamp experiment with Bonsai (contributed by Gonçalo Lopes, André Marques-Smith, Luis Jacinto, and Patricia Monteiro [unpublished]).
Figure 12
Figure 12
Bonsai workflow for measuring the distance between the two largest objects.

Similar articles

Cited by

References

    1. Aharoni D., Hoogland T. M. (2019). Circuit investigations with open-source miniaturized microscopes: past, present and future. Front. Cell. Neurosci. 13. 10.3389/fncel.2019.00141 - DOI - PMC - PubMed
    1. Carvalho F., Lopes G. (2019). Neurophotometrics. Available online at: https://github.com/neurophotometrics/neurophotometrics.
    1. Castelhano-Carlos M. J., Baumans V., Sousa N. (2017). PhenoWorld: addressing animal welfare in a new paradigm to house and assess rat behaviour. Lab. Anim. 51, 36–43. 10.1177/0023677216638642 - DOI - PubMed
    1. Douglass A. M., Kucukdereli H., Ponserre M., Markovic M., Gründemann J., Strobel C., et al. . (2017). Central amygdala circuits modulate food consumption through a positive-valence mechanism. Nat. Neurosci. 20, 1384–1394. 10.1038/nn.4623 - DOI - PubMed
    1. Dreosti E., Lopes G., Kampff A. R., Wilson S. W. (2015). Development of social behavior in young zebrafish. Front. Neural Circuits 9:39. 10.3389/fncir.2015.00039 - DOI - PMC - PubMed

LinkOut - more resources