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
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
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
Christoph Arthofer
fslpy
Commits
c327cef3
Commit
c327cef3
authored
7 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Image.calcRange unit test
parent
4f7aca98
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_advanced.py
+68
-0
68 additions, 0 deletions
tests/test_image_advanced.py
with
68 additions
and
0 deletions
tests/test_image_advanced.py
+
68
−
0
View file @
c327cef3
...
...
@@ -200,3 +200,71 @@ def _test_image_no_calcRange(threaded):
img
.
getImageWrapper
().
getTaskThread
().
waitUntilIdle
()
assert
img
.
dataRange
==
(
0
,
i
)
def
test_image_calcRange_threaded
():
_test_image_calcRange
(
True
)
def
test_image_calcRange_unthreaded
():
_test_image_calcRange
(
False
)
def
_test_image_calcRange
(
threaded
):
# Testing with a 3D image
data
=
np
.
zeros
((
10
,
10
,
10
))
for
slc
in
range
(
10
):
data
[...,
slc
]
=
slc
+
1
data
[
0
,
0
,
0
]
=
0
kwargs
=
{
'
calcRange
'
:
False
,
'
loadData
'
:
False
,
'
threaded
'
:
threaded
}
# Check that calcRange(None) will calculate the full range
img
=
fslimage
.
Image
(
data
,
**
kwargs
)
img
.
calcRange
()
if
threaded
:
img
.
getImageWrapper
().
getTaskThread
().
waitUntilIdle
()
assert
img
.
dataRange
==
(
0
,
10
)
# Check that calcRange(numBiggerThanImage)
# will calculate the full range
img
=
fslimage
.
Image
(
data
,
**
kwargs
)
img
.
calcRange
(
np
.
prod
(
img
.
shape
)
*
img
.
dtype
.
itemsize
+
1
)
if
threaded
:
img
.
getImageWrapper
().
getTaskThread
().
waitUntilIdle
()
assert
img
.
dataRange
==
(
0
,
10
)
# Check that calcRange(smallnum) will
# calculate the range of the first slice
img
=
fslimage
.
Image
(
data
,
**
kwargs
)
img
.
calcRange
(
100
)
if
threaded
:
img
.
getImageWrapper
().
getTaskThread
().
waitUntilIdle
()
assert
img
.
dataRange
==
(
0
,
1
)
#########################
# Testing with a 4D image
data
=
np
.
zeros
((
10
,
10
,
10
,
10
))
for
slc
in
range
(
10
):
data
[...,
slc
]
=
slc
+
1
data
[
0
,
0
,
0
,
0
]
=
0
# Check that calcRange(None) will calculate the full range
img
=
fslimage
.
Image
(
data
,
**
kwargs
)
img
.
calcRange
()
if
threaded
:
img
.
getImageWrapper
().
getTaskThread
().
waitUntilIdle
()
assert
img
.
dataRange
==
(
0
,
10
)
# Check that calcRange(numBiggerThanImage)
# will calculate the full range
img
=
fslimage
.
Image
(
data
,
**
kwargs
)
img
.
calcRange
(
np
.
prod
(
img
.
shape
)
*
img
.
dtype
.
itemsize
+
1
)
if
threaded
:
img
.
getImageWrapper
().
getTaskThread
().
waitUntilIdle
()
assert
img
.
dataRange
==
(
0
,
10
)
# Check that calcRange(smallnum) will
# calculate the range of the first volume
img
=
fslimage
.
Image
(
data
,
**
kwargs
)
img
.
calcRange
(
100
)
if
threaded
:
img
.
getImageWrapper
().
getTaskThread
().
waitUntilIdle
()
assert
img
.
dataRange
==
(
0
,
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