Close
0%
0%

Rodent Arena Tracker (RAT)

A low-cost system to track and report mouse activity while they are contained in simple arenas.

Similar projects worth following
RAT is a low-cost system to track and report mouse activity while they are contained in a simple arena. The system uses an OpenMV M7 microcontroller to acquire images of the arena and process them in real-time to report mouse centroid data to a text file. This data can be used as a measure of mouse movement (i.e speed and distance traveled) for various activity studies. This project is currently ongoing as we test and perfect the prototypes.

Project Goals:

  • Low-cost rodent monitoring system
  • Tolerance for different room lighting conditions
  • Centroid tracking
  • Standalone device (i.e. does not require additional dedicated hardware)
  • Battery powered option (for up to 1 day)

Constraints:

  • Currently supports tracking for only a single rodent
  • Designed for rodents with black fur
  • White or light colored arena floor/bedding to provide adequate contrast with rodent
  • Requires mounting solution if used with an arena other than the one RAT was designed for
  • Currently supports image acquisition and real-time processing at a rate of 15 fps

Hardware:

RAT is designed to be used with simple open arenas. A separate mounting solution may be required if the device is used with an arena other than the one it was designed for. The device attaches to the lid of the arena using a custom 3d printed bracket. The unit can be powered either with a 5V wired power adapter (via the micro usb port on the OpenMV Cam M7) or with a 5V rechargeable battery via the battery port on the expansion board. 

Methods:

RAT acquires and processes images in real-time using an OpenMV Cam M7 microcontroller. Data is exported to a text file on an attached SD card and real-time feedback is provided via a LCD screen. Near-IR LED illumination is used for experiments and rooms without adequate lighting. Segmentation and centroid processing is accomplished using a combination of thresholds, size filtering, and connected component analysis. The processing for each frame follows the below procedure:

  1. An image is acquired and saved to a frame buffer
  2. The current image is segmented using a set of predefined thresholds
  3. Detected blobs in the image are filtered based on a maximum size threshold and the centroid information for the largest valid blob is retained as mouse data
  4. A mouse speed value is computed using the difference in position between the current and previous image
  5. A feedback image is displayed on the LCD screen including:
    1. A yellow cross painted on the mouse centroid
    2. Mouse centroid and speed values at the bottom of the screen
    3. The name of the text file at the top of the screen
  6. Mouse centroid data is outputted to a text file including a timestamp, centroid values, and computed speed value


Team:

This project was developed by John Krynitsky (coding and hardware) and Lex Kravitz (testing) with input from Ghadi Salem, Marcial Garmendia-Cedillos, and Tom Pohida.

Funding and Terms:

This project was conceived by a team of researchers at the National Institutes of Health (NIH)  and funded by the NIH Intramural Research Program (NIDDK and CIT).

This project is released under the terms of the Creative Commons - Attribution - ShareAlike 3.0 license: 

Human readable: https://creativecommons.org/licenses/by-sa/3.0/ 

Legal wording: https://creativecommons.org/licenses/by-sa/3.0/legalcode

This project uses the excellent OpenMV Cam M7 hardware and screen shield:

RAT_v1.1_tracking.py

Newest version of main Code! RAT v1.1 for OpenMV cam, updated Feb 2020, feature updates include 1) support for an Adafruit RTC breakout, 2) autothresholdnig procedure to account for variance in room lighting, 3) improved output file format with RTC timestamps.

py - 6.86 kB - 06/29/2020 at 18:53

Download

RAT_v1.1_RTPP.py

Variant of the code to run a real-time-place-preference (RTPP) session, updated June 2020

- 7.26 kB - 06/29/2020 at 18:49

Download

RAT_v1.1_setTime.py

A script for setting the RTC chip for RAT v1.1

plain - 1.55 kB - 02/06/2020 at 20:05

Download

RAT_v1.1_w_RTC_breakout.sch

v1.1: Feb 2020 update to the board to include a place to attach Adafruit DS3231 Precision RTC Breakout https://www.adafruit.com/product/3013

- 25.35 kB - 02/06/2020 at 20:03

Download

RAT_v1.1_w_RTC_breakout.brd

v1.1: Feb 2020 update to the board to include a place to attach Adafruit DS3231 Precision RTC Breakout https://www.adafruit.com/product/3013

- 29.60 kB - 02/06/2020 at 20:03

Download

View all 7 files

  • 1 × OpenMV Cam M7 Small, low power, microcontroller board containing GPIO pins, RGB LED, micro SD card slot, and OV7725 image sensor.
  • 1 × LCD Shield A small LCD screen that pairs with the OpenMV Cam M7
  • 1 × Adafruit DS3231 RTC breakout
  • 1 × Li-Ion Battery for RTC P/N 1781 Adafruit P/N 1781
  • 1 × 3D Printed Enclosure

