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
Package registry
Model registry
Operate
Environments
Terraform modules
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
Evan Edmond
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
No related tags found
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):
...
@@ -1165,12 +1165,10 @@ class Image(Nifti):
self
.
notify
(
topic
=
'
saveState
'
)
self
.
notify
(
topic
=
'
saveState
'
)
@deprecated.deprecated
(
'
2.2.0
'
,
'
3.0.0
'
,
'
Use fsl.utils.image.resample instead.
'
)
def
resample
(
self
,
*
args
,
**
kwargs
):
def
resample
(
self
,
*
args
,
**
kwargs
):
"""
Returns a copy of the data in this ``Image``, resampled to the
"""
Deprecated - use :func:`.image.resample` instead.
"""
specified ``newShape``.
See the :mod:`.image.resample` module for more details.
"""
from
fsl.utils.image.resample
import
resample
from
fsl.utils.image.resample
import
resample
return
resample
(
self
,
*
args
,
**
kwargs
)
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 @@
...
@@ -7,6 +7,9 @@
"""
This module defines the :func:`resample` function, which can be used
"""
This module defines the :func:`resample` function, which can be used
to resample an :class:`.Image` object to a different resolution.
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
The :func:`applySmoothing` and :func:`calculateMatrix` functions are
sub-functions of :func:`resample`.
sub-functions of :func:`resample`.
"""
"""
...
@@ -20,6 +23,40 @@ import scipy.ndimage as ndimage
...
@@ -20,6 +23,40 @@ import scipy.ndimage as ndimage
import
fsl.utils.transform
as
transform
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
,
def
resample
(
image
,
newShape
,
newShape
,
sliceobj
=
None
,
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