fix(regex): Construct backreferences to ensure entity consistency #1889
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.
The regexes currently generated by bidsschematools were overly permissive, allowing mismatches between the entities in the directory and the entities in the filename. This was caught because the Python validator moved to depending on bidsschematools, and pybids has an additional battery of checks. (See bids-standard/pybids#1080.)
I've copied the failing checks in here as well as run pybids' test using this branch of bidsschematools.
Really, we shouldn't be using regexes, but doing it right is its own challenge and this fixes a known issue. Further, this does not handle the case where you might have, e.g.,
ses-siteA_dwi.json
that applies to one session across all subjects.For my future reference, to properly implement inheritance in regexes, we would need:
Figuring this out was enough of a task. Programmatically generating it doesn't seem worth it right now.