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
5404594b
Commit
5404594b
authored
6 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
TEST: Test saving mem-mapped images
parent
10f4b70f
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
+18
-18
18 additions, 18 deletions
tests/test_image.py
with
18 additions
and
18 deletions
tests/test_image.py
+
18
−
18
View file @
5404594b
...
@@ -994,29 +994,29 @@ def _test_Image_save(imgtype):
...
@@ -994,29 +994,29 @@ def _test_Image_save(imgtype):
make_image
(
filename
,
imgtype
)
make_image
(
filename
,
imgtype
)
# Using mmap can cause a "Bus error"
# Save to original location, and
# under docker. No idea why.
# to a different location. And
img
=
fslimage
.
Image
(
filename
,
mmap
=
False
)
# test both with and without mmap
targets
=
[
None
,
filename
,
filename2
]
mmaps
=
[
False
,
True
]
randvoxes
=
randvoxes
(
5
)
for
target
,
mmap
in
it
.
product
(
targets
,
mmaps
):
randvals
=
[
np
.
random
.
random
()
for
i
in
range
(
5
)]
for
(
x
,
y
,
z
),
v
in
zip
(
randvoxes
,
randvals
):
img
=
fslimage
.
Image
(
filename
,
mmap
=
mmap
)
img
[
x
,
y
,
z
]
=
v
if
imgtype
>
0
:
rvoxs
=
randvoxes
(
5
)
img
.
voxToWorldMat
=
xform
rvals
=
[
np
.
random
.
random
()
for
i
in
range
(
5
)]
# Save to original location, and
for
(
x
,
y
,
z
),
v
in
zip
(
rvoxs
,
rvals
):
# to a different location
img
[
x
,
y
,
z
]
=
v
targets
=
[
None
,
filename
,
filename2
]
for
t
in
targets
:
if
imgtype
>
0
:
img
.
voxToWorldMat
=
xform
img
.
save
(
t
)
img
.
save
(
t
arget
)
if
t
is
None
:
expDataSource
=
filename
if
t
arget
is
None
:
expDataSource
=
filename
else
:
expDataSource
=
t
else
:
expDataSource
=
t
arget
assert
img
.
saveState
assert
img
.
saveState
assert
img
.
dataSource
==
expDataSource
assert
img
.
dataSource
==
expDataSource
...
@@ -1024,7 +1024,7 @@ def _test_Image_save(imgtype):
...
@@ -1024,7 +1024,7 @@ def _test_Image_save(imgtype):
if
imgtype
>
0
:
if
imgtype
>
0
:
assert
np
.
all
(
np
.
isclose
(
img
.
voxToWorldMat
,
xform
))
assert
np
.
all
(
np
.
isclose
(
img
.
voxToWorldMat
,
xform
))
for
(
x
,
y
,
z
),
v
in
zip
(
r
and
vox
e
s
,
r
and
vals
):
for
(
x
,
y
,
z
),
v
in
zip
(
rvoxs
,
rvals
):
assert
np
.
isclose
(
img
[
x
,
y
,
z
],
v
)
assert
np
.
isclose
(
img
[
x
,
y
,
z
],
v
)
# Load the image back in
# Load the image back in
...
@@ -1036,7 +1036,7 @@ def _test_Image_save(imgtype):
...
@@ -1036,7 +1036,7 @@ def _test_Image_save(imgtype):
if
imgtype
>
0
:
if
imgtype
>
0
:
assert
np
.
all
(
np
.
isclose
(
img
.
voxToWorldMat
,
xform
))
assert
np
.
all
(
np
.
isclose
(
img
.
voxToWorldMat
,
xform
))
for
(
x
,
y
,
z
),
v
in
zip
(
r
and
vox
e
s
,
r
and
vals
):
for
(
x
,
y
,
z
),
v
in
zip
(
rvoxs
,
rvals
):
assert
np
.
isclose
(
img
[
x
,
y
,
z
],
v
)
assert
np
.
isclose
(
img
[
x
,
y
,
z
],
v
)
img2
=
None
img2
=
None
...
...
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