Skip to content

Element: decided device kinds for every probe type; batch-4 carries - #304

Merged
jesshaley merged 3 commits into
V2from
claude/element-device-kinds
Oct 30, 2026
Merged

jesshaley merged 3 commits into
V2from
claude/element-device-kinds

Conversation

@jesshaley

Copy link
Copy Markdown
Collaborator

Builds the DID-matlab part of these decisions, all in did-schema V_eta_go_forward_class_audit.md: [element type is a device kind term] (2026-10-27), [element types batch 1] .. [element types batch 4] (2026-10-30), [n-trode is a multielectrode array]. No MATLAB in the authoring container: CI is the first run.

Built

  • +convert/elementDeviceKind.m now covers all 22 device types on an ndi.probe.* class:

    • n-trode -> wikidata:Q1952355
    • patch, patch-Vm, patch-I, patch-attached -> EMPTY:0000411 patch electrode
    • sharp, sharp-Vm, sharp-Im -> EMPTY:0000412 sharp electrode
    • wide-field, two-photon, one-photon and brightfield imaging -> OBI:0400169 microscope
    • lick-spout -> EMPTY:0000414
    • reward-well -> EMPTY:0000415
    • intraoral-cannula -> NCIT:C50343
    • optogenetic-fiber -> NCIT:C50358
    • ecg -> OBI:0003806
    • eeg -> wikidata:Q4531135
    • accelerometer -> NCIT:C88166
    • thermometer -> NCIT:C50059
    • ppg -> NCIT:C224112
    • literal electrode-$ -> NCIT:C49936

    NCIT:C49936's registry row is on did-schema doc2sql: cell arrays are stored as a size/class summary, because iscell(matlabType) is always false #241, which is not merged. did2.convert turns TermRegistry off while it migrates, and no test here validates an electrode-$ device.

  • New +convert/elementTypeOfKind.m: returns the one v1 type that a kind maps back to. It returns '' when no type, or several types, share the kind.

  • +migrators_j/element.m:

    • Devices. Every device gets its Equipment Type assertion.
    • Wide-field and brightfield imaging are now devices (microscope). They are no longer carried under carry-121, so carry-121 is now cited by no site.
    • Carried whole as v1, needs_mapping, under carry-063: stimulator, event, electrode-<spec> and <prefix>_electrode-<spec>, neuron and cell. Already carried before: position/distance, derived copies, '', lfp, field, sharp-I, display, stim-n-trode, n-LED and any other string.
    • Sorted units. spikes -> cell or Group from its neuron_extracellular label, which the migrator reads through the batch index unitQualityLabels. A unit with no label is carried under carry-062. ensemble -> Group.
    • The element type assertion is dropped where the device kind alone rebuilds the v1 word: n-trode, electrode-$, lick-spout, reward-well, intraoral-cannula, optogenetic-fiber, ecg, eeg, accelerometer, thermometer, ppg.
    • The assertion is kept (rule (iii)) in two cases:
      • Kinds that several types share (patch*, sharp*, the four imaging types). Their mode belongs on the recording observation, which resolveEpochProbemap mints, not this migrator.
      • spikes and ensemble. resolveEpochProbemap keys their epochs on the assertion.
  • Readers of the type: +roundtrip/element.m, +roundtrip/private/manifestProbemap.m (probe-map row type) and resolveEpochProbemap.m (element_epoch tallies) now fall back to the kind when there is no element type assertion.

  • Tests:

    • testRawV1RoundTripElement:
      • testEveryDeviceHasItsDecidedKind checks all 22 types plus a table-equality check against elementDeviceKind.
      • testTheElementTypeAssertionIsKeptOnlyWhereTheKindDoesNotRebuildIt covers when the assertion is dropped or kept.
      • The old testADecidedDeviceKindIsAnEquipmentTypeAssertion is removed (it is inverted by the two above).
      • The converted round-trip list gains patch, patch-attached, sharp-Vm, electrode-$, lick-spout, reward-well, cannula, fiber, thermometer, ppg and all four imaging types.
      • The carried list gains stimulator, event, both electrode spellings, neuron, cell, lfp and a patch type on a non-probe class. Wide-field and brightfield leave it.
    • testMigratorsJRecordingObservation: the stimulator test is inverted (the element is carried). Comments are updated for the electrode spelling and imaging.

Python checks pass: check_carry_citations --did-schema, check_migrator_roster, and every python step of test-migrators-quick.yml.

Must wait before merge

  • NDI-matlab reads the element type assertion first. On NDI-matlab V2 3e0a2ca the readers are +vintage/elementFields.m (f.type), +migrate/+internal/pathSPromotion.m (idx.elements) and +vintage/elementLabel.m. Dropping the assertion for n-trode and the other single-type kinds leaves f.type empty in NDI's object layer for those devices. Per did-schema CLAUDE.md section 3 ("the writers and readers ... change first"), NDI-matlab must read the device kind (with elementTypeOfKind's map) before this merges.
    • NDI's TestElementLabelMatchesMigrator still passes: both labels are still written, and 'ndi element class' is written at exactly one site.

