Skip to content

Make timing_source part of the PsychophysicalKernel key, drop mixed, rename nidaq to nidq #13

Description

@rojasgabriel

Goal

Promote timing_source from a dependent attribute to part of the PsychophysicalKernel primary key, remove the mixed value, and rename nidaq to nidq.

A kernel row is one fit from one clock. Comparing NIDQ timing against Bpod timing is then a query over two rows, not a stored third row.

Today timing_source sits below the --- divider, so only one row can exist per analysis set x subject x condition x fit config, and it carries whichever clock happened to populate it. The same fit config under two clocks collides instead of coexisting, and mixed exists as a workaround for not being able to store the pair.

Plan

  1. labdata_plugin/analysisschema.py - move timing_source above the --- divider in PsychophysicalKernel, so the key becomes BehaviorAnalysisSet x Subject x trialset_description x PsychophysicalKernelFitConfig x timing_source. Set the enum to exactly enum('nidq', 'bpod').
  2. labdata_plugin/analysisschema.py - add timing_source to key_source so populate produces one row per available timing source rather than whichever one the loader returned.
  3. src/behavior_analyses/kernel_timing.py - fetch_pooled_kernel_inputs takes the requested timing source as an argument and raises when the selected trialsets cannot supply it. It must not infer a source, and must not silently pool across sources. Update the value it returns from nidaq to nidq.
  4. Grep the repo for nidaq and update the remaining references.
  5. Add a test that fits one session under both timing sources and asserts two distinct rows sharing a fit config.

Do not touch: the fit math in src/behavior_analyses/kernels.py, the PsychophysicalKernelFitConfig contents, or the psychometric tables. Do not add any table, attribute, or row that stores a NIDQ-versus-Bpod difference; that is a query, not a measurement.

Validation

uvx ruff check .
uvx ruff format --check .
  • Run the test suite under Python 3.11. Python 3.10 hits the known SciPy _spropack import problem locally.
  • Populate one GRB006 session under both timing sources and confirm two rows differing only in timing_source.

Expect: two rows, clean lint, tests pass.

Done when

  • timing_source is part of the primary key
  • The enum is exactly nidq and bpod
  • Requesting a timing source the trialsets cannot supply raises instead of falling back
  • The same fit config can be stored under both timing sources for one session
  • A test covers the two-row case

Notes

  • This is a key change, so the table must be dropped and re-declared. Check the live row count and any existing mixed rows first. The nidaq to nidq rename comes free with the re-declaration.
  • Populating requires the lab DataJoint connection, so the live validation step cannot run in a cloud agent.
  • Context: ephys PR #35 removed the duplicate session-level kernel on 2026-08-03, making this table the single canonical kernel surface.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions