open-source electrophysiology

Open-source, real-time behavior tracking.

Bonsai is open-source software for processing heterogeneous streams of data. It is ideal for real-time video analysis, but it can simultaneously control your experiments and/or acquire data from the Open Ephys acquisition board. Bonsai was developed by Gonçalo Lopes at the Champalimaud Centre for the Unknown. 

Configuring Bonsai is as simple as manipulating graphical elements to create the desired processing pipeline. Each element represents a modular operation on a data stream, which can be connected together to perform complex tasks. For example, Bonsai can be easily configured to monitor the location of an animal in an arena—with or without tracking LEDs.

  • Developed entirely in C# 
  • Uses Microsoft Reactive Extensions (Rx) under the hood.
  • Number of simultaneous operations limited only by your system and hardware
  • Intuitive and easy to understand interface
  • Various algorithms for image and digital signal processing included
  • Each processing step can be independently visualized while the workflow is running


No programming experience required.


Bonsai is a visual programming language that allows you to rapidly prototype custom workflows for processing data streams. A Bonsai workflow begins with a Source, such as a video camera, a microphone, a digital acquisition board, or a stored data file such as a photo or movie (C and K in diagram). Transform nodes (T) let you process incoming data into a new form. Multiplying two numbers, converting between image color spaces, or thresholding a digital signal are all examples of transform operations. Combinator nodes (blue S) represent advanced operators to control data flow, such as managing the timing of events or correlating and merging parallel input streams. A Sink (gray S) specifies useful processing side effects without modifying the incoming data stream. Examples are writing data to a file, turning on a motor, or playing a sound.

Enhanced experimental control.

Have you ever wanted to trigger feedback on behavior, but didn't know where to start? Bonsai makes it easy to take any incoming data stream—be it video, audio, or digital inputs—and create conditional responses to specific events. Now you can deliver reward when a subject presses a lever—but only if it recently came from a particular part of a track. Feedback can be triggered by something as simple as X,Y position within the camera's field of view, or by more complex sequences of activity.

By integrating inputs from the Open Ephys acquisition board, Bonsai becomes even more powerful. You're no longer limited to delivering closed-loop feedback based on behavior OR electrophysiology; Bonsai can accomplish both with ease.

Built with extensibility in mind.

It is very easy to extend Bonsai with your own modules. There is no need to learn yet another API—Bonsai uses Microsoft's standard Reactive Extensions (Rx) under the hood. If you are familiar with programming using Rx or LINQ, you're already good to go. After you've created a new package, just upload it to the NuGet gallery and you will immediately be able to share it with the whole Bonsai community using the integrated package manager. There is also a built-in Python integration module for added flexibility when customizing your processing pipelines.