It was truly a collective team effort at every level, with everyone working and communicating in parallel
Joaquin and Gonçalo want to bring machine learning functionality to the hands of experimental neuroscientists, empowering them to perform unprecedented experiments
This environment supports the development of collaborative projects, founded on unique expertise, that may be difficult to pursue elsewhere

Collaborating toward the next telescope for experimental neuroscience

20 October 2022

By Hyewon Kim

“In neuroscience, we are studying one of the most complicated objects in the universe, the brain, but we still don’t have all the tools required for the questions that need to be asked. We need the equivalent of telescopes, of drones sent to Mars, and big infrastructure to be able to answer these questions,” observed Gonçalo Lopes, founder of NeuroGEARS and collaborator on the recently awarded Biotechnology and Biological Sciences Research Council (BBSRC) grant.

This May, a group of researchers at the Sainsbury Wellcome Centre (SWC) and NeuroGEARS, a creative research group founded by SWC alumnus Gonçalo, were awarded over £700,000 from the BBSRC to implement machine learning techniques in neuroscience experimental control. Joaquin Rapela, research software engineer at the Gatsby Computational Neuroscience Unit (GCNU) and co-investigator on the grant, sat down with Gonçalo to comment on the unique grant submission experience.

Joaquin Goncalo stairs

Gonçalo Lopes and Joaquin Rapela

Capitalising on the unique SWC/GCNU collaborative environment

From investigating how bio-inspired neural networks implement recurrent visual processing strategies (Lindsay et al 2022) and studying how learning and attention affect visual response selectivity (Poort et al 2022), to understanding long-range communication in the brain (Javadzadeh No et al 2022), applying probabilistic tensor decomposition to neural population spiking activity (Soulat et al 2021), and building models for decision-making (Vincent et al 2022) – collaboration between SWC and GCNU has been steadily growing.

These well-established tracks pave the ground for unique collaboration opportunities that can sometimes be hard to imagine in traditional academic settings. Joaquin and Gonçalo collaborate on a regular basis to build hardware, software and data infrastructure for recording 24/7 behavioural and neural activity of mice in naturalistic settings. In the summer of 2021, Joaquin approached Gonçalo about an idea to add machine learning functionality to Bonsai. Joaquin had been excited about Bonsai – its unusual ways of allowing for users to design and record from complex environments. He also understood that Bonsai could greatly benefit from the addition of machine learning techniques to perform intelligent experimental control. He discussed this idea with Gonçalo, who strongly supported it.

To make this happen, the project needed resources, and Joaquin had learned about an opportunity for funding that asked for a piece of software that would be used by a large community. Joaquin took this proposal to Maneesh Sahani, Director of GCNU and Professor of Theoretical Neuroscience and Machine Learning, and Tom Mrsic-Flogel, Director of SWC and Professor of Neuroscience. They both agreed that it was worth applying for the grant. With everyone on board for the ride, Joaquin started to prepare a draft of the proposal.

“As the draft evolved, Maneesh was concerned that the competition for the grant was going to be fierce and that the proposal might not be strong enough for it. He suggested not to submit the proposal at that time, and to submit it to an upcoming call from the BBSRC," recounted Joaquin. Joaquin was not happy with this suggestion at the time. "But in hindsight, Maneesh's decision proved to be very wise. It helped us prepare a better version of the proposal and he identified a funding opportunity better suited to the proposal aims."However, as the summer drew to a close and the autumn nights grew longer, only one week was left until the BBSRC grant application was due. The team, along with SWC and GCNU programme managers Emma Bennett and Ana Saraiva Ayash, met to touch base. “We decided to run a sprint to see if we could make the deadline. And here is where the roller coaster started,” recounted Joaquin. With the help of Gonçalo and Ana, Joaquin prepared a first draft of the BBSRC proposal. But eventually with two days remaining until the grant application deadline, Joaquin and Gonçalo began to feel hopeless about meeting the finish line.

