A comprehensive Python program for analyzing mouse behavior in behavioral experiments. Supports three major experimental paradigms: Open Field Test (OFT), Social Avoidance Test (SAT), and Forced Swim Test (FST).
- Open Field Test (OFT): Analyzes center zone time, locomotor activity, and exploratory behavior
- Social Avoidance Test (SAT): Measures interaction zone time and avoidance behavior
- Forced Swim Test (FST): Detects and quantifies immobility periods
- Lens distortion correction
- Perspective transformation for accurate measurements
- Real-time tracking visualization
- Automated mouse detection and tracking
- Excel summaries with statistical analysis
- CSV trajectory data export
- Graphical visualization of results
- Heatmaps and movement plots
- Python 3.7 or higher
- OpenCV (cv2)
- NumPy
- Matplotlib
- openpyxl
- tkinter
- scipy
- Run the main program:
python main.py- Follow the GUI workflow:
- Select experiment type (OFT/SAT/FST)
- Choose video file
- Set analysis frame range
- Configure perspective transformation
- Adjust detection parameters
- Run tracking and analysis
├── main.py # Main program entry point
├── config.py # Configuration constants
├── file_selector.py # File selection GUI
├── frame_selector.py # Frame range selection
├── transform_setup.py # Perspective transformation setup
├── tracking.py # Basic tracking functions
├── tracking_visualization.py # Real-time tracking display
├── oft_analyzer.py # Open Field Test analysis
├── sat_analyzer.py # Social Avoidance Test analysis
├── fst_analyzer.py # Forced Swim Test analysis
├── fst_tracking.py # FST-specific tracking
├── visualization.py # Result visualization
├── csv_exporter.py # CSV data export
├── excel_exporter.py # Excel report generation
└── __init__.py # Package initialization
- Center zone time (25%, 33% area ratios)
- Corner zone time
- Total distance traveled
- Average and maximum speed
- Zone entry frequency
- Interaction zone dwelling time
- Corner zone avoidance
- Movement patterns
- Social approach/avoidance metrics
- Immobility detection threshold (customizable)
- Minimum immobility duration
- Total immobility time and percentage
- Number of immobility episodes
The program generates timestamped output files in the results/YYYYMMDD/ directory:
- Excel Summary:
{ExperimentType}summary_analyzed_at_{timestamp}.xlsx - CSV Trajectory:
{ExperimentType}_{sampleID}_trajectory_{timestamp}.csv - Visualization:
{sampleID}_tracking_plot_{timestamp}.png
This project is licensed under the MIT License - see the LICENSE file for details.
Developed with support from Claude (Anthropic AI Assistant).
Contributions are welcome! Please feel free to submit a Pull Request.