Left open

  • Mode terms on the recording observation: -attached -> OBI:0002179 and brightfield -> EMPTY:0000300 are decided but not written. They belong to the per-epoch observation that resolveEpochProbemap mints from the probe-map row. Voltage, current, 1p, 2p and wide-field modes are not decided. Until they are written, the element type assertion is kept for patch*, sharp* and imaging.
  • n-trode "number of electrodes" (EMPTY:0000408) is not built. The count comes from the epochprobemap devicestring, which is not on the v1 element, so it is batch-pass work in resolveEpochProbemap (it already parses the devicestring channels). It also needs:
    • the cross-check against probe_geometry / site2channelmap;
    • a did-schema needs_mapping register row for a disagreement.
  • ndi element class is still written: [ndi element class not kept] waits on NDI readers.
  • Register rows (for the did-schema side):
    • carry-063's when text ("not on the element type list") covers the batch-4 carries, but its decision cites [element types have no default], not [element types batch 4].
    • carry-121 should be retired, since wide-field and brightfield are now devices.
    • No new carry site uses % carry-register: none.
  • Did not run: the MATLAB suite (no MATLAB in this container).

Doubts

  • Stimulator carry cascade. Carrying stimulator triggers [dependents of a carried document carry] (carry-064), which carries its element_epochs and other converted documents that point at it. The probe-map stimulator manipulation then has no instrument_id. A deferred bath (resolved after pass 1) still names the carried v1 stimulator as instrument_id. This affects Dab baths and vhlab stimulus data broadly.
  • Merge with Store a migrated element's name apart from its reference #299: it conflicts only in testRawV1RoundTripElement.m. Store a migrated element's name apart from its reference #299 moves the device-kind test block and edits the carried list next to the rows this PR changes.
  • The 'Group' spelling is kept. Batch 4 writes group; [migrator writes the registry spelling] gives Group (NCIT:C43359).

Generated by Claude Code

… per batch 4

[element types batch 1] .. [element types batch 4] (Jess Haley, 2026-10-30,
did-schema V_eta_go_forward_class_audit.md):

- elementDeviceKind holds all 22 device types: patch* -> EMPTY:0000411,
  sharp* -> EMPTY:0000412, the four imaging types -> OBI:0400169, lick-spout
  -> EMPTY:0000414, reward-well -> EMPTY:0000415, electrode-$ ->
  NCIT:C49936, beside the kinds already built.
- wide-field-imaging and brightfield-imaging are devices (microscope), no
  longer carried under carry-121.
- stimulator, event, electrode-<spec>, <prefix>_electrode-<spec>, neuron and
  cell are carried whole as v1, needs_mapping (carry-063).
- The "element type" assertion is replaced by the device kind where the kind
  alone rebuilds the v1 word (did2.convert.elementTypeOfKind); it is kept for
  a kind several types share (patch, sharp, microscope: their modes go on the
  recording observation, not all decided) and for sorted units and ensembles.
- The element round trip, the probe-map round trip and resolveEpochProbemap
  read the type from the kind when the assertion is absent.

Tests: testEveryDeviceHasItsDecidedKind and
testTheElementTypeAssertionIsKeptOnlyWhereTheKindDoesNotRebuildIt replace
testADecidedDeviceKindIsAnEquipmentTypeAssertion; the converted and carried
round-trip lists follow the batches; the stimulator test is inverted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FxKLA8Tbf9cpvDe7fuVeKf
Merges origin/V2 (through #311), including #299 [element name and reference
stored apart]: carry-055 is gone, a reference neither one number nor one
text is carry-120, a non-empty base.name is carry-149, a unit whose probe is
not in the batch is carry-151.

Conflicts, both sides kept:
- +migrators_j/element.m header: V2's element.name / local_identifier rows
  (carry-048 / carry-120) with this branch's element.type rows (device kind,
  element type assertion only where the kind does not rebuild the word).
- +roundtrip/element.m header: V2's name/reference rows and pre-2026-10-29
  fallback with this branch's element.type-from-kind row.
- testRawV1RoundTripElement: V2's header row and tests; this branch's
  testEveryDeviceHasItsDecidedKind and
  testTheElementTypeAssertionIsKeptOnlyWhereTheKindDoesNotRebuildIt; the
  carried list is this branch's (stimulator, event, electrode spellings,
  neuron, cell, lfp, patch on a non-probe class) plus V2's carry-120,
  carry-048 and carry-151 rows, without the carry-055 rows (V2 converts
  them) and without the carry-121 rows (batch 2 makes them microscopes).
  testGroupIsWrittenAsTheRegistryNamesIt and
  testAUnitThatDisagreesWithItsProbeIsCarried, which #299 removed with no
  replacement while its header still cites carry-120 for the unit case,
  are kept.

Added on the merge:
- resolveEpochProbemap writes the decided recording / imaging mode as the
  recording observation's method term ([element type is a device kind
  term], [imaging mode is a method term], [element types batch 1],
  [element types batch 2], [cell-attached is OBI]): patch-attached
  OBI:0002179, brightfield-imaging EMPTY:0000300; counter
  mode_methods_written, rendered by census_digest.py. Test:
  testMigratorsJRecordingObservation/testTheDecidedModeIsTheObservationsMethodTerm.
