Skip to content

Conversation

@bergsalex
Copy link
Contributor

This is the code implementation half of KLAUS-118.

Implements behavior table merging functionality to address requirements in YODA-118 and YODA-65. This enables aggregation of bout tables per-behavior with header preservation, supporting both bout and bin table types through new CLI commands.

New functions:

  • merge_behavior_tables() - Merges multiple behavior tables of the same type and behavior
  • merge_multiple_behavior_tables() - Merges multiple sets of behavior tables grouped by behavior

These are exposed through new CLI commands:

  • merge-tables - Merge specific behavior table files of the same type
  • merge-multiple-tables - Auto-group and merge tables from a folder by behavior

Example CLI usage:

  # Merge specific tables of the same behavior
  uv run python -m jabs_postprocess.cli.main merge-tables \
    --input-tables experiment1_grooming_bouts.csv experiment2_grooming_bouts.csv \
    --output-prefix merged_grooming

  # Auto-merge all tables in a folder, grouped by behavior  
  uv run python -m jabs_postprocess.cli.main merge-multiple-tables \
    --table-folder /path/to/experiment/tables \
    --output-prefix experiment_merged

These changes include unit tests!

$ uv run pytest tests/test_generate_behavior_tables.py
============================== test session starts ===============================
platform darwin -- Python 3.10.9, pytest-8.3.5, pluggy-1.5.0
rootdir: /Users/aberger/Projects/KumarLab/JABS-postprocess
configfile: pyproject.toml
plugins: cov-6.1.1
collected 25 items                                                               

tests/test_generate_behavior_tables.py .........................           [100%]

=============================== 25 passed in 0.53s ===============================

@bergsalex bergsalex self-assigned this Aug 21, 2025
@bergsalex bergsalex marked this pull request as ready for review August 21, 2025 20:46
@bergsalex bergsalex merged commit 5dea0dd into master Aug 22, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants