Skip to content
Snippets Groups Projects
Commit 8a8c3649 authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

RF: Change filename check back to not requiring any entities, because e.g.

"T1w.json" is a valid sidecar file
parent 0b3df708
No related branches found
No related tags found
No related merge requests found
......@@ -156,7 +156,7 @@ def inBIDSDir(filename):
def isBIDSFile(filename, strict=True):
"""Returns ``True`` if ``filename`` looks like a BIDS image or JSON file.
A BIDS file name must consist of one or more "entities" (alpha-numeric
A BIDS file name must consist of zero or more "entities" (alpha-numeric
``name-value`` pairs), a "suffix", all separated by underscores, and a
regular file extension. For example, the following file::
......@@ -170,8 +170,12 @@ def isBIDSFile(filename, strict=True):
dataset directory, as defined by :func:`inBIDSDir`.
"""
# Zero or more entities because sidecar files
# do not necessarily need to contain any
# entities (e.g. ``T1w.json`` is valid)
name = op.basename(filename)
pattern = r'([a-z0-9]+-[a-z0-9]+_)+([a-z0-9])+\.(.+)'
pattern = r'([a-z0-9]+-[a-z0-9]+_)*([a-z0-9])+\.(.+)'
flags = re.ASCII | re.IGNORECASE
match = re.fullmatch(pattern, name, flags) is not None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment