Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify 'or' requirement in message for subject age + DOB #411

Merged
merged 13 commits into from
Oct 26, 2023
11 changes: 6 additions & 5 deletions src/nwbinspector/checks/nwbfile_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,12 @@ def check_doi_publications(nwbfile: NWBFile):
@register_check(importance=Importance.BEST_PRACTICE_SUGGESTION, neurodata_type=Subject)
def check_subject_age(subject: Subject):
"""Check if the Subject age is in ISO 8601 or our extension of it for ranges."""
if subject.age is None:
if subject.date_of_birth is None:
return InspectorMessage(message="Subject is missing age and date_of_birth.")
else:
return
if subject.age is None and subject.date_of_birth is None:
return InspectorMessage(
message="Subject is missing age and date_of_birth. Please specify at least one of these fields."
)
elif subject.age is None and subject.date_of_birth is not None:
return
if re.fullmatch(pattern=duration_regex, string=subject.age):
return

Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/test_nwbfile_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def test_pass_check_subject_age_with_dob():
def test_check_subject_age_missing():
subject = Subject(subject_id="001")
assert check_subject_age(subject) == InspectorMessage(
message="Subject is missing age and date_of_birth.",
message="Subject is missing age and date_of_birth. Please specify at least one of these fields.",
importance=Importance.BEST_PRACTICE_SUGGESTION,
check_function_name="check_subject_age",
object_type="Subject",
Expand Down
Loading