Skip to content

Brightness of a time series (time_series, plan N72) - #113

Merged
guijacquemet merged 2 commits into
mainfrom
claude/time-series-brightness
Nov 23, 2026
Merged

guijacquemet merged 2 commits into
mainfrom
claude/time-series-brightness

Conversation

@guijacquemet

Copy link
Copy Markdown
Contributor

What

A new module, time_series, moved from the OpticalFlow3D Profiler (its brightness.py) at the owner's request (plan N72, contract §3.7). It is for methods that assume constant brightness across time, such as optical flow:

  • frame_means(stack): one float64 mean per time point. Time is the first axis; the other axes (ZYX / YX) are pooled.
  • brightness_trend(means, reference): the least-squares slope of the means against the time index, divided by the reference mean. It is a check and changes nothing.
  • equalise_brightness(stack, reference): each time point is scaled to the reference's mean (Fiji's "Simple Ratio" without a background). Returns the scaled float64 series and the factors.
  • match_histograms(stack, reference): each time point's distribution is mapped onto the reference's (Fiji's "Histogram Matching", p' = interp(F_t(p), F_ref, v_ref)). The reference time point is unchanged.
  • TimeSeriesError (a ValueError) refuses non-finite pixels, arrays without a time axis, non-numeric types, an invalid reference index (a boolean or float is never converted), and equalisation of a time point whose mean is not above 0. Every message names the problem.

The caller chooses the reference time point; the profiler will pass the central frame of each optical-flow window. The formulas are the profiler's, unchanged, so its results stay bit-identical after it switches to this module.

Scope

  • Additive only. No existing output, API, message, column or schema_version changes; the package still imports with NumPy only. Nothing in fit or apply calls the new functions.
  • New module registered as pure in the code-rules layers; exported from the package.
  • Docs: contract §3.7 (with the formulas) and its section table, plan §12 N72, CHANGELOG (Unreleased), the AGENTS.md repository map, and the README.

Checks

  • python tools/check.py: code rules, Ruff and pytest pass (2,703 passed, 90 skipped). The skips are the optional scikit-image tests, as on main.
  • tests/test_time_series.py checks each function against a direct implementation: means, slope, scaled series and factors, and CDF matching with monotonicity. It also checks that inputs are never modified, the 2-D and 3-D layouts, and every refusal.

Follow-up

  • The OpticalFlow3D Profiler (guijacquemet/LabConstrictor-OpticalFlow3D) will depend on this module, pinned to the merge commit, and drop its own copy.

Generated by Claude Code

…pticalFlow3D Profiler

frame_means, brightness_trend, equalise_brightness and match_histograms, time first,
against a reference time point the caller chooses (contract section 3.7). Additive: no
existing output, API, column or schema_version changes; NumPy only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G3qp9AERqtoqUxiixuPVPV
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G3qp9AERqtoqUxiixuPVPV
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.

2 participants