Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Michiel Cottaar
fslpy
Commits
92466953
Commit
92466953
authored
5 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Support resampling images with more than 3 dimensions
parent
434b82f6
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/scripts/resample_image.py
+38
-2
38 additions, 2 deletions
fsl/scripts/resample_image.py
with
38 additions
and
2 deletions
fsl/scripts/resample_image.py
+
38
−
2
View file @
92466953
...
...
@@ -20,6 +20,40 @@ import fsl.utils.image.resample as resample
import
fsl.data.image
as
fslimage
def
intlist
(
val
):
"""
Turn a string of comma-separated ints into a list of ints.
"""
return
[
int
(
v
)
for
v
in
val
.
split
(
'
,
'
)]
def
floatlist
(
val
):
"""
Turn a string of comma-separated floats into a list of floats.
"""
return
[
float
(
v
)
for
v
in
val
.
split
(
'
,
'
)]
def
sanitiseList
(
parser
,
vals
,
img
,
arg
):
"""
Make sure that ``vals`` has the same number of elements as ``img`` has
dimensions. Used to sanitise the ``--shape`` and ``--dim`` options.
"""
if
vals
is
None
:
return
vals
nvals
=
len
(
vals
)
if
nvals
<
3
:
parser
.
error
(
'
At least three values are
'
'
required for {}
'
.
format
(
arg
))
if
nvals
>
img
.
ndim
:
parser
.
error
(
'
Input only has {} dimensions - too many values
'
'
specified for {}
'
.
format
(
img
.
ndim
,
arg
))
if
nvals
<
img
.
ndim
:
vals
=
list
(
vals
)
+
list
(
img
.
shape
[
nvals
:])
return
vals
ARGS
=
{
'
input
'
:
(
'
input
'
,),
'
output
'
:
(
'
output
'
,),
...
...
@@ -36,8 +70,8 @@ OPTS = {
'
input
'
:
dict
(
type
=
parse_data
.
Image
),
'
output
'
:
dict
(
type
=
parse_data
.
ImageOut
),
'
reference
'
:
dict
(
type
=
parse_data
.
Image
,
metavar
=
'
IMAGE
'
),
'
shape
'
:
dict
(
type
=
int
,
nargs
=
3
,
metavar
=
(
'
X
'
,
'
Y
'
,
'
Z
'
)),
'
dim
'
:
dict
(
type
=
float
,
nargs
=
3
,
metavar
=
(
'
X
'
,
'
Y
'
,
'
Z
'
)),
'
shape
'
:
dict
(
type
=
int
list
,
metavar
=
(
'
X
,Y,Z,...
'
)),
'
dim
'
:
dict
(
type
=
float
list
,
metavar
=
(
'
X
,Y,Z,...
'
)),
'
interp
'
:
dict
(
choices
=
(
'
nearest
'
,
'
linear
'
,
'
cubic
'
),
default
=
'
linear
'
),
'
origin
'
:
dict
(
choices
=
(
'
centre
'
,
'
corner
'
),
default
=
'
centre
'
),
...
...
@@ -110,6 +144,8 @@ def parseArgs(argv):
args
=
parser
.
parse_args
(
argv
)
args
.
interp
=
INTERPS
[
args
.
interp
]
args
.
dtype
=
DTYPES
.
get
(
args
.
dtype
,
args
.
input
.
dtype
)
args
.
shape
=
sanitiseList
(
parser
,
args
.
shape
,
args
.
input
,
'
shape
'
)
args
.
dim
=
sanitiseList
(
parser
,
args
.
dim
,
args
.
input
,
'
dim
'
)
return
args
...
...
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