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
23c46fa1
Commit
23c46fa1
authored
Mar 18, 2020
by
Paul McCarthy
🚵
Browse files
RF: bids module updated to support files with any extension.
parent
3b8bc0af
Changes
1
Show whitespace changes
Inline
Side-by-side
fsl/utils/bids.py
View file @
23c46fa1
...
...
@@ -83,7 +83,11 @@ def parseFilename(filename):
sub-01_ses-01_task-stim_bold.nii.gz
has suffix ``bold``, and entities ``sub=01``, ``ses=01`` and ``task=stim``.
has suffix ``bold``, entities ``sub=01``, ``ses=01`` and ``task=stim``, and
extension ``.nii.gz``.
.. note:: This function assumes that no period (``.``) characters occur in
the body of a BIDS filename.
:returns: A tuple containing:
- A dict containing the entities
...
...
@@ -97,7 +101,7 @@ def parseFilename(filename):
suffix
=
None
entities
=
[]
filename
=
op
.
basename
(
filename
)
filename
=
fslpath
.
removeExt
(
filename
,
[
'.nii'
,
'.nii.gz'
,
'.json'
]
)
filename
=
fslpath
.
removeExt
(
filename
,
firstDot
=
True
)
parts
=
filename
.
split
(
'_'
)
for
part
in
parts
[:
-
1
]:
...
...
@@ -148,7 +152,7 @@ def isBIDSFile(filename, strict=True):
"""
name
=
op
.
basename
(
filename
)
pattern
=
r
'([a-z0-9]+-[a-z0-9]+_)*([a-z0-9])+\.(
nii|nii\.gz|json
)'
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
...
...
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