Repository navigation
Extract asset anatomy from HERD ontology links - #1980
Draft
bendichter wants to merge 1 commit into
Draft
bendichter wants to merge 1 commit into
bendichter wants to merge 1 commit into
Conversation
Collect UBERON and MBA entities linked in an NWB file's HERD table and put them in wasDerivedFrom[BioSample].anatomy, for any species. HERD links take precedence over string matching of location values. Entities linked only from Subject objects are skipped, since UBERON also holds life-stage terms that may be linked from Subject.age. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1980 +/- ##
==========================================
+ Coverage 91.18% 91.26% +0.08%
==========================================
Files 95 95
Lines 14740 14872 +132
==========================================
+ Hits 13440 13573 +133
+ Misses 1300 1299 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 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.
Addresses #1979.
What this does
pynwb_utils._get_herd_anatomyreads the file's HERD table (nwb.external_resources) and collects every entity with aUBERON:orMBA:ID, whatever object or field it is linked from. Entities linked only fromSubjectobjects are skipped: UBERON also holds life-stage terms that may be linked fromSubject.age. The result goes into the metadata dict asherd_anatomy.brain_areas.herd_anatomy_to_modelsturns those into deduplicatedAnatomymodels. HERD stores no labels, so the name comes from the bundled Allen CCF table forMBA:terms, else the longest value in the file linked to the term (sotrapezius musclebeatsEMG), else the entity ID._extract_brain_anatomyuses HERD anatomy first, for any species, and falls back to the existing mouse-only string matching from feat: extract brain area anatomy from NWB location fields #1807. The terms land in the same place:wasDerivedFrom[BioSample].anatomy, on the syntheticbrain-region-samplewhen there's no tissue/slice/cell ID.The HERD tables are read directly rather than through
HERD.to_dataframe(), because that call raises a pandas deprecation warning that the test config turns into an error.Checked on DANDI:001888
On
sub-GRIN2B-129/sub-GRIN2B-129_ses-2021-03-26_ecephys.nwb(rat, so #1807 extracts nothing), streamed from S3:The species, strain and genotype links in the same table are left out. Most names are lab abbreviations. Once #1825 lands, its bundled UBERON table can supply real labels through
_ontology_label; I left that out to keep this PR independent of #1825.Not done here
cortexwhen more specific ones are present, and stimulus body parts.AssetsSummary, which needs a dandi-schema change.Tests
Subject.agelife-stage term skipped), a mouse file where HERD wins over Allen matching, label/dedupe rules, and HERD anatomy without a species.test_metadata.py,test_pynwb_utils.pyandtest_brain_areas.pypass locally except three BIDS tests that needbids-validator-deno, which isn't installed here (they fail on master too). mypy and pre-commit are clean.🤖 Generated with Claude Code