That same evening, Joaquin was leaving the building for the day when he ran into Tom. Tom shared with Joaquin that he had already arranged with Maneesh to work on the grant submission intensively for the next two days. Overnight, the timeline that seemed impossible began to bear fruit. “I was filled with hope, as I knew that with the help of Tom and Maneesh the proposal would be submitted. The six of us met at 10am and worked on the proposal until 2am the next day – when the application was due – to improve the proposal draft, add new proposal sections and summary plots, ask for letters of support, and complete budgets,” recounted Joaquin.

Joaquin Goncalo board 1

Joaquin and Gonçalo discuss the design of a closed-loop experiment in Joaquin’s office

The team met again in the morning to complete the sprint. Maneesh, contributing ideas and masterfully formatting the proposal with his LaTeX expertise, compressed Joaquin’s original draft to meet the eight-page limit while maximising information. Tom, who had obtained five letters of recommendation from leading scientists in just one afternoon, supplemented missing sections of the proposal. Ana and Emma, taking care of the substantial amount of key administrative tasks, kept the whole team on track. Gonçalo, strengthening the proposal with his Bonsai experience, filled in the gaps with external references. The team submitted the application with five minutes to spare.

“It was truly a collective team effort at every level, with everyone working and communicating in parallel,” shared Ana. “There were also a few last minute hiccups (we realised we were missing a letter of support on the morning of the submission) that threatened to derail everything – but again, everyone worked really quickly and effectively.”

The team heard this May that the project will be funded.

External reputation of Bonsai and knowledge transfer through software

The reviews came in two rounds, and the team learned important lessons from each. "The first two reviewers spoke so highly about Bonsai and highlighted in detail several of its unique features, that after reading their reviews I much better appreciated the relevance of our proposed grant contributions," commented Joaquin.

The last reviewer argued that equipping Bonsai with powerful statistical tools could lead to misapplications by users not well trained in statistical subjects. The team appreciated this insight. “For us, that was a very helpful comment, because it allowed us to think about an important aspect of the project besides software development. We were forced to reflect on how to educate Bonsai users to use the new statistical tools well. Statistical software is an accurate means to transfer knowledge, and education is a key element of this transfer,” continued Joaquin. The team proposed workshops and hackathons to explain to Bonsai users the essential characteristics of the provided machine learning tools, in the hopes of helping them better use the tools and prevent misapplications.

Incorporating machine learning

Joaquin and Gonçalo want to bring machine learning functionality to the hands of experimental neuroscientists, empowering them to perform unprecedented experiments. For instance, future experiments could control an animal’s environment not only based on the animal behaviour, but also based on statistical inferences about the animal’s brain state. “We trust that the creativity of experimental neuroscientists, empowered by state-of-the-art machine intelligence functionality, will yield revolutionary findings in neuroscience,” shared Joaquin.

Tools like DeepLabCut for tracking animal behaviour and KiloSort for electrophysiology analysis and cell identification in the brain already use machine learning to achieve their purpose, but they work in a mostly offline framework. Users first run an experiment, but only after this experiment ends they attempt to understand what the data may mean. By contrast, in Bonsai, the team aims to enable users to use machine learning methods during the experiment. “If you can understand something more subtle about what is happening with the animal brain or behaviour while they are being monitored, and you can know that in real time while the animal is behaving, you will be able to do a certain type of experiment – manipulations that you cannot do if you can only know that information after the fact,” explained Gonçalo.

The need to draw a connection between brain and behaviour has also driven the very establishment of SWC. Nobel Laureate Professor John O’Keefe, SWC’s inaugural director, discovered place cells based on a new idea in neuroscience at the time. Because of the complexity of the brain, neuroscientists had chosen to have as many experimental variables under their control as possible, including what was presented to the animal as well as keeping the position of the animals stationary. However, Professor O’Keefe decided to let the animal move freely in an arena while making sense of what was going on in its brain. It was a surprise for the field to find out that it is possible to observe reliable activity in the brain that informs the animal’s location, regardless of what the animal was doing. The neural correlates of this phenomenon, found in the brain’s hippocampus, were coined ‘place cells.’ This experimental approach signalled a paradigm shift in the way that neuroscientists thought about what was required to understand the brain.

