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
f879120a
Commit
f879120a
authored
4 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
ENH: New imrm script. fsl.scripts package is pkgutils, so can be used by other
projects
parent
54507efa
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
fsl/scripts/__init__.py
+8
-1
8 additions, 1 deletion
fsl/scripts/__init__.py
fsl/scripts/imrm.py
+62
-0
62 additions, 0 deletions
fsl/scripts/imrm.py
with
70 additions
and
1 deletion
fsl/scripts/__init__.py
+
8
−
1
View file @
f879120a
...
@@ -5,5 +5,12 @@
...
@@ -5,5 +5,12 @@
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
#
"""
The ``fsl.scripts`` package contains all of the executable scripts provided
"""
The ``fsl.scripts`` package contains all of the executable scripts provided
by ``fslpy``.
by ``fslpy``, and other python-based FSL packages.
.. note:: The ``fsl.scripts`` namespace is a ``pkgutil``-style *namespace
package* - it can be used across different projects - see
https://packaging.python.org/guides/packaging-namespace-packages/ for
details.
"""
"""
__path__
=
__import__
(
'
pkgutil
'
).
extend_path
(
__path__
,
__name__
)
# noqa
This diff is collapsed.
Click to expand it.
fsl/scripts/imrm.py
0 → 100644
+
62
−
0
View file @
f879120a
#!/usr/bin/env python
#
# imrm.py - Remove image files.
#
# Author: Paul McCarthy <paulmc@fmrib.ox.ac.uk>
#
"""
This module defines the ``imrm`` application, for removing NIFTI image
files.
"""
from
__future__
import
print_function
import
itertools
as
it
import
os.path
as
op
import
os
import
sys
import
warnings
import
contextlib
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: {} <list of image names to remove>
NB: filenames can be basenames or not
"""
.
strip
()
ALLOWED_EXTENSIONS
=
fslimage
.
ALLOWED_EXTENSIONS
+
[
'
.mnc
'
,
'
.mnc.gz
'
]
"""
List of file extensions that are removed by ``imrm``.
"""
def
main
(
argv
=
None
):
"""
Removes all images which are specified on the command line.
"""
if
argv
is
None
:
argv
=
sys
.
argv
if
len
(
argv
)
<
2
:
exe
=
op
.
abspath
(
argv
[
0
])
print
(
usage
.
format
(
exe
))
return
1
prefixes
=
[
fslpath
.
removeExt
(
p
,
ALLOWED_EXTENSIONS
)
for
p
in
argv
[
1
:]]
for
prefix
,
ext
in
it
.
product
(
prefixes
,
ALLOWED_EXTENSIONS
):
path
=
f
'
{
prefix
}{
ext
}
'
if
op
.
exists
(
path
):
os
.
remove
(
path
)
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