Skip to content

Modality: add MRS, iEEG, CT and physiological, with is_a parents - #61

Merged
jdkent merged 2 commits into
mainfrom
feat/modality-vocabulary
Nov 24, 2026
Merged

jdkent merged 2 commits into
mainfrom
feat/modality-vocabulary

Conversation

@jdkent

@jdkent jdkent commented Nov 23, 2026

Copy link
Copy Markdown
Member

Makes study_schema's Modality the single source of the modality vocabulary that ns-pond normalizes to and neurostore filters base studies on (neurostuff/neurostore#1962). Both repos currently hold their own 14-value copy.

Changes

  • Four new values in the storage Modality. The extraction projection is regenerated through pondie.schema.generate.

    value instantiates is_a
    MRS MRI (MR scanner parameters apply) MRI
    iEEG (ECoG, sEEG, depth electrodes, LFP, units) OtherModality other
    CT OtherModality other
    physiological (EMG, ECG, EDA, eye tracking and pupil, pulse, respiration, movement) OtherModality other

    iEEG instantiates OtherModality rather than EEG, because the EEG class is scalp EEG (10-20 placement).

  • Parents as is_a on permissible values:

    • fMRI, sMRI, dMRI and MRS refine MRI;
    • iEEG, CT and physiological refine other.
  • Generator. tools/generate_models.py writes each enum's value parents onto its JSON Schema definition as x-parents, alongside x-reference and x-unique-keys.

  • Python API. study_schema.jsonschema.value_parents(name, enum) and value_children(name, enum) read x-parents back in declared order. For example, value_children("storage-study", "Modality") is {"MRI": ("fMRI", "sMRI", "dMRI", "MRS"), "other": ("iEEG", "CT", "physiological")}. The package still depends only on pydantic.

  • The Modality, MRI and OtherModality descriptions, and the tutorial's modality table, list the new values.

Values are spelled the way Modality already spells them, so consumers store them as-is: MRS, iEEG, CT, physiological.

Checks

  • tools/generate_models.py --check is clean. The tests pass with linkml 1.12.1: 265 passed, 17 skipped (pyarrow, pyarty and setuptools were not installed locally).
  • New tests:
    • tests/test_annotate_value_parents.py, the generator annotation;
    • tests/test_value_parents.py: the API on both contracts, parents and children being values of the enum, the extraction and storage vocabularies being identical, and an enum without parents.
  • On pondie main with its submodule at this branch's head, every schema check passes: pondie.schema.generate --check, checks.field_provenance, checks.linkml, checks.extraction_to_storage_map and checks.storage_parameter_priorities.

Downstream

  • Extraction models. The extraction schema's Modality gains four values, so the extraction models may need retraining before they emit them. Nothing has been retrained; that needs James's go-ahead and a budget.
  • Pins. After this merges:
    • pondie pins the merge commit (pyproject and submodule), then ns-pond (study_schema equal to pondie's);
    • neurostore#1962 pins it separately, building its modality database enum and parent mapping from Modality and value_children;
    • ns-pond's normalization/modality.py then reads its values and parents from here, in a follow-up PR.

🤖 Generated with Claude Code

jdkent and others added 2 commits November 23, 2026 13:53
Modality gains the four values ns-pond's acquisition_modality vocabulary uses
beyond the schema's: MRS (instantiates MRI), and iEEG, CT and physiological
(instantiate OtherModality). Each refining value names the coarser one with
`is_a`: fMRI, sMRI, dMRI and MRS refine MRI, and iEEG, CT and physiological
refine other.

The generator writes those parents onto the enum's JSON Schema definition as
`x-parents`, and `study_schema.jsonschema.value_parents` / `value_children`
read them, so neurostore and ns-pond can take the vocabulary and its
hierarchy from here instead of copying them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ity values

`pondie.schema.generate` (pondie main) projects the storage Modality, with its
`is_a` parents, into neuroimaging-study-extraction/acquisition.yaml; the
extraction models and JSON Schema are regenerated from it. The tutorial's
modality table lists the new values and their parents.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@jdkent jdkent left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jdkent
jdkent merged commit abf53f5 into main Nov 24, 2026
6 checks passed
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