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
89be1aba
Commit
89be1aba
authored
4 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
ENH: new remove_ext script, minor adjustments to imrm
parent
e430a1bc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
fsl/scripts/imrm.py
+5
-6
5 additions, 6 deletions
fsl/scripts/imrm.py
fsl/scripts/remove_ext.py
+51
-0
51 additions, 0 deletions
fsl/scripts/remove_ext.py
with
56 additions
and
6 deletions
fsl/scripts/imrm.py
+
5
−
6
View file @
89be1aba
...
...
@@ -23,7 +23,7 @@ with warnings.catch_warnings():
import
fsl.data.image
as
fslimage
usage
=
"""
Usage:
{}
<list of image names to remove>
usage
=
"""
Usage:
imrm
<list of image names to remove>
NB: filenames can be basenames or not
"""
.
strip
()
...
...
@@ -36,14 +36,13 @@ def main(argv=None):
"""
Removes all images which are specified on the command line.
"""
if
argv
is
None
:
argv
=
sys
.
argv
argv
=
sys
.
argv
[
1
:]
if
len
(
argv
)
<
2
:
exe
=
op
.
abspath
(
argv
[
0
])
print
(
usage
.
format
(
exe
))
if
len
(
argv
)
<
1
:
print
(
usage
)
return
1
prefixes
=
[
fslpath
.
removeExt
(
p
,
ALLOWED_EXTENSIONS
)
for
p
in
argv
[
1
:]
]
prefixes
=
[
fslpath
.
removeExt
(
p
,
ALLOWED_EXTENSIONS
)
for
p
in
argv
]
for
prefix
,
ext
in
it
.
product
(
prefixes
,
ALLOWED_EXTENSIONS
):
...
...
This diff is collapsed.
Click to expand it.
fsl/scripts/remove_ext.py
0 → 100644
+
51
−
0
View file @
89be1aba
#!/usr/bin/env python
#
# remove_ext.py - Remove file extensions from NIFTI image paths
#
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
import
sys
import
warnings
import
fsl.utils.path
as
fslpath
# See atlasq.py for explanation
with
warnings
.
catch_warnings
():
warnings
.
filterwarnings
(
"
ignore
"
,
category
=
FutureWarning
)
import
fsl.data.image
as
fslimage
usage
=
"""
Usage: remove_ext <list of image paths to remove extension from>
"""
.
strip
()
ALLOWED_EXTENSIONS
=
fslimage
.
ALLOWED_EXTENSIONS
+
[
'
.mnc
'
,
'
.mnc.gz
'
]
"""
List of file extensions that are removed by ``remove_ext``.
"""
def
main
(
argv
=
None
):
"""
Removes file extensions from all paths which are specified on the
command line.
"""
if
argv
is
None
:
argv
=
sys
.
argv
[
1
:]
if
len
(
argv
)
<
1
:
print
(
usage
)
return
1
removed
=
[]
for
path
in
argv
:
removed
.
append
(
fslpath
.
removeExt
(
path
,
ALLOWED_EXTENSIONS
))
print
(
'
'
.
join
(
removed
))
return
0
if
__name__
==
'
__main__
'
:
sys
.
exit
(
main
())
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