HERD integration: species ontology terms#1772
Open
bendichter wants to merge 5 commits into
Open
Conversation
Introduces `neuroconv.tools.ontology`, an offline, dependency-free lookup of common neuroscience species. `make_nwbfile_from_metadata` now: - emits a non-blocking suggestion (`validate_species`) when `Subject.species` is a recognized common name (e.g. "mouse") or a likely typo, pointing at the canonical Latin binomial and its NCBITaxon identifier; and - attaches a machine-readable NCBITaxon external-resource reference (`add_species_external_resource`) for a recognized binomial, stored in-file under `/general/external_resources` via HDMF's HERD, so downstream tools can resolve the term without guessing. The HERD is built with pynwb's type map (required for the `Subject.species` attribute to resolve) and the write is idempotent. In-file HERD storage relies on pynwb>=4.0.0, which is now the minimum pin. Closes #1771 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
for more information, see https://pre-commit.ci
The new neuroconv.tools.ontology submodule is attached to the tools namespace via nwb_helpers' import of add_species_external_resource, so test_tools' expected_structure must include it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add a user guide page covering the non-blocking species suggestion and the in-file NCBITaxon (HERD) annotation, an API reference page for neuroconv.tools.ontology, and wire both into their toctrees. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1772 +/- ##
==========================================
+ Coverage 82.40% 82.51% +0.10%
==========================================
Files 176 179 +3
Lines 13992 14080 +88
==========================================
+ Hits 11530 11618 +88
Misses 2462 2462
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1771.
What
Adds
neuroconv.tools.ontologyand wires it intomake_nwbfile_from_metadataso that a subject's species is both recommended in a standardized form and annotated with a machine-readable NCBITaxon reference in the written file.Two behaviors:
validate_specieswarns with a concrete recommendation whenSubject.speciesis a recognized common name (e.g."mouse") or a likely typo (e.g."Homo sapien"), pointing at the canonical Latin binomial and its NCBITaxon id (Mus musculus/NCBITaxon:10090). Valid-but-uncommon binomials pass silently.add_species_external_resourceattaches an external-resource reference mapping a recognizedSubject.speciesbinomial to its NCBITaxon entity, stored in-file under/general/external_resourcesvia HDMF's HERD. This is the HERD integration the issue asked for — downstream tools (e.g. DANDI) can resolve the term without guessing.The species table is a small curated, offline, dependency-free lookup of common neuroscience species (no network, no ontology client).
Notes
Subject.speciesattribute spec to resolve; without itadd_refraises. The write is idempotent and extends a pre-existingexternal_resourcesHERD in place rather than replacing it.Testing
tests/test_minimal/test_tools/test_ontology_species.py— table integrity, common-name/typo suggestions,get_species_termresolution, warning behavior.tests/test_minimal/test_tools/test_ontology_external_resources.py— no-op cases, annotation, idempotency, extend-in-place, and a full write→read round trip confirming the reference persists in the NWB file.🤖 Generated with Claude Code