A YOLO-based tool for ROI cropping and movement tracking of Mus musculus.
Project description
Mus Musculus Tracker 🐁
A custom YOLO-based tool for automated mouse (Mus musculus) detection, movement tracking, and manual keypoint labeling.
📋 Features
- Automated Detection: Robust mouse tracking powered by YOLO (v12).
- Video Cropping and Compression: Automatically crops video borders to focus on the arena/cage and compresses them to 640x640 MP4.
- Trajectory Tracking: Extracts movement coordinates and trajectory data.
- Keypoints Labeling: Interactive script to label points
p0..p9on the first frame. - CLI: Command-line interface.
🚀 Installation
Via Pip (Recommended)
pip install mus-musculus-tracker
Via Conda (Development)
gh repo clone juancolonna/mouse-tracker
cd mouse-tracker
conda env create -f environment.yml
conda activate mouse-tracker
pip install -e .
🛠 Usage
1) Basic Use of Mouse tracking (mouse-track)
Run mouse-track with a single video file:
mouse-track path/to/video.mp4
For batch mode, provide a CSV file containing the list of videos (one video per row):
mouse-track path/to/list_of_videos.csv
Use the -y flag to automatically accept confirmation prompts:
mouse-track -y path/to/video.mp4
or, in batch mode:
mouse-track -y path/to/list_of_videos.csv
2) Keypoints labeling (keypoints-labeler)
The keypoints_labeler.py script reads a CSV list of videos, opens the first frame of each video, and requests manual selection of the 10 keypoints (p0 to p9).
keypoints-labeler path/to/video_list.csv path/to/output_keypoints.csv
Expected video_list.csv format:
- No header.
- One video path per line.
- Only one column is used.
Example video_list.csv:
/data/exp01/video_001.mp4
/data/exp01/video_002.mp4
Output (output_keypoints.csv):
path_and_filecolumn with the original video path.p0_x,p0_y,...,p9_x,p9_ycolumns.
Labeling behavior:
- Left-click to select the current point.
- Any key (e.g.
ESC) other thanq/Qmoves to the next point. - If you advance without clicking (e.g. press
ESCtwice without a mouse click), the current video is skipped. qorQaborts the batch process.
Point order:
p0is the center.- Points
p0 -> p1 -> p2go from the center toward the lid. p3..p9follow a counter-clockwise order according to the figure.
3) Batch Tracking Mode (mouse-track)
For processing multiple videos with pre-labeled keypoints, use a CSV file containing video paths and their keypoints:
mouse-track -y path/to/keypoints_list.csv
Expected keypoints_list.csv format:
- Header row:
path_and_file,p0_x,p0_y,p1_x,p1_y,...,p9_x,p9_y - Each subsequent row: video path followed by 20 numeric values (x,y pairs for p0-p9)
Example keypoints_list.csv:
path_and_file,p0_x,p0_y,p1_x,p1_y,p2_x,p2_y,p3_x,p3_y,p4_x,p4_y,p5_x,p5_y,p6_x,p6_y,p7_x,p7_y,p8_x,p8_y,p9_x,p9_y
/data/exp01/video_001.mp4,320,240,315,235,310,230,325,245,330,250,335,255,340,260,345,265,350,270,355,275
/data/exp01/video_002.mp4,320,240,315,235,310,230,325,245,330,250,335,255,340,260,345,265,350,270,355,275
This mode automatically crops and tracks all videos in the list without manual interaction. The script will prompt for confirmation before starting the batch process.
📑 Requirements
- Python >= 3.13
ultralyticsopencv-pythonmoviepytqdmnumpy
✍️ Authors
Juan G. Colonna juancolonna@icomp.ufam.edu.br
Instituto de Computação
Universidade Federal do Amazonas
📄 License
This project is licensed under the MIT License. See LICENSE for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mus_musculus_tracker-0.1.6.tar.gz.
File metadata
- Download URL: mus_musculus_tracker-0.1.6.tar.gz
- Upload date:
- Size: 4.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a554c7ebc4e17cdeb7b91bd61743d32d146a37998046723cb34fec86d3ec07d1
|
|
| MD5 |
61a1dbc58c334b4259a986352999941f
|
|
| BLAKE2b-256 |
eb769a92b92b67d8cff206933647beff763bc83bd7a702a9aaf835650996ea6f
|
File details
Details for the file mus_musculus_tracker-0.1.6-py3-none-any.whl.
File metadata
- Download URL: mus_musculus_tracker-0.1.6-py3-none-any.whl
- Upload date:
- Size: 4.9 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9acbb68ec507c4571616d3c571bb60ef02d2617beee5a2e25c37158ff6718a4c
|
|
| MD5 |
2bb31b93e723e3b2640355cb64b64641
|
|
| BLAKE2b-256 |
a8eed04085807e9e8bb8202b84e2113ae21555cfa9d1ad91754e5aff7b989dc9
|