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
93547daf
Commit
93547daf
authored
5 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
TEST: Test for resample_image script (coming up)
parent
f95277d9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_scripts/test_resample_image.py
+69
-0
69 additions, 0 deletions
tests/test_scripts/test_resample_image.py
with
69 additions
and
0 deletions
tests/test_scripts/test_resample_image.py
0 → 100644
+
69
−
0
View file @
93547daf
#!/usr/bin/env python
import
numpy
as
np
import
fsl.scripts.resample_image
as
resample_image
import
fsl.utils.transform
as
transform
from
fsl.utils.tempdir
import
tempdir
from
fsl.data.image
import
Image
from
..
import
make_random_image
def
test_resample_image_shape
():
with
tempdir
():
img
=
Image
(
make_random_image
(
'
image.nii.gz
'
,
dims
=
(
10
,
10
,
10
)))
resample_image
.
main
(
'
image resampled -s 20 20 20
'
.
split
())
res
=
Image
(
'
resampled
'
)
expv2w
=
transform
.
concat
(
img
.
voxToWorldMat
,
transform
.
scaleOffsetXform
([
0.5
,
0.5
,
0.5
],
0
))
assert
np
.
all
(
np
.
isclose
(
res
.
shape
,
(
20
,
20
,
20
)))
assert
np
.
all
(
np
.
isclose
(
res
.
pixdim
,
(
0.5
,
0.5
,
0.5
)))
assert
np
.
all
(
np
.
isclose
(
res
.
voxToWorldMat
,
expv2w
))
assert
np
.
all
(
np
.
isclose
(
np
.
array
(
transform
.
axisBounds
(
res
.
shape
,
res
.
voxToWorldMat
))
-
0.25
,
transform
.
axisBounds
(
img
.
shape
,
img
.
voxToWorldMat
)))
resample_image
.
main
(
'
image resampled -s 20 20 20 -o corner
'
.
split
())
res
=
Image
(
'
resampled
'
)
assert
np
.
all
(
np
.
isclose
(
transform
.
axisBounds
(
res
.
shape
,
res
.
voxToWorldMat
),
transform
.
axisBounds
(
img
.
shape
,
img
.
voxToWorldMat
)))
def
test_resample_image_dim
():
with
tempdir
():
img
=
Image
(
make_random_image
(
'
image.nii.gz
'
,
dims
=
(
10
,
10
,
10
)))
resample_image
.
main
(
'
image resampled -d 0.5 0.5 0.5
'
.
split
())
res
=
Image
(
'
resampled
'
)
expv2w
=
transform
.
concat
(
img
.
voxToWorldMat
,
transform
.
scaleOffsetXform
([
0.5
,
0.5
,
0.5
],
0
))
assert
np
.
all
(
np
.
isclose
(
res
.
shape
,
(
20
,
20
,
20
)))
assert
np
.
all
(
np
.
isclose
(
res
.
pixdim
,
(
0.5
,
0.5
,
0.5
)))
assert
np
.
all
(
np
.
isclose
(
res
.
voxToWorldMat
,
expv2w
))
def
test_resample_image_ref
():
with
tempdir
():
img
=
Image
(
make_random_image
(
'
image.nii.gz
'
,
dims
=
(
10
,
10
,
10
)))
ref
=
Image
(
make_random_image
(
'
ref.nii.gz
'
,
dims
=
(
20
,
20
,
20
),
pixdims
=
(
0.5
,
0.5
,
0.5
)))
resample_image
.
main
(
'
image resampled -r ref
'
.
split
())
res
=
Image
(
'
resampled
'
)
expv2w
=
ref
.
voxToWorldMat
assert
np
.
all
(
np
.
isclose
(
res
.
shape
,
(
20
,
20
,
20
)))
assert
np
.
all
(
np
.
isclose
(
res
.
pixdim
,
(
0.5
,
0.5
,
0.5
)))
assert
np
.
all
(
np
.
isclose
(
res
.
voxToWorldMat
,
expv2w
))
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