- testRawV1RoundTripBath/testTheSwitchChangesNoBath compares the carried
  stimulator element by id only: a carried document is its v1 source as
  each path spells it (it failed on #304's head, CI run of 41ab1d6).

No file cites carry-055 or carry-121. MATLAB has not run on this merge.

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

Copy link
Copy Markdown
Collaborator Author

Merged V2 (through #311) into this branch: 963c578. MATLAB has not run on the merge. No MATLAB in the authoring container; this push's CI is the first MATLAB run.

Conflicts and how they were resolved

Three files conflicted. Both sides were kept in each.

  • +migrators_j/element.m (header only): V2's element.name / local_identifier rows (Store a migrated element's name apart from its reference #299: carry-048, carry-120; carry-055 gone) together with this branch's element.type rows.
  • +roundtrip/element.m (header only): V2's name and reference rows, plus its fallback for documents migrated before 2026-10-29, together with this branch's rule that rebuilds the type from the device kind.
  • testRawV1RoundTripElement.m:
    • Kept: V2's header and tests, and this branch's two device-kind tests.
    • The carried list is this branch's rows plus V2's carry-120, carry-048 and carry-151 rows.
    • Dropped: the carry-055 rows (V2 converts those elements now) and the carry-121 rows (batch 2 makes those elements microscopes).
    • Store a migrated element's name apart from its reference #299 had removed testGroupIsWrittenAsTheRegistryNamesIt and testAUnitThatDisagreesWithItsProbeIsCarried with no replacement, while its header still cites carry-120 for the unit case. I kept both tests. Reviewer: confirm this.

Added on the merge

  • Mode terms. resolveEpochProbemap writes the decided mode as the recording observation's method term: patch-attached -> OBI:0002179, brightfield-imaging -> EMPTY:0000300.
    • Decisions: [element type is a device kind term], [imaging mode is a method term], [element types batch 1]/[2], [cell-attached is OBI].
    • New counter mode_methods_written, rendered by census_digest.py.
    • New test: testMigratorsJRecordingObservation/testTheDecidedModeIsTheObservationsMethodTerm.
    • The other modes have no decided term, so they get nothing.
    • The element still writes its element type assertion for patch*, sharp* and the imaging types, because an element's round trip reads no observation.
  • Bath test fix. testRawV1RoundTripBath/testTheSwitchChangesNoBath failed on 41ab1d6 ("document 2 differs between the raw and the renamed path"). The stimulator element is now carried, and a carried document is its v1 source as each path spells it. The test now compares the carried document by id only, as testBothPathsConvertAnElementAlike already does. This diagnosis comes from reading the code, not from running it.

Superseded items in the PR body

Python checks on 963c578 (all exit 0)

  • check_carry_citations.py --did-schema, run against did-schema origin/main 1e1eef9: no carry-055 or carry-121 citation anywhere in the tree.
  • check_migrator_roster.py and test_check_migrator_roster.py.
  • test_check_carry_citations.py.
  • test_batch_pass_wiring.py.
  • test_census_digest*.py.
  • test_corpus_proven.py, test_sample_corpus.py, test_extract_failure_fixtures.py, test_affected_corpora.py, test_corpus_matrix.py.
  • did-schema check_empty_ontology_nodes.py --did . --enforce.

Left for did-schema

carry-121 is cited by no DID-matlab site: no git grep hit, and check_carry_citations lists it as uncited. did-schema can retire it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FxKLA8Tbf9cpvDe7fuVeKf


Generated by Claude Code

Builds the DID-matlab part of [stimulator is SNOMED CT Stimulator]
(Decided by Jess Haley, 2026-10-30, did-schema
V_eta_go_forward_class_audit.md), which replaces item (4) of
[element types batch 4]: a v1 `stimulator` element is a device of kind
SNOMEDCT:36645008 "Stimulator" instead of being carried (carry-063).

- elementDeviceKind: the stimulator row; it leaves the NOT HERE list.
- element.m: stimulator moves from the carried list to the device list;
  its kind is the only one with that node, so the kind alone rebuilds the
  v1 word and the `element type` assertion is dropped, as for n-trode.
- Tests: testRawV1RoundTripElement converts and round-trips a stimulator
  probe, pins its kind and the dropped assertion, and no longer lists it
  as carried; testMigratorsJRecordingObservation inverts the carried
  stimulator test (a device, Equipment Type SNOMEDCT:36645008, no
  observation, `observes` kept); testRawV1RoundTripBath's comment no
  longer says the stimulator is carried.

The term registry row and the Equipment Type value are on did-schema
#246, not yet on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FxKLA8Tbf9cpvDe7fuVeKf
@jesshaley
jesshaley marked this pull request as ready for review October 30, 2026 16:00
@jesshaley
jesshaley merged commit a87114f into V2 Oct 30, 2026
11 checks passed
@jesshaley
jesshaley deleted the claude/element-device-kinds branch November 25, 2026 21: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.

2 participants