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
fd1ea39f
Commit
fd1ea39f
authored
6 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
TEST: Expand Image.resample test
parent
a69bd9e4
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_image.py
+40
-2
40 additions, 2 deletions
tests/test_image.py
with
40 additions
and
2 deletions
tests/test_image.py
+
40
−
2
View file @
fd1ea39f
...
@@ -1078,6 +1078,12 @@ def test_image_resample(seed):
...
@@ -1078,6 +1078,12 @@ def test_image_resample(seed):
make_random_image
(
fname
,
shape
)
make_random_image
(
fname
,
shape
)
img
=
fslimage
.
Image
(
fname
,
mmap
=
False
)
img
=
fslimage
.
Image
(
fname
,
mmap
=
False
)
# bad shape
with
pytest
.
raises
(
ValueError
):
img
.
resample
((
10
,
10
))
with
pytest
.
raises
(
ValueError
):
img
.
resample
((
10
,
10
,
10
,
10
))
# resampling to the same shape should be a no-op
# resampling to the same shape should be a no-op
samei
,
samex
=
img
.
resample
(
shape
)
samei
,
samex
=
img
.
resample
(
shape
)
assert
np
.
all
(
samei
==
img
[:])
assert
np
.
all
(
samei
==
img
[:])
...
@@ -1134,18 +1140,50 @@ def test_image_resample(seed):
...
@@ -1134,18 +1140,50 @@ def test_image_resample(seed):
assert
np
.
all
(
np
.
isclose
(
resvals
,
origvals
))
assert
np
.
all
(
np
.
isclose
(
resvals
,
origvals
))
# Test a 4D image
del
img
img
=
None
def
test_image_resample_4d
(
seed
):
fname
=
'
test.nii.gz
'
with
tempdir
():
make_random_image
(
fname
,
(
10
,
10
,
10
,
10
))
make_random_image
(
fname
,
(
10
,
10
,
10
,
10
))
# resample one volume
img
=
fslimage
.
Image
(
fname
)
img
=
fslimage
.
Image
(
fname
)
slc
=
(
slice
(
None
),
slice
(
None
),
slice
(
None
),
3
)
slc
=
(
slice
(
None
),
slice
(
None
),
slice
(
None
),
3
)
resampled
=
img
.
resample
(
img
.
shape
[:
3
],
slc
)[
0
]
resampled
=
img
.
resample
(
img
.
shape
[:
3
],
slc
)[
0
]
assert
np
.
all
(
resampled
==
img
[...,
3
])
assert
np
.
all
(
resampled
==
img
[...,
3
])
# resample up
resampled
=
img
.
resample
((
15
,
15
,
15
),
slc
)[
0
]
resampled
=
img
.
resample
((
15
,
15
,
15
),
slc
)[
0
]
assert
tuple
(
resampled
.
shape
)
==
(
15
,
15
,
15
)
assert
tuple
(
resampled
.
shape
)
==
(
15
,
15
,
15
)
# resample down
resampled
=
img
.
resample
((
5
,
5
,
5
),
slc
)[
0
]
assert
tuple
(
resampled
.
shape
)
==
(
5
,
5
,
5
)
# resample the entire image
resampled
=
img
.
resample
((
15
,
15
,
15
,
10
),
None
)[
0
]
assert
tuple
(
resampled
.
shape
)
==
(
15
,
15
,
15
,
10
)
resampled
=
img
.
resample
((
5
,
5
,
5
,
10
),
None
)[
0
]
assert
tuple
(
resampled
.
shape
)
==
(
5
,
5
,
5
,
10
)
# resample along the fourth dim
resampled
=
img
.
resample
((
15
,
15
,
15
,
15
),
None
)[
0
]
assert
tuple
(
resampled
.
shape
)
==
(
15
,
15
,
15
,
15
)
resampled
=
img
.
resample
((
5
,
5
,
5
,
15
),
None
)[
0
]
assert
tuple
(
resampled
.
shape
)
==
(
5
,
5
,
5
,
15
)
del
img
del
img
del
resampled
img
=
None
img
=
None
resampled
=
None
def
test_Image_init_xform_nifti1
():
_test_Image_init_xform
(
1
)
def
test_Image_init_xform_nifti1
():
_test_Image_init_xform
(
1
)
...
...
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