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
d92f8e0f
Commit
d92f8e0f
authored
5 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
BF: Fix up adjust method
parent
8393c2bd
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
+15
-11
15 additions, 11 deletions
fsl/data/image.py
fsl/transform/affine.py
+1
-1
1 addition, 1 deletion
fsl/transform/affine.py
with
16 additions
and
12 deletions
fsl/data/image.py
+
15
−
11
View file @
d92f8e0f
...
...
@@ -864,22 +864,26 @@ class Nifti(notifier.Notifier, meta.Meta):
raise
ValueError
(
'
Exactly one of pixdim or
'
'
shape must be specified
'
)
if
shape
is
not
None
:
ndim
=
len
(
shape
)
else
:
ndim
=
len
(
pixdim
)
# We only allow adjustment of
# the spatial dimensions
if
ndim
!=
3
:
raise
ValueError
(
'
Three dimensions must be specified
'
)
oldShape
=
np
.
array
(
self
.
shape
[
:
ndim
])
oldPixdim
=
np
.
array
(
self
.
pixdim
[:
ndim
])
newShape
=
shape
newPixdim
=
pixdim
# if pixdims were specified,
# convert them into a shape
# convert them into a shape,
# and vice versa
if
newPixdim
is
not
None
:
npixdim
=
len
(
newPixdim
)
newPixdim
=
np
.
array
(
newPixdim
)
oldShape
=
np
.
array
(
self
.
shape
[
:
npixdim
])
oldPixdim
=
np
.
array
(
self
.
pixdim
[:
npixdim
])
newShape
=
oldShape
*
(
oldPixdim
/
newPixdim
)
# We only allow adjustment of
# the spatial dimensions
if
len
(
newShape
)
!=
3
:
raise
ValueError
(
'
Three dimensions must be specified
'
)
newShape
=
oldShape
*
(
oldPixdim
/
newPixdim
)
else
:
newPixdim
=
oldPixdim
*
(
oldShape
/
newShape
)
# Rescale the voxel-to-world affine
xform
=
affine
.
rescale
(
oldShape
,
newShape
,
origin
)
...
...
This diff is collapsed.
Click to expand it.
fsl/transform/affine.py
+
1
−
1
View file @
d92f8e0f
...
...
@@ -588,7 +588,7 @@ def rmsdev(T1, T2, R=None, xc=None):
def
rescale
(
oldShape
,
newShape
,
origin
=
None
):
"""
Calculates an affine matrix to use for resampling.
This function generates an affine transformation matr
e
ix that can be used
This function generates an affine transformation matrix that can be used
to resample an N-D array from ``oldShape`` to ``newShape`` using, for
example, ``scipy.ndimage.affine_transform``.
...
...
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