Building a smart operant conditioning environment for rat behavioral studies
Fall 2020
This project started in the end of Fall 2019 when I joined the Gluckman group. I was asked to realize a series of smaller projects using cheap electronic sensors and devices, that should have interfaced together through a Raspberry pi (RPi) to have a working smart operant chamber for rat behavioral studies.
The goal of the project was to realize a simple environment for rats and mice with an easy general data aquisition system consisting of:
RPi3 - The brain of the whole system.The RPi as controller of the whole chamber obtained data from each part and integrated it in a .bin file with title and date that was then exported. To read the file it was necessary a secondary program to decode the .bin file and access the information.
The following are the most interesting components of the design explained a little more in depth.
Smart Fountain
The hardware for the smart fountain is set in the following way:
In this way the animal learns to associate the turning on of the fountain with the LED turning on and learns that by pressing the lever, the LED turns on and consequently it can get water.
To prevent an excessive amount of water from being distributed, a limit was added to the total activation time of the fountain each hour.
This is an early sketch that represents the functioning of the hardware.
This video represents my first successes in 2019 when I managed to control the pump for the first time.
The goal of the project was to realize a simple environment for rats and mice with an easy general data aquisition system consisting of:
- Fountain with lever that trains the animal to be used, through techniques of operant conditioning.
- Camera recording in cycles of 1 hour, analyzing the behavior of the animal through simple object tracking techniques.
- Electrode recording through SPI device (ADS1299)
- A controlled light system that artificially simulates day and night cycle.
Design
RPi3 - The brain of the whole system.
The following are the most interesting components of the design explained a little more in depth.
Smart Fountain
The hardware for the smart fountain is set in the following way:
- The fountain in the chamber is powered by a peristaltic pump connected to the Rpi.
- The tube to distribute the water goes from the fountain into the chamber T
- The metal switch which regulates the activation of the pump is attached to the wall of the cage, using a plexiglass wall to protect the electronics.
- Above the lever there is an LED that turns on whenever the fountain is on.
In this way the animal learns to associate the turning on of the fountain with the LED turning on and learns that by pressing the lever, the LED turns on and consequently it can get water.
To prevent an excessive amount of water from being distributed, a limit was added to the total activation time of the fountain each hour.
This is an early sketch that represents the functioning of the hardware.
This video represents my first successes in 2019 when I managed to control the pump for the first time.
Electrode recording - ADS1299
ADS1299 is an amplifier used for neural recordings in biosensing that we were interested in using for real time in vivo measuraments.
Being an SPI device it required to be controlled externally through registers that the Pi could access through a cable. I had to solder an interface to make it stable and prevent the cables from detatching, checking that each pin was receiving the correct signal using a one channel oscilloscope (it was a lot of work).
This image represents the 8 channel module with ADS1299 that records neural activity on the head of the animal, directly connected to the RPi.
Object tracking
An IR-Pi camera is attached to the RPi to record the behavior of the animal over the study period. The video was analyzed in two moments: at the time of the recording (Online) and after the recording (Offline).
- Online analysis
The Online analysis is done in real time by the Pi and consists in creating a grid of regions of interest on the screen and measure the change in the coordinations of the centroid in each region between frames, identifying in this way where and when the animal moves.
The advantage of this method is that we can have a real time quick analysis of the behaviour however with a low resolution and possible inaccuracies due to change in lighting.
- Offline analysis
The Offline analysis is performed on the recorded videos using DeepLabCut, a program that uses Neural Networks to study the movement of the animal.
This is a much more accurate method than the online one, with the only disadvantage of being computationally and time expensive due to the need of training the Network.
Advantages
Compared to other recording systems used for animal behavioral studies, this one is a cheaper option that permits to have a vast general gathering of information. Further, the simplicity in recreating the environment is such that it can be duplicated in wide sets of cages allowing multiple experiments to run at once and delivering precise data ready to be analyzed.