Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Michiel Cottaar
fslpy
Commits
8a8c3649
Commit
8a8c3649
authored
Feb 23, 2021
by
Paul McCarthy
🚵
Browse files
RF: Change filename check back to not requiring any entities, because e.g.
"T1w.json" is a valid sidecar file
parent
0b3df708
Changes
1
Hide whitespace changes
Inline
Side-by-side
fsl/utils/bids.py
View file @
8a8c3649
...
@@ -156,7 +156,7 @@ def inBIDSDir(filename):
...
@@ -156,7 +156,7 @@ def inBIDSDir(filename):
def
isBIDSFile
(
filename
,
strict
=
True
):
def
isBIDSFile
(
filename
,
strict
=
True
):
"""Returns ``True`` if ``filename`` looks like a BIDS image or JSON file.
"""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
``name-value`` pairs), a "suffix", all separated by underscores, and a
regular file extension. For example, the following file::
regular file extension. For example, the following file::
...
@@ -170,8 +170,12 @@ def isBIDSFile(filename, strict=True):
...
@@ -170,8 +170,12 @@ def isBIDSFile(filename, strict=True):
dataset directory, as defined by :func:`inBIDSDir`.
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
)
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
flags
=
re
.
ASCII
|
re
.
IGNORECASE
match
=
re
.
fullmatch
(
pattern
,
name
,
flags
)
is
not
None
match
=
re
.
fullmatch
(
pattern
,
name
,
flags
)
is
not
None
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment