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
eee2c366
Commit
eee2c366
authored
5 years ago
by
Michiel Cottaar
Browse files
Options
Downloads
Patches
Plain Diff
BUG: check invalid characters in the FileTree
Also made small fixes to trees that contained invalid characters
parent
e8f0a5ad
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
fsl/utils/filetree/parse.py
+20
-0
20 additions, 0 deletions
fsl/utils/filetree/parse.py
fsl/utils/filetree/trees/HCP_Surface.tree
+1
-1
1 addition, 1 deletion
fsl/utils/filetree/trees/HCP_Surface.tree
fsl/utils/filetree/trees/freesurfer.tree
+2
-2
2 additions, 2 deletions
fsl/utils/filetree/trees/freesurfer.tree
with
23 additions
and
3 deletions
fsl/utils/filetree/parse.py
+
20
−
0
View file @
eee2c366
...
...
@@ -38,6 +38,21 @@ def list_all_trees() -> List[str]:
return
trees
def
check_forbidden_characters
(
text
,
characters
,
text_type
):
"""
Checks the text for forbidden characters
raises ValueError if one is found
:param text: string with the text
:param characters: sequence of forbidden characters
:param text_type: type of the text to raise in error message
"""
bad
=
[
character
for
character
in
characters
if
character
in
text
]
if
len
(
bad
)
>
0
:
raise
ValueError
(
f
'
Invalid character(s)
"
{
""
.
join
(
bad
)
}
"
in
{
text_type
}
:
{
text
}
'
)
def
read_line
(
line
:
str
)
->
Tuple
[
int
,
PurePath
,
str
]:
"""
Parses line from the tree file
...
...
@@ -54,11 +69,14 @@ def read_line(line: str) -> Tuple[int, PurePath, str]:
match
=
re
.
match
(
r
'
^(\s*)(\S*)\s*\((\S*)\)\s*$
'
,
line
)
if
match
is
not
None
:
gr
=
match
.
groups
()
check_forbidden_characters
(
gr
[
1
],
r
'
<>
"
/\|?*
'
,
'
file or directory name
'
)
check_forbidden_characters
(
gr
[
2
],
r
'
(){}/
'
,
'
short name
'
)
return
len
(
gr
[
0
]),
PurePath
(
gr
[
1
]),
gr
[
2
]
match
=
re
.
match
(
r
'
^(\s*)(\S*)\s*$
'
,
line
)
if
match
is
not
None
:
gr
=
match
.
groups
()
short_name
=
gr
[
1
].
split
(
'
.
'
)[
0
]
check_forbidden_characters
(
gr
[
1
],
r
'
<>
"
/\|?*
'
,
'
file or directory name
'
)
return
len
(
gr
[
0
]),
PurePath
(
gr
[
1
]),
short_name
raise
ValueError
(
'
Unrecognized line %s
'
%
line
)
...
...
@@ -79,6 +97,8 @@ def read_subtree_line(line: str, directory: str) -> Tuple[int, "filetree.FileTre
if
match
is
None
:
raise
ValueError
(
"
Sub-tree line could not be parsed: {}
"
.
format
(
line
.
strip
()))
spaces
,
type_name
,
variables_str
,
short_name
=
match
.
groups
()
check_forbidden_characters
(
type_name
,
r
'
<>:
"
/\|?*
'
,
'
sub-tree name
'
)
check_forbidden_characters
(
short_name
,
r
'
(){}/
'
,
'
sub-tree name
'
)
variables
=
{}
if
len
(
variables_str
.
strip
())
!=
0
:
...
...
This diff is collapsed.
Click to expand it.
fsl/utils/filetree/trees/HCP_Surface.tree
+
1
−
1
View file @
eee2c366
...
...
@@ -27,6 +27,6 @@
{subject}.sulc_MSMAll.{space}.dscalar.nii (sulc_msm_cifti)
{subject}.thickness_MSMAll.{space}.dscalar.nii (thick_msm_cifti)
{subject}.curvature_MSMAll.{space}.dscalar.nii (curv_msm_cifti)
{subject}.BA.32k_fs_LR.dlabel.nii (BA_cifti)
)
{subject}.BA.32k_fs_LR.dlabel.nii (BA_cifti)
{subject}.aparc.32k_fs_LR.dlabel.nii (aparc_cifti)
{subject}.aparc.a2009s.32k_fs_LR.dlabel.nii (aparc2009_cifti)
This diff is collapsed.
Click to expand it.
fsl/utils/filetree/trees/freesurfer.tree
+
2
−
2
View file @
eee2c366
...
...
@@ -67,10 +67,10 @@
aparc.a2009s+aseg.mgz (aparc_a2009s_aseg)
aseg.mgz
label
/
label
{hemi}h.aparc.annot (aparc.annot)
stats
/
stats
aseg.stats (aseg_stats)
wmparc.stats (wmparc_stats)
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