Skip to main content

Automated behavioral analysis software and pipeline for neuroscience.

Project description

Issues Closed Issues License


Behavython logo

Automated Behavioral Analysis Interface
Currently built to integrate seamlessly with DeepLabCut
Other tools coming soon!

Report Bug · Request Feature


Table of Contents


About

Behavython is an automated, high-throughput behavioral analysis interface. It features a modular architecture that converts raw tracking data (CSV/H5) into structured, biologically relevant behavioral metrics.

It natively supports:

  • Geometry-based paradigms: Open Field, Elevated Plus Maze (EPM)
  • Interaction-based paradigms: Social Recognition, Social Discrimination, Object Discrimination

The software enforces strict scientific reproducibility through automated environment management, robust data validation, and granular metric exports.


Getting Started

Automated Installation (Windows)

For Windows users, we provide a batch script that automates the creation of the Conda environment, installs the correct pip dependencies, and handles the CUDA setup.

Download and run the installer from the repository:

Step-by-Step Installation (Manual)

We strongly recommend using Conda (or Miniconda/Mamba) to manage your isolated Python environment to prevent dependency conflicts.

1. Create the environment: Create a clean environment explicitly using Python 3.10.

conda create -n behavython python=3.10

2. Activate the environment: You must be inside the environment for the next steps.

conda activate behavython

3. Install Behavython: Use pip inside the activated environment. Crucial: You must include the extra index URL to fetch the correct GPU-compiled PyTorch wheels. Omitting this may result in an incompatible CPU-only installation.

pip install behavython --extra-index-url [https://download.pytorch.org/whl/cu118](https://download.pytorch.org/whl/cu118)

GPU Setup (Critical)

⚠️ Required for correct execution

Behavython relies heavily on GPU-accelerated frameworks. You must install the NVIDIA CUDA toolkit and cuDNN AFTER you have completed the pip installation above, and it must be done INSIDE the active behavython environment.

# Ensure you are still inside the 'behavython' environment
conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0

Failure to configure the GPU dependencies correctly will result in severe processing slowdowns and potential runtime memory errors during DeepLabCut operations.


Pretrained Models

Behavython comes with a pretrained model for roi and mouse tracking (c57 black on white arena top view) These can be downloaded from the GitHub Releases page.

The latest release (models-v1.0) includes:

  • c57_network_2025_minified.zip - Optimized for C57 rodent tracking.
  • roi_network.zip - Dedicated network for Region of Interest detection in social recognition experiments.

Extract these ZIP archives into .behavython/models/ folder in your home directory located in:

  • Windows: C:\Users\<YourUsername>\.behavython\models\
  • Linux/Mac: ~/.behavython/models/
  • Note: Ensure the extracted model files are directly within the models folder, not nested inside additional subdirectories.

Workflow & Configuration

The Pipeline

Video → DeepLabCut → Filtered CSV → Behavython Core Pipeline → Metrics & Parquet

Arena Configuration (Geometry Tasks)

For Open Field and Elevated Plus Maze (EPM) experiments, Behavython requires a .json configuration file defining the spatial geometry. You can extract these coordinates using the ImageJ Point Tool.

  • Open Field: Requires exactly 4 ordered corners (Top-Left, Top-Right, Bottom-Right, Bottom-Left).
  • Elevated Plus Maze: Requires exactly 12 ordered points defining the outer boundaries, arms, and center zone.

Note: Incorrect coordinate ordering will corrupt spatial occupancy metrics.

ROI Configuration (Interaction Tasks)

For interaction paradigms, utilize the ImageJ Oval Tool to define your regions of interest.

  • Analyze → Set Measurements: Ensure Centroid and Bounding Rectangle are checked.
  • Name the exported CSV files logically (e.g., video_roiL.csv and video_roiR.csv for two-choice tasks, or video_roi.csv for single-object).

Outputs & Metrics

The pipeline outputs data in multiple formats for both statistical aggregation and granular programmatic review.

General Storage

  • analysis_summary.xlsx / .csv: Scalar metrics aggregated per animal.
  • analysis_timeseries.parquet: Highly compressed, frame-by-frame data utilizing Apache Arrow for efficient downstream data science workflows.
  • analysis_log.json: Comprehensive error and warning logs per session.

Task-Specific Metrics

Geometry Experiments (Open Field, EPM):

  • Zone occupancy times and percentages.
  • Transition counts between zones.
  • Discrete spatial_state arrays per frame.

Interaction Experiments (Social/Object):

  • Investigation and approach proportions.
  • Mean inter-bout intervals (seconds).
  • Discrete bout analysis (Collision bouts, approach-only bouts, abortive retreats).
  • analysis_collisions.parquet: Granular export containing distance to objects, interaction angles, and frame-by-frame flags.

Contributing

Contributions to the codebase and scientific pipelines are welcome.

  • Open an issue to report bugs or suggest features.
  • Submit a pull request for code changes. Ensure modifications align with the project's modular architecture and strict type-hinting standards.

License

This project is distributed under the GNU GPL v3.0 License. See the LICENSE file for more information.


Contact


Acknowledgments


Developed at
Núcleo de Neurociências (NNC)
Universidade Federal de Minas Gerais (UFMG)
Brazil

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

behavython-0.8.2.tar.gz (647.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

behavython-0.8.2-py3-none-any.whl (651.9 kB view details)

Uploaded Python 3

File details

Details for the file behavython-0.8.2.tar.gz.

File metadata

  • Download URL: behavython-0.8.2.tar.gz
  • Upload date:
  • Size: 647.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for behavython-0.8.2.tar.gz
Algorithm Hash digest
SHA256 51f470607b28332f632d6fc4d79c6640f104bf7e47deede7b98c458ec265bb0c
MD5 10c44e9837954039eb3d447b90a148a6
BLAKE2b-256 3a3babd48ae1ca05857eb6045e5ec844ef06997a697c90700a8a411b384c0ce5

See more details on using hashes here.

File details

Details for the file behavython-0.8.2-py3-none-any.whl.

File metadata

  • Download URL: behavython-0.8.2-py3-none-any.whl
  • Upload date:
  • Size: 651.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for behavython-0.8.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d42a2b7d2a50ea8511a9ae6959d1baa31b11398af701f08237561db3aeeb3700
MD5 d5915198af5e1099ca7b3b836f6e1049
BLAKE2b-256 c7ef265d22f341466e44da2644819e2ae65709822156d7c81732422eb217c9c2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page