Add Allen CCF location validation checks for mouse subjects#671
Add Allen CCF location validation checks for mouse subjects#671bendichter wants to merge 5 commits intodevfrom
Conversation
Validate location fields against Allen Mouse Brain CCF ontology terms when subject species is mouse. Adds checks for ImagingPlane.location, electrodes.location column, and IntracellularElectrode.location. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
a7c0450 to
2eaf1b1
Compare
h-mayorquin
left a comment
There was a problem hiding this comment.
I did the first reading.
Are you including all the tissue types at the level 1 of the hierarchy besides gray?
I think fiber tracts and level 1 ventricular system probably does not make sense for electrode localization but I guess there is not downside from including everything, is it?
src/nwbinspector/checks/_ophys.py
Outdated
| from .._registration import Importance, InspectorMessage, register_check | ||
| from ..utils import get_data_shape | ||
|
|
||
| MOUSE_SPECIES_VALUES = {"Mus musculus", "Mouse", "mouse", "http://purl.obolibrary.org/obo/NCBITaxon_10090"} |
There was a problem hiding this comment.
This is repeated across the sets, maybe we should centralize?
There was a problem hiding this comment.
Done — centralized into checks/_common.py and updated all three modules (_ophys.py, _ecephys.py, _icephys.py) to import from there.
| return None | ||
|
|
||
| location = imaging_plane.location | ||
| if location is None: |
There was a problem hiding this comment.
Isn't location required in the schema? If so, this if does not make sense, right?
There was a problem hiding this comment.
yeah, this is in case it was ever not required or it ever becomes not required. It can become a problem when checks throw errors, so I like to be extra careful about the existence of attributes.
There was a problem hiding this comment.
I thought that it ended up here just because the agents by default write overly defensive coding.
| return None | ||
| if nwbfile.electrodes is None: | ||
| return None | ||
| if "location" not in nwbfile.electrodes.colnames: |
There was a problem hiding this comment.
This is required on the schema as well.
There was a problem hiding this comment.
I'd prefer to leave it in in case it ever becomes optional
There was a problem hiding this comment.
Do we need to have this on the pypi distribution? I would just remove the script entirely but if you want to have it we should modify the hatchling configuration so this is not distributed.
There was a problem hiding this comment.
I like it staying in. It's clearly labelled within _internal_configs, and it would be useful if someone needs to regenerate these values with a new schema. What is the downside of keeping this in?
There was a problem hiding this comment.
I don't think people will know how to extract it from the wheel. Why would like it there? it is here on github which is the code that someone would get if they want to experiment at that level.
| valid_terms = get_allen_ccf_location_terms() | ||
| invalid_locations = set() | ||
| for location in nwbfile.electrodes["location"].data: | ||
| if location not in valid_terms and location not in invalid_locations: |
There was a problem hiding this comment.
This will make the matching case-sensitive, is this desirable?
There was a problem hiding this comment.
yes, the abbreviations are exact, including case. If they have the wrong case, that should be flagged.
There was a problem hiding this comment.
I don't think this is working as intended. This is a setuptools legacy letover and this project uses hatchling.
There was a problem hiding this comment.
ok, then lets remove it
There was a problem hiding this comment.
Good catch — reverted. The project uses hatchling, so MANIFEST.in has no effect. The JSON file is already included automatically since it lives under src/nwbinspector/.
Remove MANIFEST.in change (hatchling ignores it) and move the duplicated MOUSE_SPECIES_VALUES constant into checks/_common.py. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
for more information, see https://pre-commit.ci
The pyproject.toml skip list doesn't apply when pre-commit passes explicit filenames to codespell. Using exclude in the hook config prevents brain region abbreviations from being flagged as typos. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #671 +/- ##
==========================================
+ Coverage 78.41% 82.26% +3.84%
==========================================
Files 47 49 +2
Lines 1756 1821 +65
==========================================
+ Hits 1377 1498 +121
+ Misses 379 323 -56
🚀 New features to boost your workflow:
|
Summary
locationfields against Allen Mouse Brain CCF ontology terms when subject species is mouseImagingPlane.location,electrodes.locationcolumn, andIntracellularElectrode.locationCloses #670
Test plan
🤖 Generated with Claude Code