Skip to content

Commit 1d4dbe0

Browse files
committed
Allow plus signs in labels (bids-standard/bids-specification#1926)
1 parent 7fe257d commit 1d4dbe0

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

bidscoin/bids.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,14 +1645,9 @@ def sanitize(label: Union[str, DataFormat, DataType]):
16451645
return ''
16461646
if not isinstance(label, (str, DataFormat, DataType)):
16471647
return label
1648-
label = str(label)
1648+
pattern = bidsschema.objects.formats.label.pattern[:-1].replace('[', '[^') # Schema pattern: '[0-9a-zA-Z+]+', see https://github.com/bids-standard/bids-specification/pull/1926/files
16491649

1650-
special_characters = (' ', '_', '-','.')
1651-
1652-
for special in special_characters:
1653-
label = label.strip().replace(special, '')
1654-
1655-
return re.sub(r'(?u)[^-\w.]', '', label)
1650+
return re.sub(pattern, '', str(label)) # Replace anything that NOT matches the pattern with ''
16561651

16571652

16581653
def match_runvalue(attribute, pattern) -> bool:

0 commit comments

Comments
 (0)