Skip to content

Tuning fits name their symbols by registered term (did-schema #474, step 2) - #602

Draft
jesshaley wants to merge 2 commits into
V2from
claude/fit-symbol-terms
Draft

jesshaley wants to merge 2 commits into
V2from
claude/fit-symbol-terms

Conversation

@jesshaley

Copy link
Copy Markdown
Collaborator

Step 2 of Waltham-Data-Science/DID-schema#474 ("Fit symbols get term nodes and a symbol field"). It follows did-schema #488, which adds the optional symbol field. The did-schema branch claude/fit-symbol-terms is at #488's head (f1d43b05), so this branch's quick CI pairs with it.

Decisions built

All Decided by Jess Haley, 2026-12-03, in did-schema docs/plans/did_v2_go_forward_class_audit.md:

  • [fit symbols need term nodes]
  • [fit coefficients share general terms], as amended by [fit terms name their meaning]
  • [a fit with an equation names every symbol] (S1, S2)
  • [fit symbol terms batch 1] (U5)
  • [fit symbol terms batch 2]
  • [difference of Gaussians named added and subtracted]
  • [fit symbol terms list 1]
  • [fit symbol terms list 2]
  • [response properties under measurement]
  • [fit symbol scope]: the five models only. Priebe is did-schema#477; fitcurve / vmspikefit are did-schema#478. Neither is touched here.

What the migrators write

This applies once the loaded schema declares symbol on the four fit lists. On a schema without it, a fit is written exactly as before (siblings first, via jFitSymbolsDeclared). Each coefficient and constraint gets its registered term in variable and the writer's symbol in symbol:

model symbol → term
Naka-Rushton (contrast tuning, contrast sensitivity) Rm → EMPTY:0000469 response scale; c50 → EMPTY:0000465 semisaturation contrast; n → EMPTY:0000470 contrast exponent; s → EMPTY:0000471 saturation exponent
double Gaussian (oridir) Rsp → EMPTY:0000466 baseline response; Rp → EMPTY:0000472; Op → EMPTY:0000467 preferred direction; sig → EMPTY:0000474 direction tuning width; Rn → EMPTY:0000473
difference of Gaussians (SF, TF) a1/b1/a2/b2 → EMPTY:0000476/0000477/0000478/0000479
Movshon 2005 (SF, TF) k → EMPTY:0000469; fc → EMPTY:0000480 high-frequency fall-off frequency; fh → EMPTY:0000482 low-frequency cutoff frequency; B → EMPTY:0000481; C → EMPTY:0000466
log-Gaussian (SF, TF) a → EMPTY:0000466; b → EMPTY:0000349 peak amplitude; c → EMPTY:0000468 preferred frequency; d → EMPTY:0000475

Every fit with a model row also gets its two variables:

  • independent_variables: one entry holding the family's variable, with its symbol in equation:
    • Contrast NCIT:C70754 c
    • Direction NCIT:C42677 theta
    • Spatial Frequency NCIT:C75389 / Temporal Frequency NCIT:C25515 x or f
    • The entry also carries the unit of the curve's covariate of that variable, when that covariate has one, so that fit_metric_unit holds.
  • dependent_variable: the curve's response variable (from jResponseVariable) with symbol R.

The cubic spline has no equation, so it writes both variables with no symbol (U5).

Round trip

  • The round trip reads symbol for the v1 names (fitSymbolOf). A fit migrated before is still read by its variable's name.
  • It checks that each symbol's term matches the table (fitTermBad).
  • It checks the restated variables (fitVariablesBad). Anything else is listed, never dropped.

Rule S1 (rule name fit_symbols_named: Proposed, not decided)

  • did2.build.checkFitSymbolsNamed refuses a fit with a non-empty equation when a coefficient or constraint has no symbol, or when a symbol repeats. Uniqueness is checked across coefficients and constraints together.
  • checkRules.m dispatches the check when a class declares the rule. No class declares it yet.
  • checkTerm.m's fit-symbol exemption is unchanged; it is dropped after the schema binding lands.

Report

jCalculation leaves one tuning_fit_model note per fit written with a model row, with DETAIL <stem> | <how>. v1_to_v2 prints the total first, then the count per detail. A corpus report therefore counts the fits of each model exactly.

Tests

  • New testFitSymbolTerms:
    • the decided table, written out from the decision lines rather than read from the code;
    • every table term is registered;
    • the writers' own outputs (oridir, contrast sensitivity, SF, TF, and contrast tuning once its metrics are declared) name every symbol by its decided term, and their round trips lose nothing;
    • the rule's positive and negative cases, and its dispatch on a schema copy that declares it.
  • testTuningDecisions and testMigratorsJ read symbol when the schema declares it.

CI results and corpus counts (20211116, Soph) are posted as a comment.

Not in this PR

  • NDI-matlab model_fit writers (the Haley density fits): the decision lists NDI-matlab "any model_fit writer".
  • The schema bindings and the declared rule. Both come after this PR (siblings first).

Generated by Claude Code

Once the loaded schema declares `symbol` on the fit lists (did-schema #488),
the tuning migrators write each coefficient's and constraint's `variable` as
the symbol's registered term and the writer's symbol in `symbol`, and name
the fit's independent variable (Contrast, Direction, Spatial or Temporal
Frequency, with its equation symbol) and dependent variable (the curve's
response variable, `R`); the cubic spline writes no symbol. On a schema
without the field a fit is written as before. Decided by Jess Haley,
2026-12-03, did-schema did_v2_go_forward_class_audit.md: [fit symbols need
term nodes], [a fit with an equation names every symbol], [fit terms name
their meaning], [difference of Gaussians named added and subtracted], [fit
symbol terms batch 1] (U5), [fit symbol terms batch 2], [fit symbol terms
list 1], [fit symbol terms list 2], [fit symbol scope].

- tuningFitModels: each row's symbol terms, independent symbol and `R`;
  a second output gives the family's independent variable term
- jTuningCurve, jContrastSensitivityValue: write them (jFitNamed,
  jFitVariables, jFitSymbolsDeclared)
- round trip: reads `symbol` for the v1 names (a fit migrated before is
  read by its variable's name), checks each symbol's term and the restated
  variables, lists anything else
- checkRules: rule `fit_symbols_named` (name Proposed, not decided; S1),
  checked by did2.build.checkFitSymbolsNamed when a class declares it; no
  class declares it yet
- jCalculation: one 'tuning_fit_model' report note per fit, v1_to_v2
  prints the count per model, denominator first
- tests: testFitSymbolTerms (the decided table, the writers' fits, the
  rule); tuning tests read `symbol` when the schema declares it

checkTerm.m's fit-symbol exemption stays until the schema binding lands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FxKLA8Tbf9cpvDe7fuVeKf
'node', m{1}, 'name', m{2}, 'symbols', {m{3}}, 'equation', m{4}, ...
'constraints', {spec{k, 4}}, 'leadingZero', spec{k, 5}); %#ok<AGROW>
'node', m{1}, 'name', m{2}, 'symbols', {reshape(named(:, 1), 1, [])}, ...
'equation', m{4}, 'constraints', {spec{k, 4}}, 'leadingZero', spec{k, 5}, ...
writeCorpusReport persists the 'tuning_fit_model' notes: the fits written
with a model row (the denominator) and the count of each '<stem> | <how>',
or "not measured" when none was written.

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