Jun 29, 2026

Open Field Activity Monitoring Processing Protocol

  • Kaitlin Southern1,
  • Jacob Griffith1,
  • Kyle Allen1
  • 1University of Florida
  • OrthoBME Lab Rodent Behavior Protocols
Icon indicating open access to content
QR code linking to this content
Protocol CitationKaitlin Southern, Jacob Griffith, Kyle Allen 2026. Open Field Activity Monitoring Processing Protocol. protocols.io https://dx.doi.org/10.17504/protocols.io.dm6gp4w5pgzp/v1
License: This is an open access  protocol  distributed under the terms of the  Creative Commons Attribution License,  which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited
Protocol status: Working
We use this protocol and it's working
Created: June 29, 2026
Last Modified: June 29, 2026
Protocol  Integer ID: 320013
Keywords: open-field activity, preclinical models, centroid tracking, extracting quantitative locomotor parameter, open field activity monitoring processing protocol, quantitative locomotor parameter, analysis of rodent behavior, centroid tracking, rodent behavior, background subtraction, acceleration
Funders Acknowledgements:
National Institute of Health
Grant ID: UC2AR082196
Abstract
This protocol describes a reproducible workflow for extracting quantitative locomotor parameters—position, velocity, and acceleration—from open‑field activity‑monitoring videos captured with standard webcams. The method employs background subtraction and centroid tracking implemented in MATLAB, enabling automated, high‑throughput analysis of rodent behavior.
Materials
MATLAB Files Needed:
- activity_batch_’studyname’
- batch_script_’studyname’
- centroid_data_saver
- running_centroid_metrics_calculator_v2
MATLAB Setup
Open MATLAB
Set the path. Home > Set Path > Add with Subfolders. Choose your folder that contains your activity monitoring videos. Click Save.
Set the same path location in the ‘Current Folder’ panel on the left. This is where all generated files will save.
Create an additional folder in this location named ‘Processing’.
Create Boxed Bounds for Each Activity Cage
To create bounds for the left cage, load the right calvid video into MATLAB in the Command Window.
filename = ‘RJ_Aging_24moM_RightCalvid.mkv’ *your calvid video name
Create an image from the video.
v = VideoReader (filename)
image = read (v, 60)
imshow (image)
An image should, pop up. Select the Data Tips in the top right corner of the image.
Click the top left corner of the Left Arena box. Record the [X, Y] coordinate.


Repeat this process for all corners of the box.
The Y coordinates of the top two corners should be equal. The Y coordinate of the bottom two corners should be equal.
The X coordinates for the left bounds should be equal. The X coordinates for the right bounds should be equal. Example: top left (210, 248), top right (477, 248), bottom right (477, 507), bottom left (210, 507). This will create a square.
Define the bounds of the left box (cam_1_box) in the Command Window using your coordinate. The X cooridnates followed by the Y coordinates in order from the top left corner to the bottom left corner (in a circle)
cam_1_box = roipoly (image, [x1 x2 x3 x4], [y1 y2 y3 y4]);
Example: cam_1_box = roipoly (image, [210 477 477 507], [248 248 507 507]);
Using imshow (cam_1_box) in the Command Window, you should see a white box from the X and Y coordinates you selected.


Segment this box from the image in the video.
cam_1_bw = uint8(cam_1_box).*image;
imshow (cam_1_bw) to see the final box around the arena floor.


Complete the same process, defining the right box (cam_2_box, cam_2_bw), using the Left Calvid video.
filename = ‘RJ_Aging_24moM_RightCalvid.mkv’ *your calvid video name
v = VideoReader (filename)
image = read (v, 60)
imshow(image)
cam_2_boxm= roipoly (image, [x1 x2 x3 x4], [y1 y2 y3 y4]);
imshow(cam_2_box)
cam_2_bw = uint8(cam_2_box).*image;
imshow(cam_2_bw)
Once both of your boxes are defined. Create an image combining the two boxes in the command window.
im_comb_calvid = cam_1_bw + cam_2_bw
imwrite (im_comb_calvid, “24moMBackground.tiff”) *your group name
View the tiff file to ensure both arena floors are boxed correctly and visible.


