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

[ENH] Allow plus signs in labels #1926

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
4 changes: 2 additions & 2 deletions CODEOWNERS
yarikoptic marked this conversation as resolved.
Show resolved Hide resolved
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
/src/derivatives/diffusion-derivatives.md @francopestilli @oesteban @Lestropie

# The schema
/src/schema/ @tsalo @erdalkaraca
/tools/schemacode/ @tsalo @erdalkaraca
/src/schema/ @erdalkaraca
/tools/schemacode/ @erdalkaraca
9 changes: 7 additions & 2 deletions src/schema/objects/formats.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ index:
label:
display_name: Label
description: |
Freeform labels without special characters.
pattern: '[0-9a-zA-Z]+'
Free-form labels with alphanumeric and plus (+) characters.

Plus signs MAY be used to concatenate multiple applicable labels,
but no relationship is established by a partial match.
In particular, the inheritance principle does not connect files
containing "ent-X+Y" and "ent-X" or "ent-Y".
tsalo marked this conversation as resolved.
Show resolved Hide resolved
pattern: '[0-9a-zA-Z+]+'
# Metadata types
boolean:
display_name: Boolean
Expand Down
8 changes: 4 additions & 4 deletions tools/schemacode/bidsschematools/tests/test_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def test_entity_rule(schema_obj):
nii_rule = rules._entity_rule(rule, schema_obj)
assert nii_rule == {
"regex": (
r"sub-(?P<subject>[0-9a-zA-Z]+)/"
r"(?:ses-(?P<session>[0-9a-zA-Z]+)/)?"
r"sub-(?P<subject>[0-9a-zA-Z+]+)/"
r"(?:ses-(?P<session>[0-9a-zA-Z+]+)/)?"
r"(?P<datatype>anat)/"
r"(?(subject)sub-(?P=subject)_)"
r"(?(session)ses-(?P=session)_)"
Expand Down Expand Up @@ -50,8 +50,8 @@ def test_entity_rule(schema_obj):
json_rule = rules._entity_rule(rule, schema_obj)
assert json_rule == {
"regex": (
r"(?:sub-(?P<subject>[0-9a-zA-Z]+)/)?"
r"(?:ses-(?P<session>[0-9a-zA-Z]+)/)?"
r"(?:sub-(?P<subject>[0-9a-zA-Z+]+)/)?"
r"(?:ses-(?P<session>[0-9a-zA-Z+]+)/)?"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am afraid that is not all ... I will push a few commits on that end in a few minutes (I hope you don't mind).
Some other might need adjustment and I even start feeling that we might need to come up with some term (like "literal" but there might be better) to encompass "alphanumeric" and +.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yarikoptic Note this is a regression test that shows the specific output of a specific synthetic rule.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my comment is not really about this test -- I meant that changes in this PR (just this test) aren't sufficient. pushed now

r"(?:(?P<datatype>anat)/)?"
r"(?(subject)sub-(?P=subject)_)"
r"(?(session)ses-(?P=session)_)"
Expand Down