“From John O’Keefe’s and others’ discoveries, neuroscientists learned that if an animal is moving around an environment, the overall activity of the brain totally changes. It’s as if you are looking at a totally different brain from that of a head-fixed or anaesthetised animal,” continued Gonçalo. To understand this radically different state of the brain when the animal was moving freely in a constantly changing environment versus being stationary in a fixed laboratory setting, the experimental paradigm had to shift entirely to take account of multiple levels of change in real time and feed the outputs back into the system itself, in what is called a closed-loop experiment.

Closed loop diagram

“What that means is that basically, you need to measure what the animal is doing, what it wants to do, what is changing in the world, and control the loop between those changes that are made by the animal, and changes that are made by the world. And if you can understand where you sit in that loop, it turns out that you can then make environments that adapt themselves to what the animal is doing.” Machine learning functionality in Bonsai will allow for a better understanding of all the variables involved in the design of such complex closed-loop experiments.

The goal is to now use machine intelligence to manage the elaborate data collected at SWC, including electrophysiology recordings, camera tracking, and optogenetic manipulations. “Machine learning techniques can tell you when a mouse enters a certain behavioural or neural state, so you can control an experiment based on the very signals from the mouse’s brain,” Joaquin explained, a feature absent from the current Bonsai language. “As a machine learning researcher, I usually have one day to look at what a large dataset of spikes may mean. With this project, we can provide machine learning researchers with a new type of online dataset that they are not used to.” Joaquin looks forward to seeing how the machine learning community will react to these new types of data, like the new types of images that a powerful telescope can provide. Instead of providing a static high-resolution picture like a telescope, however, the new technology enabled by the grant will behave much like the living brain itself, constantly analysing and trying to understand the world.

A unique collaborative environment

Looking back, Joaquin realises that the unique collaborative environment at SWC and GCNU was essential for the success for the grant proposal. “The proposal idea would not have appeared if Gonçalo, with his expertise in experimental control, and myself, with expertise in machine learning, were not already collaborating,” he explains. Looking back, Joaquin realises the submitted proposal would not have reached its level of sophistication without the expertise of Maneesh and Tom, as well as the letters of support they obtained. Also key was that the reviewers highly regarded Bonsai, and that its creator was a collaborator in the grant.

A communal kitchen at SWC, where many conversations take place, some sparking collaborations

“At SWC/GCNU we are creating a uniquely collaborative environment for neuroscience research, and the success of this grant was possible thanks to this environment,” said Joaquin. “The grant combines advanced neural data analysis methods (GCNU), which will be beta tested with unique neuroscience experimental data (SWC), and integrated into a top-notch technology for experimental control (Bonsai, NeuroGEARS). There are few places around the world where a collaborative grant proposal of this nature can be funded and developed.”

Joaquin contributes to the Research Culture Working Groups at SWC. “It’s important for all to contribute to further develop our research environment,” he said. “In a few years we may be able to say that we contributed to the creation of a new way to do neuroscience. And if this does not happen, we will grow a lot in the attempt. This grant experience demonstrates that any of us at SWC/GCNU (like a PhD student or postdoc) can have an idea, and be supported by our rich environment (including the directors Maneesh and Tom), to develop it to success.”

The speed with which the grant proposal could be submitted was only enabled by the support of SWC and GCNU programme managers Emma and Ana, as well as the everyday environment at both departments to embrace bottom-up collaborative approaches. Joaquin is grateful for the privilege of being surrounded by the resources of this environment. “This environment supports the development of collaborative projects, founded on unique expertise, that may be difficult to pursue elsewhere.”

Learn more about Bonsai

Read the abstract and summary of the recently awarded BBSRC grant ‘Machine Intelligence for Neuroscience Experimental Control’