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
1abeddcc
Commit
1abeddcc
authored
5 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
ENH,RF: Deprecated Image.resample. New convenience wrappers -
resampleToPixdims and resampleToReference
parent
28921fe1
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/data/image.py
+3
-5
3 additions, 5 deletions
fsl/data/image.py
fsl/utils/image/resample.py
+37
-0
37 additions, 0 deletions
fsl/utils/image/resample.py
with
40 additions
and
5 deletions
fsl/data/image.py
+
3
−
5
View file @
1abeddcc
...
...
@@ -1165,12 +1165,10 @@ class Image(Nifti):
self
.
notify
(
topic
=
'
saveState
'
)
@deprecated.deprecated
(
'
2.2.0
'
,
'
3.0.0
'
,
'
Use fsl.utils.image.resample instead.
'
)
def
resample
(
self
,
*
args
,
**
kwargs
):
"""
Returns a copy of the data in this ``Image``, resampled to the
specified ``newShape``.
See the :mod:`.image.resample` module for more details.
"""
"""
Deprecated - use :func:`.image.resample` instead.
"""
from
fsl.utils.image.resample
import
resample
return
resample
(
self
,
*
args
,
**
kwargs
)
...
...
This diff is collapsed.
Click to expand it.
fsl/utils/image/resample.py
+
37
−
0
View file @
1abeddcc
...
...
@@ -7,6 +7,9 @@
"""
This module defines the :func:`resample` function, which can be used
to resample an :class:`.Image` object to a different resolution.
The :func:`resampleToPixdims` and :func:`resampleToReference` functions
are convenience wrappers around :func:`resample`.
The :func:`applySmoothing` and :func:`calculateMatrix` functions are
sub-functions of :func:`resample`.
"""
...
...
@@ -20,6 +23,40 @@ import scipy.ndimage as ndimage
import
fsl.utils.transform
as
transform
def
resampleToPixdims
(
image
,
newPixdims
,
**
kwargs
):
"""
Resample ``image`` so that it has the specified voxel dimensions.
This is a wrapper around :func:`resample` - refer to its documenttion
for details on the other arguments and the return values.
:arg image: :class:`.Image` to resample
:arg pixdims: New voxel dimensions to resample ``image`` to.
"""
oldShape
=
image
.
shape
oldPixdims
=
image
.
pixdim
fac
=
[
o
/
float
(
n
)
for
o
,
n
in
zip
(
oldPixdims
,
newPixdims
)]
newShape
=
[
p
*
f
for
p
,
f
in
zip
(
oldShape
,
fac
)]
return
resample
(
image
,
newShape
,
**
kwargs
)
def
resampleToReference
(
image
,
reference
,
**
kwargs
):
"""
Resample ``image`` into the space of the ``reference``.
This is a wrapper around :func:`resample` - refer to its documenttion
for details on the other arguments and the return values.
:arg image: :class:`.Image` to resample
:arg reference: :class:`.Nifti` defining the space to resample ``image``
into
"""
kwargs
[
'
mode
'
]
=
kwargs
.
get
(
'
mode
'
,
'
constant
'
)
kwargs
[
'
newShape
'
]
=
reference
.
shape
kwargs
[
'
matrix
'
]
=
transform
.
concat
(
image
.
worldToVoxMat
,
reference
.
voxToWorldMat
)
return
resample
(
image
,
**
kwargs
)
def
resample
(
image
,
newShape
,
sliceobj
=
None
,
...
...
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