Skip to content

feat(review): time-bin export with one sheet per measure, and bouts per bin - #236

Merged
gbradham merged 3 commits into
mainfrom
feat/review-bins-per-metric-sheets
Oct 29, 2026
Merged

gbradham merged 3 commits into
mainfrom
feat/review-bins-per-metric-sheets

Conversation

@gbradham

@gbradham gbradham commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

What

A new tick in Export → Time bins (CSV)…: One sheet per measure (Excel workbook).

When ticked, the export is an .xlsx instead of a CSV:

  • One sheet per measure: each behaviour (seconds and %), zone, distance and speed measure on its own sheet. Rows are sessions, with their group; columns are the bins (0-1 min, 1-2 min, …). The header row is frozen.
  • Bins sheet: each bin's start and end in seconds.
  • Measures sheet: which measure and source column each sheet holds, since Excel limits sheet names to 31 characters.
  • Measures no session has a value for get no sheet.
  • Sheet names are made legal for Excel (no []:*?/\) and unique, ignoring case.
  • The Tidy/Wide layout is greyed out while ticked, and the tick is remembered between exports.

Bouts per bin

Each behaviour now has a bouts measure (e.g. Groom bouts), with its own sheet in the workbook. It's also offered in the epoch table and the CSV exports.

  • A bout counts in the bin where it starts. One already under way at a bin's start belongs to the bin before, so a session's bins add up to its total bout count. Counting every bout a bin touches would count one that crosses an edge in both bins.
  • Animals with no bouts in a bin get 0, not a blank.

Flow timing tests

The macOS runner failed test_flow_schedule.py twice when one gap of four woke 15–75 ms late. Those tests now check the median gap, which still catches the systematic drift they guard against.

Dependency

Adds openpyxl>=3.1.0 (pure Python) to the core dependencies, and updates uv.lock. If it's missing, the export says how to install it rather than failing.

Tests

  • test_epochs.py::TestMetricSheets: layout, order, empty measures skipped, sheet-name rules.
  • test_time_bins_dialog.py (new): the tick and the greyed-out layout.
  • test_analysis_window.py: a sheet per measure from a real cohort, and an end-to-end .xlsx read back with pandas.
  • test_session_view.py::TestBoutOnsets and bin tests: onsets, edge-crossing bouts, bins summing to the whole, the bouts sheet.
  • Session view, epochs, stats, Session Review GUI and tour suites: 731 passed. ruff and black clean.

🤖 Generated with Claude Code

A tick in the time-bin dialog writes an Excel workbook instead of a CSV:
each behaviour, zone and distance measure on its own sheet, a row per
session (with its group) and a column per bin, plus Bins and Measures
sheets saying what the columns and sheet names are. Measures no session
has are left out. Sheet names are made legal and unique for Excel. The
tick is remembered. Adds openpyxl as a dependency.
The flow-schedule tests failed on the macOS runner when one gap of four
woke 15-75 ms late, with nothing wrong in the schedule. A drift -- what
these tests guard against -- moves every gap, so the median catches it
and the total run time still bounds the whole flow.
Each behaviour gets a bouts measure: the bouts that start in a range. A
bout under way at the range's start belongs to the range before, so the
bins of a session add up to its bout total; counting every bout a bin
touches would count one crossing an edge in both. It is offered in the
epoch table, the CSV exports and, as its own sheet, the per-measure
workbook.
@gbradham gbradham changed the title feat(review): time-bin export with one sheet per measure feat(review): time-bin export with one sheet per measure, and bouts per bin Oct 29, 2026
@gbradham
gbradham merged commit 0e6a7ef into main Oct 29, 2026
4 checks passed
@gbradham
gbradham deleted the feat/review-bins-per-metric-sheets branch October 29, 2026 20:46
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.

1 participant