Heron allows you to design complicated experiments significantly faster and importantly it enables you to change them as your ideas change.
While ROS is really difficult at the beginning, it becomes easier to use as you learn it; whereas Bonsai becomes harder as you need to increase the complexity of your experiments. What I wanted to develop was a platform to combine the pros of both...

Developing Heron, the progeny of Bonsai and ROS

3 May 2023

By April Cashin-Garbutt

Taking an idea for an experiment and bringing it to life, from scratch, is no easy feat. But what if there was a platform that enabled you to take your mental schema of any desired experiment and construct the necessary hardware and software in a way that results in a clean, easy-to-understand code base that also deals well with subsequent updates? Developing such a platform became the goal of George Dimitriadis, Joint Gatsby Unit / SWC Research Fellow, and the result of months of hard work are finally paying off.

Solving a challenging problem

From his experience working in several labs, George knew first-hand how time-consuming it can be setting up a completely new experiment from scratch. To go from an idea in an empty room, to a working experimental set-up is challenging.

“Your ideas change so frequently at these early stages, often every couple of weeks. Things happen, some ideas don’t work out, or new ideas come up. These new ideas may only be small changes conceptually, but they can be very difficult to implement practically,” explained George.

This situation is one that many scientists find themselves in and so George decided to set out to develop a new tool that could address these common pain points. His aim was to develop a platform that was easily reconfigurable, while also being able to keep track of changes, and flexibly incorporate new hardware and software within the same project design.

Developing the progeny of Bonsai and ROS

In the robotics field, many people rely on the Robot Operating System, ROS, which is designed to make it as easy as possible for lots of different pieces of hardware to talk to each other. ROS abstracts the connectivity between items of hardware, making it very easy to add or remove new pieces without any knock-on issues. The problem is ROS is mainly built in C++ and so it is not an easy tool for many experimental neuroscientists to use, as they don’t have the required background knowledge and skills.

On the other end of the spectrum is Bonsai, a tool that is very easy for neuroscientists to use and put together simple experiments. Bonsai is graphical and you interact with it through nodes, which makes it straightforward to design experiments. However, Bonsai gets more difficult as the complexity of experiments increases.

“While ROS is really difficult at the beginning, it becomes easier to use as you learn it; whereas Bonsai becomes harder as you need to increase the complexity of your experiments. What I wanted to develop was a platform to combine the pros of both and I was really pleased to find Heron did,” said George.

Line graph showing difficulty of use as experiment complexity increases for Bonsai, ROS and Heron

Introducing Heron

George spent many months developing Heron, a new platform that is easy to learn within a few days but that also allows for increasingly complex experiments without creating spaghetti code.

“Heron allows for hybrid programming. i.e. it has a graphical interface, which behaves a lot like Bonsai, but users can write their own nodes in Python. This means that complexity never becomes unmanageable as experiments can typically be captured using between four to fifteen nodes,” explained George.

In one of his experiments, George has to control a set of synchronised cameras. Instead of achieving this with a large group of predetermined nodes or complex, low level code spread over multiple classes and files, Heron represents the camera group and their controls as a single Node running a few tens of lines of code.

Simple Heron

The benefits of a Python-based platform

George implemented Heron in Python, one of the most commonly used programming languages in neuroscience. He wanted to make sure the platform was easy-to-use as most pieces of hardware come with a Python API. This means that Heron users can write code to connect devices that need to be controlled together, without having to wait for new nodes to be created for them.

“Heron allows you to design complicated experiments significantly faster and importantly it enables you to change them as your ideas change. It uses Python as its main language, which is very accessible,” said George.

Because of the communication in the background, one can use multiple computers with multiple operating systems. In George’s current experiment, he has three computers running three different operating systems spread over two physical machines. Heron enables these all to talk to each other without the need to write connectivity code.

Visualising the flow of information

“One unintended benefit of Heron is that it results in a graph of nodes connected with each other, which provides a practical self-documentation of your experiment. What Heron produces conceptually matches the flow of information in your head, as the nodes are high-level constructs. This allows you to keep track and make changes more easily,” explained George.

Heron is a Knowledge Graph editor, which allows users to easily change the state of an object. This means that it avoids unforeseen consequences of small changes, as each node is only controlled by itself. Therefore, you can make changes to nodes while making sure that nothing else breaks. This is known as the ‘actor-based paradigm’ and is also how ROS is made.

Next steps for Heron

After conceptualising and developing Heron in the Akrami lab at SWC, George is now reaping the rewards of the platform by using it in his experiments. He has also been working with Ella Svahn in the MacAskill lab to try out the platform. A new preprint in bioRxiv outlines three behavioural experiments that showcase different aspects of Heron.

“Ella’s experiment showcases how Heron allows you to see a set of nodes and immediately be able to visualise the timeline of an experiment. The second experiment shows how you can use multiple computers running multiple operating systems and Heron takes care of the network connectivity for you. The last experiment highlights how you can also use Heron with programming languages other than Python, such as a game engines that work on C++ and C#, and how to use Heron to build state machines,” explained George.

“State machines are the heart and soul of a lot of behavioural sciences toolboxes” George expanded, “but they are really a small tip of the iceberg. They often lead to bloated, hard to follow, code when they become the main construction tool. Heron offers users methods to deal with that tip while itself taking care of the rest of the iceberg.” 

The next step for George is to get feedback from the wider Python community. He plans to explore how Heron can be used on other data analysis pipelines and hopes to develop a small community of people working on Heron.

About Heron

To find out more about Heron: