Visual Reactive Programming with Bonsai

This training course will introduce you to the basic concepts of data acquisition and behavioural control using the Bonsai visual programming language.

Course Schedule

Tuesday Wednesday Thursday Friday Monday
Seminar Introduction to Bonsai Reactive Operators Higher Order Operators BonVision Wrap-up
Recap Object Tracking Data Synchronization State Machines
Workshop Acquisition and Tracking Closed-loop experiments Operant behavior Visual environments Final projects

Day 1 - Introduction to Bonsai

  • Introduction to Bonsai. What is visual reactive programming?
  • How to measure almost anything with Bonsai (from quantities to bytes).
  • How to control almost anything with Bonsai (from bytes to effects).
  • Real-time tracking of colored objects, moving objects and contrasting objects.
  • Measuring behavior using voltages and an Arduino.

Day 2 - Real-time closed-loop experiments

  • Data synchronization and measuring closed-loop latency.
  • Conditional effects. Triggering a stimulus based on video activity.
  • Continuous feedback. Modulate stimulus intensity with speed or distance.
  • Feedback stabilization. Record video centered around a moving object.
  • Real-time markerless pose tracking using Bonsai + DeepLabCut and Bonsai + SLEAP.

Day 3 - Operant behavior tasks

  • Creating dynamic observable sequences with higher-order operators.
  • Modeling trial sequences: states, events, and side-effects.
  • Driving state transitions with external inputs.
  • Choice, timeouts and conditional logic. Building reaction time and Go/No-Go tasks.
  • Best practices for composing complex workflows.

Day 4 - Interactive visual environments

  • Creating and controlling visual environments with BonVision.
  • Building closed-loop virtual reality experiments.
  • Combining real-time and non real-time logic.
  • Building variable trial structures.
  • Logging stimulus and response outcomes.

Day 5 - Wrap-up

  • How to extend Bonsai with scripting.
  • Reproducible deployment and versioning of experiments.
  • Interfacing Bonsai with Python and MATLAB.
  • Bonsai hackathon and project presentations.
  • Closing remarks.