View all 12 components

  • Time-stamps in Excel

    Lex Kravitz07/10/2020 at 19:28 0 comments

    RAT stores the date and time of each sample in the 'DateTime' column using the following format:

    MM/DD/YY HH:MM:SS.mmm

    "mmm" represents milliseconds.  For example, like this: 7/10/20 13:57:29.034

    However, if you open a RAT data file in Excel unexpected things can happen.  My version of Excel defaults to showing just the minutes and seconds, which is not super helpful.


    To show the full data and time, highlight the 'DateTime' column and right click to select "Format Cells".  In the window that pops up, highlight "Custom" as the format and copy/paste the following format into the box called "Type":

    [$-en-US]m/d/yy h:mm:ss.000 ;@


    Excel should now show the full date and time, including milliseconds, for each frame.


  • RAT with the new OpenMV H7 camera

    Lex Kravitz07/10/2020 at 19:07 0 comments

    When we designed the RAT we were using the older M7 camera.  As things go, around the time we finished the design the OpenMV team released the more powerful H7 camera.  We had already purchased ten M7s and they worked so we didn't bother upgrading to the H7.  We were recently asked about compatibility with the H7 camera so we bought one and found that it is drop in compatible in all ways, except the housing we designed does not fit the H7, due to the different dimensions for the removable camera module.  See video below:

  • How to flash code to the RAT

    Lex Kravitz06/29/2020 at 20:20 0 comments

    Here is a short video explaining how to flash code to the OpenMV camera in the RAT

  • Real-Time Place Preference

    Lex Kravitz11/06/2019 at 16:33 0 comments

    In neuroscience research it is often helpful to ask whether and animal will prefer or avoid stimulating a set of brain cells. For example, stimulating cells that make dopamine is highly preferred and animals will spend most of their waking hours stimulating them if given the chance!  

    The RAT can do a simple test of this feature of behavior with a task called a "Real-Time Place Preference" assay.  Here, we programmed the output of the RAT to pulse a brain-stimulation  LED at ~15Hz whenever the mouse moves to one side of a box.  In this way, we can test whether he prefers to spend time on the side that results in brain stimulation, or avoid the stimulation.  We did this with a mouse that expresses a light sensitive protein in a brain structure that receives dopamine, and is also preferred.  Here are photos of the setup and results:

  • Validation using Bonsai for video tracking

    Lex Kravitz04/12/2019 at 23:00 0 comments

    We validated RAT's video tracking ability with an amazing piece of software called Bonsai.  Bonsai is a visual programming language that can do many things, including fast video manipulations and object tracking.  If you haven't seen Bonsai yet you should check it out!

    Our setup recorded the mouse with both a webcam (streaming into Bonsai) and the RAT:

    We exported the X and Y position of the mouse from both systems and looked at how the data lined up (spoiler: incredibly well).  Shown below are correlations of X and Y position from the two systems, plus 3 minutes of X and Y tracking data.  

    Conclusion?  The RAT is good for mice!  

  • Video assembly and instructions

    Lex Kravitz03/29/2019 at 21:01 0 comments

    We recorded a quick video showing how to assemble and use the RAT:


    Updated for v1.1 of the PCB

  • PCB!

    Lex Kravitz03/20/2019 at 03:00 0 comments

    We made a simple PCB that includes a LiPo battery connector, a button for resetting the RAT, and a programmable BNC output that can be set to export speed, test pulses, or even when the animal enters a specific part of the arena, for a real-time-place-preference experiment:

  • Updated the camera housing

    Lex Kravitz03/20/2019 at 02:58 0 comments

    We made a new housing for the camera, complete with a 3D printed tripod thread.  It works great!

  • Hello Tracking World!

    Lex Kravitz11/29/2018 at 23:50 0 comments

    Jonathan finished the first version of the code and we were able to test with a mouse.  The OpenMV cam does a great job in this application.  We are easily able to track mice in both light and dark (thanks to the onboard IR LEDs), and calculate X, Y, and speed in realtime.  Currently these are written to the screen, and to a log file on the SD card, but we are designing a shield for the OpenMV cam that will allow them to be recorded as voltage signals in near-real time.

    Video of RAMS in action:

View all 9 project logs

  • 1
    Assemble Breakout PCB

    Assemble the RAT PCB by soldering the tactile button, right-angle BNC connector, JST right-angle connector, Adafruit RTC breakout, and long male headers to the board.  See a video of the completed electronics here:

  • 2
    ​Assemble the OpenMV Cam M7 into 3D printed housing

    Place the OpenMV electronics into the 3D printed housing

  • 3
    Install OpenMV software

    Download and install the OpenMV IDE (https://openmv.io/pages/download) and download code to run the RAT from the files area.

View all 4 instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates