Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FSL
fslpy
Commits
23c46fa1
Commit
23c46fa1
authored
5 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
RF: bids module updated to support files with any extension.
parent
3b8bc0af
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/utils/bids.py
+7
-3
7 additions, 3 deletions
fsl/utils/bids.py
with
7 additions
and
3 deletions
fsl/utils/bids.py
+
7
−
3
View file @
23c46fa1
...
@@ -83,7 +83,11 @@ def parseFilename(filename):
...
@@ -83,7 +83,11 @@ def parseFilename(filename):
sub-01_ses-01_task-stim_bold.nii.gz
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:
:returns: A tuple containing:
- A dict containing the entities
- A dict containing the entities
...
@@ -97,7 +101,7 @@ def parseFilename(filename):
...
@@ -97,7 +101,7 @@ def parseFilename(filename):
suffix
=
None
suffix
=
None
entities
=
[]
entities
=
[]
filename
=
op
.
basename
(
filename
)
filename
=
op
.
basename
(
filename
)
filename
=
fslpath
.
removeExt
(
filename
,
[
'
.nii
'
,
'
.nii.gz
'
,
'
.json
'
]
)
filename
=
fslpath
.
removeExt
(
filename
,
firstDot
=
True
)
parts
=
filename
.
split
(
'
_
'
)
parts
=
filename
.
split
(
'
_
'
)
for
part
in
parts
[:
-
1
]:
for
part
in
parts
[:
-
1
]:
...
@@ -148,7 +152,7 @@ def isBIDSFile(filename, strict=True):
...
@@ -148,7 +152,7 @@ def isBIDSFile(filename, strict=True):
"""
"""
name
=
op
.
basename
(
filename
)
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
flags
=
re
.
ASCII
|
re
.
IGNORECASE
match
=
re
.
fullmatch
(
pattern
,
name
,
flags
)
is
not
None
match
=
re
.
fullmatch
(
pattern
,
name
,
flags
)
is
not
None
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment