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
a69bd9e4
Commit
a69bd9e4
authored
6 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
RF: Image.resample supports data with more than 3 dimensions.
parent
16496d1d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/data/image.py
+9
-8
9 additions, 8 deletions
fsl/data/image.py
with
9 additions
and
8 deletions
fsl/data/image.py
+
9
−
8
View file @
a69bd9e4
...
@@ -1173,7 +1173,7 @@ class Image(Nifti):
...
@@ -1173,7 +1173,7 @@ class Image(Nifti):
order
=
1
,
order
=
1
,
smooth
=
True
):
smooth
=
True
):
"""
Returns a copy of the data in this ``Image``, resampled to the
"""
Returns a copy of the data in this ``Image``, resampled to the
specified ``
s
hape``.
specified ``
newS
hape``.
:arg newShape: Desired shape. May containg floating point values,
:arg newShape: Desired shape. May containg floating point values,
in which case the resampled image will have shape
in which case the resampled image will have shape
...
@@ -1182,7 +1182,7 @@ class Image(Nifti):
...
@@ -1182,7 +1182,7 @@ class Image(Nifti):
:arg sliceobj: Slice into this ``Image``. If ``None``, the whole
:arg sliceobj: Slice into this ``Image``. If ``None``, the whole
image is resampled, and it is assumed that it has the
image is resampled, and it is assumed that it has the
same number of dimensions as ``
s
hape``. A
same number of dimensions as ``
newS
hape``. A
:exc:`ValueError` is raised if this is not the case.
:exc:`ValueError` is raised if this is not the case.
:arg dtype: ``numpy`` data type of the resampled data. If ``None``,
:arg dtype: ``numpy`` data type of the resampled data. If ``None``,
...
@@ -1201,12 +1201,12 @@ class Image(Nifti):
...
@@ -1201,12 +1201,12 @@ class Image(Nifti):
:returns: A tuple containing:
:returns: A tuple containing:
- A ``numpy`` array of shape ``
s
hape``, containing
an
- A ``numpy`` array of shape ``
newS
hape``, containing
interpolated copy of the data in this ``Image``.
an
interpolated copy of the data in this ``Image``.
- A ``numpy`` array of shape ``(4, 4)``, containing the
- A ``numpy`` array of shape ``(4, 4)``, containing the
adjusted voxel-to-world transformation for the
resampled
adjusted voxel-to-world transformation for the
spatial
data.
dimensions of the resampled
data.
"""
"""
if
sliceobj
is
None
:
sliceobj
=
slice
(
None
)
if
sliceobj
is
None
:
sliceobj
=
slice
(
None
)
...
@@ -1225,7 +1225,7 @@ class Image(Nifti):
...
@@ -1225,7 +1225,7 @@ class Image(Nifti):
ratio
=
oldShape
/
newShape
ratio
=
oldShape
/
newShape
newShape
=
np
.
array
(
np
.
round
(
newShape
),
dtype
=
np
.
int
)
newShape
=
np
.
array
(
np
.
round
(
newShape
),
dtype
=
np
.
int
)
scale
=
transform
.
scaleOffsetXform
(
ratio
,
0
)
scale
=
np
.
diag
(
ratio
)
# If interpolating and smoothing, we apply a
# If interpolating and smoothing, we apply a
# gaussian filter along axes with a resampling
# gaussian filter along axes with a resampling
...
@@ -1242,7 +1242,7 @@ class Image(Nifti):
...
@@ -1242,7 +1242,7 @@ class Image(Nifti):
data
=
ndimage
.
gaussian_filter
(
data
,
sigma
)
data
=
ndimage
.
gaussian_filter
(
data
,
sigma
)
data
=
ndimage
.
affine_transform
(
data
,
data
=
ndimage
.
affine_transform
(
data
,
scale
[:
3
,
:
3
]
,
scale
,
output_shape
=
newShape
,
output_shape
=
newShape
,
order
=
order
)
order
=
order
)
...
@@ -1250,6 +1250,7 @@ class Image(Nifti):
...
@@ -1250,6 +1250,7 @@ class Image(Nifti):
# puts the resampled image into the
# puts the resampled image into the
# same world coordinate system as this
# same world coordinate system as this
# image.
# image.
scale
=
transform
.
scaleOffsetXform
(
ratio
[:
3
],
0
)
xform
=
transform
.
concat
(
self
.
voxToWorldMat
,
scale
)
xform
=
transform
.
concat
(
self
.
voxToWorldMat
,
scale
)
else
:
else
:
xform
=
self
.
voxToWorldMat
xform
=
self
.
voxToWorldMat
...
...
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