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
2d665092
Commit
2d665092
authored
7 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Image.reample method allows data type to be specified
parent
1bf67e0e
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/data/image.py
+7
-4
7 additions, 4 deletions
fsl/data/image.py
with
7 additions
and
4 deletions
fsl/data/image.py
+
7
−
4
View file @
2d665092
...
...
@@ -1116,12 +1116,15 @@ class Image(Nifti):
self
.
notify
(
topic
=
'
saveState
'
)
def
resample
(
self
,
shape
,
sliceobj
=
None
,
**
kwargs
):
def
resample
(
self
,
shape
,
sliceobj
=
None
,
dtype
=
None
,
**
kwargs
):
"""
Returns a copy of the data in this ``Image``, resampled to the
specified ``shape``.
:arg shape: Desired shape
:arg dtype: ``numpy`` data type of the resampled data. If ``None``,
the :meth:`dtype` of this ``Image`` is used.
:arg sliceobj: Slice into this ``Image``. If ``None``, the whole
image is resampled, and it is assumed that it has the
same number of dimensions as ``shape``.
...
...
@@ -1133,14 +1136,14 @@ class Image(Nifti):
interpolated copy of the data in this ``Image``.
"""
if
sliceobj
is
None
:
sliceobj
=
slice
(
None
)
if
sliceobj
is
None
:
sliceobj
=
slice
(
None
)
if
dtype
is
None
:
dtype
=
self
.
dtype
ndims
=
len
(
shape
)
data
=
self
[
sliceobj
]
if
tuple
(
data
.
shape
)
!=
tuple
(
shape
):
data
=
np
.
array
(
data
,
dtype
=
np
.
float
,
copy
=
False
)
data
=
np
.
array
(
data
,
dtype
=
dtype
,
copy
=
False
)
zooms
=
[
float
(
shape
[
i
])
/
data
.
shape
[
i
]
for
i
in
range
(
ndims
)]
data
=
ndimage
.
zoom
(
data
,
zooms
,
**
kwargs
)
...
...
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