- Research note
- Open Access
An open-source video tracking system for mouse locomotor activity analysis
BMC Research Notes volume 13, Article number: 48 (2020)
The ability to accurately and efficiently quantify mouse locomotor activity is essential for evaluating therapeutic efficacy and phenotyping genetically modified mice, in particular for the research of neuromuscular diseases. Our objective is to develop a program for video tracking of mice and locomotion analysis.
Here we describe a MATLAB program for video tracking of mice and locomotion analysis. The system is composed of a webcam, an open field, and a computer with MATLAB installed. Animal behavior is recorded by the webcam and the video is then analyzed for mouse position on each frame by a customized MATLAB code. The system has been tested for analyzing two or more mice simultaneously placed in individual chambers. The accumulative moving distance, velocity and thigmotaxis (percentage of time spending in the outer peripheral of the arena, which is commonly used as an index of anxiety) within a test period can be readily obtained. This system can be easily implemented in any laboratory as an in vivo locomotion assay to assess the neuromuscular abnormality of genetically modified animals and the impact of therapeutic interventions.
Measurement of position and locomotion are central to the study of animal behavior, such as novelty exploration, anxiety, spatial orientation and learning/memory. The Open Field Test (OFT) was first described by Hall and Ballachey in 1932  and is still one of the most commonly used assays for monitoring exploratory behavior and locomotor activity in laboratory animals. Moreover, the OFT has been used to assess neuromuscular effects across a variety of experimental paradigms, such as stroke, psychotic effects of drug, stress/anxiety, aging, gender, circadian cycling, neuromuscular diseases of genetic origin, and environmental factors.
Despite its worldwide popularity among the scientific community, the vast majority of research laboratories still rely on commercial systems for recording and analyzing the OFT data. There are two major types of commercial OFT systems, photocell-based  and video-based [3, 4]. Examples of photocell-based commercial systems include Opto-Varimex (Columbus Instruments, OH, USA) and IR Actimeter (PanLab), while ANY-maze (Stoelting Co, IL, USA) and Ethovision® XT (Noldus, Wageningen, The Netherlands) are based on video tracking. These commercial systems are excellent in their recording and analytical capability, however, they are typically provided with specific hardware and software bundled and thus relatively expensive. Moreover, they offer little methodological transparency or flexibility.
Due to the low requirement on the hardware for video tracking as compared to photocell-based systems, it becomes more attractive for the research laboratories to build up their own customized video-tracking system for mouse behavior analysis. Several open source programs have been reported as alternatives to the commercial OFT systems [5,6,7,8,9,10,11,12,13]. These programs can all allow the determination of travel distance and time spent within a defined region-of-interest (ROI). However, their performance varies in terms of simultaneous multi-animal tracking capability, running speed, data output, and capacity for batch analysis.
Here we describe MouseActivity—an open source MATLAB script that offers rapid analysis of locomotion parameters, such as distance travelled, mean speed, thigmotaxis, and stationary fraction. Using a mouse model of Inflammatory Bowel Disease (IBD) and a mouse model of Duchenne muscular dystrophy (DMD), we show that MouseActivity can quantitatively discern differences in movement across an Open Field. The script is freely available at https://github.com/HanLab-OSU/MouseActivity for the scientific community so that it can be tailored and customized for the specific settings and purposes in different laboratories. The script has been tested in MATLAB R2018b under both Windows7 and macOS High Sierra. An executable installer has also been compiled for the macOS system.
Mice (C57BL/6J and B6Ros.Cg-Dmdmdx−4Cv/J) were maintained at The Ohio State University Laboratory Animal Resources in accordance with animal use guidelines. After the final video recording, mice were sacrificed by CO2 inhalation. All animal studies were authorized by the Animal Care, Use, and Review Committee of the Ohio State University.
Establishment of an inflammatory bowel disease (IBD) mouse model
Drinking water containing 3% (w/v) dextran sulfate sodium (DSS, 36,000–50,000 Da, MP Biomedicals, Solon, OH) was given to male C57BL/6J mice at 20 weeks of age for 8 days . The mice were video-recorded before and on day 8 after the initiation of DSS treatment. They were also weighed every day to monitor the body mass change.
Open field setup and video recording
The open fields are composed of one, two or four 12″ × 12″ × 12″ transparent acrylic chambers aligned horizontally or vertically, with each chamber housing a single mouse to be analyzed (see Additional file 1). We have tested our system for analyzing one mouse or two mice simultaneously, but it can be easily modified to analyze more mice simultaneously. Regular mouse bedding can also be included if preferred. A Microsoft Surface Pro 4 Tablet with its built-in rear camera was used to record the mouse videos for behavior analysis. The videos were acquired in the MP4 format with a resolution of 1920 × 1080 pixels at 30 frames per second.
Video processing and data analysis
The video files are processed by a MATLAB script (version R2018b), running on a PC with Microsoft Windows 7 or an Apple MacBook Air computer with macOS High Sierra (version 10.13.6). The MouseActivity code was designed to detect black mice such as C57BL/6J and mdx4cv in a light arena, but it can be easily modified to do the opposite (e.g. light-colored animals in a dark arena). The MouseActivity processes the movie files frame-by-frame continuously or in steps, detects the mice in each frame, determines the position of the mice, and save the data. The MouseActivity source code is freely available at https://github.com/HanLab-OSU/MouseActivity.
Statistical analyses were performed using GraphPad Prism® 5.02 (GraphPad Software, Inc.). Results are expressed as Mean ± S.E.M. The number of independent experiments and the statistical test employed are indicated in the respective figure legends. A p value less than 0.05 was considered to be statistically significant.
Workflow of the MouseActivity
The core of the program (Additional file 2) works by first inverting the grayscale image of each video frame, converting it to binary image based on a user-defined threshold (using the ‘im2bw’ function), removing all connected objects that have fewer than designated pixels (the background noise other than the mouse) from the binary image (using the ‘bwareaopen’ function), and measuring the position/area of the mouse in the binary image (using the ‘regionprops’ function). After finding the position of the animal, the program proceeds to the next video frame. It can also be set to skip video frames using a parameter called “steps”, which has a default value of 3 (meaning every 3rd frame will be analyzed). By identifying the position of the mice on each frame, the software can then compute the movement properties such as traveling distance, average speed and thigmotaxis, and output the data into Microsoft Excel format for image plotting and statistical analysis.
Once started, the program will ask for the selection of a movie file (a sample video file is provided in Additional file 3 for testing) to analyze. It will then pop up a figure showing one of the frames with different thresholding levels (Fig. 1). This gives the user an idea about what threshold may be ideal for the image processing. The threshold setting is critical in image segmentation. As shown in Fig. 1a, increasing the threshold from 0.5 to 0.8 gradually improved the discernibility of the mice from the background noises. To illustrate the importance of setting a proper threshold value on tracking of mouse, we compared the tracking results of a test movie file with a threshold of 0.5 and 0.75. At the threshold of 0.5, both mice were labeled with much larger ovals than the mouse bodies (Fig. 1b, left) indicating that the incorrect identification of the mouse positions. In contrast, at the threshold of 0.75, the color ovals marked each mouse precisely (Fig. 1b, right). The trajectory of each mouse was obviously shifted when the threshold was set at 0.5 (Fig. 1c, left) as compared to 0.75 (Fig. 1c, right).
After clicking the image with the best threshold, the program will ask the user to enter several other parameters including the minimal pixel size of the objects (mice), the number of animals in the movie, the start frame and last frame to be analyzed, and the frame steps to be analyzed (e.g. analyze every “x” frame). The default values for all these parameters can be over-written here by manual input. The minimal pixel size of the mouse is also important for correct identification of the mouse objects. These parameters need to be adjusted according to the video specification.
After completion of the tracking process in all frames, the program will save the tracking data (e.g. the position coordinates and area of each mouse) into a MATLAB file (Additional file 4), and start to analyze the data. This will result in several outputs including a summary figure with mouse trajectory and travel distance (Additional file 5), a figure with the distribution of each mouse area, eccentricity and major axis length (e.g. the mouse body length) (Additional file 6), and an Excel file with the mouse position, travel distance and thigmotaxis (Additional file 7). When both tracking and analysis have been completed, it will ask the user if they want to check the tracking results. If yes is checked, it will pop up a dynamic figure showing each analyzed frame with the mouse labeled by a color oval and number. After completing this process, it will save the tracking movie (Additional file 8) for examination of the tracking accuracy.
Evaluation of mice with IBD
Before the DSS treatment (Fig. 2a), the mean body weight of mice was 26.16 ± 0.47 g (n = 12). During the IBD induction, the mice showed a steady weight loss (Fig. 2c). On the 8th day of DSS treatment, the mean body weight of mice was reduced by ~ 17% to 21.63 ± 0.54 g. We then used the MouseActivity software to analyze the mouse activity changes before and after the induction of IBD in an Open Field recorded in 10-min videos. The mouse trajectory (Fig. 2b) demonstrated that the mice moved much less across the Open Field after the DSS treatment than before the DSS treatment. On average, the mice travelled 26.0 ± 2.1 m in 10 min before the DSS treatment, whereas the total travel distance was significantly decreased to 11.6 ± 2.0 m within 10 min after the DSS treatment (Fig. 2d). IBD induction may also affect the anxiety of the mice. Indeed, we observed that the mice after IBD induction tended to stay longer at the peripheral of the Open Field as reflected by an increased thigmotaxis value (Fig. 2e).
Evaluation of mice with Duchenne muscular dystrophy
Loss of dystrophin in Duchenne muscular dystrophy (DMD) leads to muscle degeneration and regeneration, and impairs the contractile function of muscles . To examine the physical activity of mdx4cv mice, a mouse model of DMD , we recorded 10-min videos of wild-type (WT, C57BL/6J) and mdx4cv mice at the age of 20 weeks in the Open Field and analyzed the videos using MouseActivity. A representative trajectory was shown in Fig. 3a for each strain. Under the basal condition, the mdx4cv mice showed a trend to travel less than WT mice within 10 min (30.8 ± 2.7 vs. 23.0 ± 1.4 meters, not significant) (Fig. 3b). There was no significant difference in the thigmotaxis between WT and mdx4cv mice (Fig. 3c). To examine how the mice respond to stress, we grabbed the mice by the tail and neck skin, and then released them for free, and this was repeated for 5 times before placing them in the Open Field for video recording. Interestingly, this mild stress significantly reduced the average travel distance of WT mice by about half (Fig. 3a), and more dramatic reduction (~ 93.8%) was observed in the mdx4cv mice, which essentially stayed quiet in the corner of the Open Field during the entire observation time window (Fig. 3a–c), indicating that the mdx4cv mice had an increased anxiety after stress.
In this study, we developed a MATLAB program, MouseActivity, as an alternative open-source video tracking system for mouse locomotor activity analysis. This system does not require sophisticated hardware, and can be run on an average personal computer with MATLAB installed. However, the users will be required to build their own Open Field and movie recorder, which are straightforward and can be as simple as placing a rectangular chamber with an overhead webcam (most of Laptop computer has a high-quality webcam pre-installed). The script is currently written to analyze only rectangular Open Field, but can be modified easily to analyze Open Field of other shapes. Another limitation of MouseActivity is that it could not analyze two or more mice placed in a single Open Field, and is incapable of distinguishing the animal’s head from its tail.
Availability of data and materials
All analyzed data during this study are included in this manuscript and its supplementary information files, and the original datasets during the current study are available from the corresponding author on reasonable request. The software codes are publicly available at: https://github.com/HanLab-OSU/MouseActivity.
Duchenne muscular dystrophy
Dextran sulfate sodium
Inflammatory bowel disease
Open field test
Hall C, Ballachey EL. A study of the rat’s behavior in a field: a contribution to method in comparative psychology, vol. 6. Berkeley: University of California Publications in Psychology; 1932. p. 1–12.
Ericson E, Samuelsson J, Ahlenius S. Photocell measurements of rat motor activity. A contribution to sensitivity and variation in behavioral observations. J Pharmacol Methods. 1991;25(2):111–22.
Godden DH, Graham D. ‘Instant’ analysis of movement. J Exp Biol. 1983;107:505–8.
Schwarting RK, Goldenberg R, Steiner H, Fornaguera J, Huston JP. A video image analyzing system for open-field behavior in the rat focusing on behavioral asymmetries. J Neurosci Methods. 1993;49(3):199–210.
Tort AB, Neto WP, Amaral OB, Kazlauckas V, Souza DO, Lara DR. A simple webcam-based approach for the measurement of rodent locomotion and other behavioural parameters. J Neurosci Methods. 2006;157(1):91–7.
Togasaki DM, Hsu A, Samant M, Farzan B, DeLanney LE, Langston JW, et al. The Webcam system: a simple, automated, computer-based video system for quantitative measurement of movement in nonhuman primates. J Neurosci Methods. 2005;145(1–2):159–66.
Ramazani RB, Krishnan HR, Bergeson SE, Atkinson NS. Computer automated movement detection for the analysis of behavior. J Neurosci Methods. 2007;162(1–2):171–9.
Lind NM, Vinther M, Hemmingsen RP, Hansen AK. Validation of a digital video tracking system for recording pig locomotor behaviour. J Neurosci Methods. 2005;143(2):123–32.
Crispim Junior CF, Pederiva CN, Bose RC, Garcia VA, Lino-de-Oliveira C, Marino-Neto J. ETHOWATCHER: validation of a tool for behavioral and video-tracking analysis in laboratory animals. Comput Biol Med. 2012;42(2):257–64.
Samson AL, Ju L, Ah Kim H, Zhang SR, Lee JA, Sturgeon SA, et al. MouseMove: an open source program for semi-automated analysis of movement and cognitive testing in rodents. Sci Rep. 2015;5:16171.
Patel TP, Gullotti DM, Hernandez P, O’Brien WT, Capehart BP, Morrison B 3rd, et al. An open-source toolbox for automated phenotyping of mice in behavioral tasks. Front Behav Neurosci. 2014;8:349.
Perez-Escudero A, Vicente-Page J, Hinz RC, Arganda S, de Polavieja GG. idTracker: tracking individuals in a group by automatic identification of unmarked animals. Nat Methods. 2014;11(7):743–8.
Ohayon S, Avni O, Taylor AL, Perona P, Egnor SER. Automated multi-day tracking of marked mice for the analysis of social behaviour. J Neurosci Methods. 2013;219(1):10–9.
Zhou F, Hamza T, Fleur AS, Zhang Y, Yu H, Chen K, et al. Mice with inflammatory bowel disease are susceptible to clostridium difficile infection with severe disease outcomes. Inflamm Bowel Dis. 2018;24(3):573–82.
Koenig M, Hoffman EP, Bertelson CJ, Monaco AP, Feener C, Kunkel LM. Complete cloning of the Duchenne muscular dystrophy (DMD) cDNA and preliminary genomic organization of the DMD gene in normal and affected individuals. Cell. 1987;50(3):509–17.
Chapman VM, Miller DR, Armstrong D, Caskey CT. Recovery of induced mutations for X chromosome-linked muscular dystrophy in mice. Proc Natl Acad Sci USA. 1989;86(4):1292–6.
We thank the members of the Han lab for technical assistance and fruitful discussion.
RH is supported by US National Institutes of Health Grant (R01HL116546). The funder had no role in study design, data collection and analysis, decision to publish, or preparation of the manuscript.
Ethics approval and consent to participate
All animal studies were authorized by the Animal Care, Use, and Review Committee of the Ohio State University.
Consent for publication
The authors declare that they have no competing interests.
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Additional file 5. A sample summary output after analyzing a video of two mice using MouseActivity. (A) Mouse trajectory showing two mice in their own Open Field. The solid black lines indicate the border of the Open Field; the dash line boxes outline the center area of the Open Field; the space between the solid lines and the dash lines were designated as the peripheral area of the Open Field. (B) The accumulative travel distance of individual mice in 10-min of recording.
About this article
Cite this article
Zhang, C., Li, H. & Han, R. An open-source video tracking system for mouse locomotor activity analysis. BMC Res Notes 13, 48 (2020). https://doi.org/10.1186/s13104-020-4916-6
- Video tracking
- Locomotor activity
- Neuromuscular diseases