RatInABox: a new toolkit for modelling navigation in the brain
By April Cashin-Garbutt
Modelling navigation in the brain is no easy feat. Researchers often spend months writing code to enable them to study computational questions about how the brain represents the world. But what if there was a toolkit that could simulate animals moving around an environment and model their neural activity?
Developing such a software system became the goal of Tom George, a PhD student at SWC who strongly felt that “people should spend less time writing boring code and more time doing awesome science!” The resulting toolkit, RatInABox, is now available for all to use and has already received over 20,000 downloads.
Simulating synthetic locomotion and neural data
Neuroscientists frequently use synthetic locomotion and neural activity data when studying theoretical questions about the brain. This avoids the need to collect data from real animals and many questions can often be answered with artificially generated datasets.
However, generating realistic artificial data is time-consuming and computationally complex. The lack of a common framework can also lead to issues with standardisation and reproducibility of results. These were strong motivators for Tom and the team to develop the new software programme.
Developing RatInABox
“We built RatInABox to allow researchers to build models of agents exploring 2D environments alongside their spatial representations in the hippocampus, including place cells, grid cells and boundary-vector cells,” explained Tom George.
The Python-based tool allows users to construct 1D or 2D spaces and add agents into the environments. These agents (which can represent rats, or mice, or humans or anything else) can explore the environment under a variety of different motion policies. Users can then add specific neurons, such as place cells, and define different parameters including size, position and firing rate. As the agent explores the environment, the artificial place cells generate data.
To make sure that the toolkit generates realistic locomotion and neural data, the team added parameters that were fitted to real rodent data. For the cell models, they implemented all the most classic computational models that the literature has converged on in the last 15-20 years.
The team hope that RatInABox will enable researchers to build more realistic models. “The current way a lot of modelling is done is to imagine the world like a chess board and you can move around in a clunky, discretised way. For RatInABox, we wanted the world to be simple, but realistic so that motion trajectories, and place cells, are smooth.”
Utilising RatInABox
RatInABox has already been used in many theoretical studies to help answer questions about the statistics of motion, or how place cells or grid cells compare and encode space. Multiple labs at SWC are already using RatInABox as a realistic motion model to replicate trajectories of animals exploring environments to help them understand the underlying neural processes.
“In addition to generating realistic data, RatInABox can also be used to build models of navigation. Neural data can be used to determine the motion of the agent, thereby closing the loop,” continued Tom George.
Experimentalists have been using RatInABox to compare neural data from tasks to many different types of representation. For example, neuroscientists are using the toolkit to determine whether their data is most similar to place cells, or boundary-vector cells and so forth.
“Researchers have been using RatInABox to essentially do comparative analyses between artificial data sets and the real data sets in order to try and understand what type of representations are present in the real data,” explained Tom George.
Impact of RatInABox
From a 3Rs perspective, RatInABox should help to reduce the number of real rats used in experiments as it allows the simulation of locomotion and neural activity.
“If you have a theoretical question you want to ask about grid cells, you don’t necessarily need real grid cells from real rats. So hopefully RatInABox can reduce the need for real rodent experiments in some cases and help make the most out of existing rodent data,” explained Tom George.
In addition to computational and experimental neuroscience, the team have received a lot of interest from researchers studying machine learning, specifically reinforcement learning which often involves policies and finding optimal trajectories through 2D spaces. The team hope that RatInABox can be used to merge more machine learning ideas into neuroscience.
RatInABox as a teaching tool
In addition to research, RatInABox has been used for teaching. The software package is easy to use and visual, so it can be used to plot data and show animations and videos. Tom George has frequently used the toolkit during the computational neuroscience and machine learning summer school he co-organises in Africa, TReND-CaMinA.
“We have found RatInABox to be very useful for teaching spatial representations to students who haven’t encountered these ideas before. In the 2023 summer school, we used RatInABox to teach students about place cells and ideas in machine learning,” commented Tom George.
Open source, community-driven approach
The RatInABox package is entirely open-source so anyone can freely download the source code in full and use it for their research or teaching. While the code is designed to be intuitive, the team have built a range of tutorials to help users learn how to build models with the package.
The open-source nature of the package has also led the project to become community-driven. There is a GitHub where people can request changes, suggest or implement new features and flag bugs. The community can then respond, meaning that RatInABox does not need to be centrally managed.
The team are hoping to expand the package into certain domains and are considering developing a subpackage dedicated to reinforcement learning. They plan to build new features to allow multi-agent analysis and new types of state representation. In the next year, they are looking to make improvements in efficiency and align the style of the tool more closely with other tools in the field. Longer term, the hope is to grow and maintain the package sustainably.
About RatInABox
To find out more about RatInABox:
- Read the paper in eLife, ‘RatInABox: A toolkit for modelling locomotion and neuronal activity in continuous environments’
- Access RatInABox and the tutorials on GitHub, RatInABox
- Find out more about TReND-CaMinA summer school for computational neuroscience