Skip to content

Preserve NWB subject age-reference metadata - #1931

Open
AtomicGlance wants to merge 2 commits into
dandi:masterfrom
AtomicGlance:fix/1242-age-reference
Open

AtomicGlance wants to merge 2 commits into
dandi:masterfrom
AtomicGlance:fix/1242-age-reference

Conversation

@AtomicGlance

Copy link
Copy Markdown
Contributor

Fixes #1242.

NWB subjects can store a gestational age as an ordinary duration such as P3W, with its meaning supplied by age__reference. That reference was not included in the extracted metadata, so the duration became birth-referenced.

This includes age__reference in subject metadata and uses a gestational reference when converting the age. Existing gestational-prefix strings remain supported. When age is calculated from date of birth and session start, it remains birth-referenced; that calculation is unchanged.

Tests cover birth and gestational references through an NWB write/read round trip, legacy strings and missing references, and date-of-birth precedence.

Local validation on Windows/Python 3.13:

  • Metadata tests excluding BIDS, ontology/network and remote-asset cases: 153 passed, 2 existing expected-failure tests unexpectedly passed, 11 deselected.
  • Black, isort and flake8 passed.
  • mypy dandi: no issues in 96 source files.

The full integration suite has not been run locally.

@codecov

codecov Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.37%. Comparing base (c3931cc) to head (17c1cc1).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1931      +/-   ##
==========================================
+ Coverage   78.29%   78.37%   +0.07%     
==========================================
  Files          92       92              
  Lines       14068    14101      +33     
==========================================
+ Hits        11015    11051      +36     
+ Misses       3053     3050       -3     
Flag Coverage Δ
unittests 78.37% <100.00%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AtomicGlance

Copy link
Copy Markdown
Contributor Author

Could a maintainer please add the patch label to this PR and #1932 when convenient? Both are bug fixes, and their label checks are failing because no release-category label is set. Thank you!

Comment thread dandi/tests/test_metadata.py Outdated
@AtomicGlance

Copy link
Copy Markdown
Contributor Author

some relevant (and not finished :-/ ) work in BIDS and near:

* [Formalize participants' age to clarify the reference point bids-standard/bids-specification#1634](https://github.com/bids-standard/bids-specification/issues/1634)

* [[ENH] Additional age related columns for participants.tsv file to cover animal data bids-standard/bids-specification#1839](https://github.com/bids-standard/bids-specification/pull/1839)

* [[ENH] Additional age related columns for participants.tsv file to cover animal data contd. bids-standard/bids-specification#2340](https://github.com/bids-standard/bids-specification/pull/2340)

* [Add AgeReference for non-birth based age con/nwb2bids#420](https://github.com/con/nwb2bids/issues/420)

Thanks for sharing these, Yaroslav! It’s helpful to see how this connects to the work on age references in BIDS, and I’m glad the PR sparked the nwb2bids discussion too. I’ll read through the proposals to get a better understanding.

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.

parse age reference

2 participants