Modify Activity Script
Open activity_batch_studyname (rename for your study). Ensure the file is saved in the Processing folder in your path.
On line 1, change the name of the function to activity_batch_studyname
Example: function [] = activity_batch_24moM(filename,fps,group_name)
On line 22, update im_med_2 with your tiff file.
im_med_2= imread (24moM_Background.tiff’); * with your tiff file
In lines 33 and 34, enter the X and Y coordinates from your left and right boxes.
cam_1_box = roipoly(im_combined,[x1 x2 x3 x4], [y1 y2 y3 y4]);
cam_2_box = roipoly(im_combined,[x1 x2 x3 x4], [y1 y2 y3 y4]);
After these lines are modified, load a file into the command window to ensure the file is working. In the command window:
filename = ‘RJ_Aging_24moM_Cohort1_Activity.mkv’ v= VideoReader (filename)
fps= 30
ijk= 3000
Run lines 11 -22
Run lines 27-86
In the workspace open centroid_x_1 by double clicking. Scroll down to 3000 (your ijk value), and there should be a value there. If there is not a number there, something is wrong.
Check for typos, etc.
Run Batch Script
Open batch_script. Ensure it is saved in the Processing folder in the path.
The number of lines will depend on how many videos you have in this collection period. The following lines are used to run one video through the activity_batch file.
disp('Now starting Cohort-01')
tic
activity_batch_24moM('RJ_Aging_24moM_Cohort1_Activity.mkv', 10,'24moM_Cohort-01') *Name your video and cohort
disp('Finished processing Cohort-01')
toc
You will repeat these lines over again with additional videos and cohort names. This is for 7 videos (7 cohorts).


After all of your videos are in the file, click Run
This may take several hours. Running this file will output a MATLAB data workspace file for each video in your Current Folder.
Combine Data using Centroid Data Saver
Open centroid_data_saver. Ensure it is saved in the Processing folder in the path.
Double click on the first Cohort workspace from the Current Window panel. You should see the variable populate in your workspace.
In the file change line 2 and line 6 to the name of your cohort. Leave the -01 and -02 to separate the centroid data from the left and right arenas.
In the command window define data_combined as an empty array.
data_combined = []
Run lines 1-14.
Complete the same process for each video, without remaining data_combined.
Double click on Cohort 2.
Change line 2 and 4.
Run lines 1-14.


Change line 16 to save the data file with your desired study name.
save('Filename.mat','data_combined')
On the last Cohort Run all.
Be sure to not run a video twice or skip a video. If so, the process will need to be re-done, defining data_combined = [].
Once completed, you should see the Data file in your Current Folder.
Create Output Files and Figures
Create a master excel document from your videos using column headings: Group_ID, Video (path), Animal_ID, Sex, Age (months). In the case below, there was not a rodent in the right cage of Cohort 7, see NA.


Open Running_centroid_matrics_calculator_v2
Change line 5 with the name of the output MATLAB file from the last step.
Similar on line 7, however add '_diary'.
Add the name of your master excel spreadsheet above on line 17.
Lines 50 and 51 may need to be updated based on your camera placement.
Edit lines 265, 269, 273, to include your study name, leave 'combined_values.csv', 'combined_time_series.csv', and interval_time_series.csv' so you can differentiate between the output files.
Within your Processing folder create a Plots folder. Within the Plots folder create folders 1) Position and 2) Velocity_and_Acceleration.
Within your Processing folder create another folder titled Data_outputs_csv.
Ensure all of these folders are in your path.
Once all file names are updated, click Run.
Plots will be outputted in the 'Plots' folder, output csv files will be located in the 'Data_outputs_csv' folder.