Skip to main content

Data analysis and visualization package for Ethopy behavioral experiments

Project description

Ethopy Analysis

PyPI Version Python Versions Documentation License: MIT

Ethopy Analysis

A comprehensive Python package for analyzing and visualizing behavioral data from Ethopy experiments.

๐Ÿ‘‰ Documentation

Overview

Ethopy Analysis provides a modern, modular approach to behavioral data analysis with the following key features:

  • DataFrame-based: Most of plotting functions work with pandas DataFrames, making them independent of data source
  • Modular Design: Composable functions for different analysis levels (animal, session, comparison)
  • DataJoint-based: Works with DataJoint databases and provides DataFrame interfaces
  • Extensible: Modular function-based architecture for easy extension
  • Production Ready: Command-line interface, proper packaging, and configuration management

Installation

From Source (Development)

Setting Up a Virtual Environmentยถ

Before installing dependencies, it's recommended to use a virtual environment to keep your project isolated and manageable.

python -m venv venv
source venv/bin/activate  # On Windows use: venv\Scripts\activate

installing dependencies:

# Clone the repository
git clone <repository-url>
cd ethopy_analysis

# Install in development mode
pip install -e .

Dependencies

  • pandas >= 1.3.0
  • matplotlib >= 3.5.0
  • seaborn >= 0.11.0
  • numpy >= 1.20.0
  • plotly >= 5.0.0
  • datajoint >= 0.13.0 (for database access)
  • click >= 8.0.0 (for CLI)

Package Structure

ethopy-analysis/
โ”œโ”€โ”€ src/ethopy_analysis/
โ”‚   โ”œโ”€โ”€ data/                        # Data loading and processing
โ”‚   โ”‚   โ”œโ”€โ”€ loaders.py               # DB loaders: sessions, trials, states,
โ”‚   โ”‚   โ”‚                            #   licks, proximity, state windows,
โ”‚   โ”‚   โ”‚                            #   ON-OFF pairs, per-trial raster data
โ”‚   โ”‚   โ”œโ”€โ”€ analysis.py              # Derived metrics: performance,
โ”‚   โ”‚   โ”‚                            #   port-exit-to-lick latency, summaries
โ”‚   โ”‚   โ””โ”€โ”€ utils.py                 # Utilities: consecutive runs,
โ”‚   โ”‚                                #   column mapping, group helpers
โ”‚   โ”œโ”€โ”€ plots/                       # Plotting functions (DataFrame-based)
โ”‚   โ”‚   โ”œโ”€โ”€ animal.py                # Animal-level plots across sessions
โ”‚   โ”‚   โ”œโ”€โ”€ session.py               # Session-level plots: licks, proximity,
โ”‚   โ”‚   โ”‚                            #   states, trial-events raster
โ”‚   โ”‚   โ”œโ”€โ”€ comparison.py            # Multi-animal/condition comparisons
โ”‚   โ”‚   โ””โ”€โ”€ utils.py                 # Plotting utilities
โ”‚   โ”œโ”€โ”€ db/                          # Database connectivity
โ”‚   โ”‚   โ””โ”€โ”€ schemas.py               # DataJoint schema management and caching
โ”‚   โ”œโ”€โ”€ config/                      # Configuration management
โ”‚   โ”‚   โ”œโ”€โ”€ settings.py              # Config loading: ethopy_config.json,
โ”‚   โ”‚   โ”‚                            #   dj_conf.json, EthoPy local_conf.json,
โ”‚   โ”‚   โ”‚                            #   and environment variables
โ”‚   โ”‚   โ”œโ”€โ”€ styles.py                # Plot style presets
โ”‚   โ”‚   โ””โ”€โ”€ interactive.py           # Interactive credential prompts
โ”‚   โ””โ”€โ”€ cli.py                       # Command-line interface
โ”œโ”€โ”€ examples/                        # Example notebooks
โ”‚   โ”œโ”€โ”€ load_example.ipynb           # Data loading walkthrough
โ”‚   โ”œโ”€โ”€ animal_analysis_example.ipynb # Animal-level analysis
โ”‚   โ””โ”€โ”€ session_analysis_example.ipynb # Session-level analysis incl.
โ”‚                                    #   proximity, state windows, raster plot
โ”œโ”€โ”€ docs/                            # Documentation
โ”œโ”€โ”€ pyproject.toml                   # Package configuration
โ””โ”€โ”€ README.md

Configuration

Already using EthoPy?

If EthoPy is installed, ethopy-analysis automatically reads ~/.ethopy/local_conf.json โ€” no extra setup needed.

Other options

Method How
Config file Create ethopy_config.json in the project root (see docs/configuration.md)
Environment variables export DJ_HOST=โ€ฆ DJ_USER=โ€ฆ DJ_PASSWORD=โ€ฆ
Interactive Run any loader โ€” credentials are prompted if nothing else is found

See docs/configuration.md for the full priority order and format reference.

Examples and Tutorials

Check out the examples/ directory for comprehensive notebooks:

  • load_example.ipynb: Comprehensive animal-level analysis
  • animal_analysis_example.ipynb: Comprehensive animal-level analysis
  • session_analysis_example.ipynb: Detailed session-level analysis

Contributing

Adding New Plot Functions

  1. Create your plotting function in the appropriate module
  2. Follow the DataFrame-based input convention
  3. Return (fig, ax) or (fig, axes) tuple
  4. Import and use directly in your analysis

Code Style

  • Functions over classes where possible
  • Clear, descriptive function names
  • Pandas DataFrames for data exchange
  • Matplotlib for plotting (with optional Plotly support)

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

ethopy_analysis-0.1.3.tar.gz (5.9 MB view details)

Uploaded Source

Built Distribution

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

ethopy_analysis-0.1.3-py3-none-any.whl (57.8 kB view details)

Uploaded Python 3

File details

Details for the file ethopy_analysis-0.1.3.tar.gz.

File metadata

  • Download URL: ethopy_analysis-0.1.3.tar.gz
  • Upload date:
  • Size: 5.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for ethopy_analysis-0.1.3.tar.gz
Algorithm Hash digest
SHA256 7a55d05ab2e12af049194c4ef5dedbf879368359be36b617ca57ca8855331b5b
MD5 ae22f6571fd7fbe3f70d9cceff10793c
BLAKE2b-256 c04fe748457286de5ef51d3f3574f87d18c58e42a392676276401723e8342d7f

See more details on using hashes here.

File details

Details for the file ethopy_analysis-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for ethopy_analysis-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 630dabc9bb0f661ce5cf2aa3ac42a973d495f2e5d43ba799270ace9a0f5dcdb1
MD5 683c3172ebbce21912e0bbdaad2365bb
BLAKE2b-256 ec3251cf1eb2e85ece0bea425152605421c9ae92d4b6a1e53c2ab85feab43a2f

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