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
84bd4950
Commit
84bd4950
authored
5 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
RF: Adjust matrix correctly (again) for >3D images. Adjust pixdims of higher
dimensions
parent
7d2a83e6
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/scripts/resample_image.py
+13
-0
13 additions, 0 deletions
fsl/scripts/resample_image.py
fsl/utils/image/resample.py
+6
-1
6 additions, 1 deletion
fsl/utils/image/resample.py
with
19 additions
and
1 deletion
fsl/scripts/resample_image.py
+
13
−
0
View file @
84bd4950
...
...
@@ -196,6 +196,19 @@ def main(argv=None):
xform
=
None
resampled
=
fslimage
.
Image
(
resampled
,
xform
=
xform
,
header
=
hdr
)
# Adjust the pixdims of the
# higher dimensions if they
# have been resampled
if
len
(
resampled
.
shape
)
>
3
:
oldPixdim
=
args
.
input
.
pixdim
[
3
:]
oldShape
=
args
.
input
.
shape
[
3
:]
newShape
=
resampled
.
shape
[
3
:]
for
i
,
(
p
,
o
,
n
)
in
enumerate
(
zip
(
oldPixdim
,
oldShape
,
newShape
),
4
):
resampled
.
header
[
'
pixdim
'
][
i
]
=
p
*
o
/
n
resampled
.
save
(
args
.
output
)
return
0
...
...
This diff is collapsed.
Click to expand it.
fsl/utils/image/resample.py
+
6
−
1
View file @
84bd4950
...
...
@@ -210,7 +210,12 @@ def resample(image,
# might not return a 4x4 matrix, so we
# make sure it is valid.
if
matrix
.
shape
!=
(
4
,
4
):
matrix
=
np
.
vstack
((
matrix
[:
3
,
:
4
],
[
0
,
0
,
0
,
1
]))
rotmat
=
matrix
[:
3
,
:
3
]
offsets
=
matrix
[:
3
,
-
1
]
matrix
=
np
.
eye
(
4
)
matrix
[:
3
,
:
3
]
=
rotmat
matrix
[:
3
,
-
1
]
=
offsets
matrix
=
transform
.
concat
(
image
.
voxToWorldMat
,
matrix
)
return
data
,
matrix
...
...
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