Skip to content

Accept C. elegans sex from ndx-subjects' c_elegans_sex - #774

Merged
bendichter merged 2 commits into
NeurodataWithoutBorders:devfrom
dandi:c-elegans-sex-ndx-subjects
Nov 5, 2026
Merged

bendichter merged 2 commits into
NeurodataWithoutBorders:devfrom
dandi:c-elegans-sex-ndx-subjects

Conversation

@yarikoptic

Copy link
Copy Markdown
Contributor

Motivation

check_subject_sex (CRITICAL in the dandi config) requires Subject.sex to be XX (hermaphrodite) or XO (male) when the species is C. elegans. The CElegansSubject type of ndx-subjects instead fixes sex to "O", and records XX/XO in a separate c_elegans_sex field (for example DANDI:001075). Every such file therefore fails check_subject_sex, and so fails dandi validate/dandi upload, even though the sex is recorded.

Discussed with @CodyCBakerPhD in

That PR makes dandi-cli read c_elegans_sex for the asset metadata.

Changes

  • check_subject_sex passes when c_elegans_sex is XX or XO and sex is "O" or unset.
  • The C. elegans message now names the c_elegans_sex alternative.
  • The "Subject Sex" best practice mentions the ndx-subjects case.
  • Tests use a Subject subclass with a c_elegans_sex attribute, standing in for CElegansSubject, so the tests do not depend on ndx-subjects. They cover both codes with sex "O" or unset, and an invalid c_elegans_sex.

Testing

  • tests/unit_tests: 345 passed, 7 skipped. pre-commit passes.

  • I wrote two NWB files with ndx-subjects 0.2.0, then ran inspect_nwbfile(..., config=load_config("dandi")) without ndx-subjects installed, so the extension came from the namespace cached in the file:

    file before after
    sex="O", c_elegans_sex="XO" check_subject_sex fails passes
    sex unset, c_elegans_sex="XX" n/a (not run) passes

A changelog entry (changelog_entries/<PR>.fix.md) will be added once the PR number is known.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NdN9xPzPo1AzsnEMuU8UQs

CElegansSubject of ndx-subjects fixes Subject.sex to "O" and records
XX (hermaphrodite) or XO (male) in a separate c_elegans_sex field (e.g.
DANDI:001075), so check_subject_sex flagged every such file even though
the sex is recorded.  Accept sex "O" (or unset) when c_elegans_sex is XX
or XO.

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

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.21%. Comparing base (fe72b42) to head (65ff014).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##              dev     #774      +/-   ##
==========================================
+ Coverage   86.30%   89.21%   +2.90%     
==========================================
  Files          48       48              
  Lines        2001     2003       +2     
==========================================
+ Hits         1727     1787      +60     
+ Misses        274      216      -58     
Files with missing lines Coverage Δ
src/nwbinspector/checks/_nwbfile_metadata.py 96.63% <100.00%> (+0.03%) ⬆️

... and 4 files with indirect coverage changes

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

@bendichter
bendichter merged commit 8f2a3d7 into NeurodataWithoutBorders:dev Nov 5, 2026
25 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.

4 participants