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
9aa58f77
Commit
9aa58f77
authored
7 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Fixes/optimisations to atlas query tests
parent
6d0e6f8b
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_atlases_query.py
+18
-10
18 additions, 10 deletions
tests/test_atlases_query.py
with
18 additions
and
10 deletions
tests/test_atlases_query.py
+
18
−
10
View file @
9aa58f77
...
@@ -37,14 +37,20 @@ def _repeat(iterator, n):
...
@@ -37,14 +37,20 @@ def _repeat(iterator, n):
_atlases
=
cache
.
Cache
()
_atlases
=
cache
.
Cache
()
def
_get_atlas
(
atlasID
,
res
,
summary
=
False
):
def
_get_atlas
(
atlasID
,
res
,
summary
=
False
):
atlasID
=
'
striatum-structural
'
atlas
=
_atlases
.
get
((
atlasID
,
res
,
summary
),
default
=
None
)
atlas
=
_atlases
.
get
((
atlasID
,
res
,
summary
),
default
=
None
)
if
atlas
is
None
:
if
atlas
is
None
:
if
summary
or
atlasID
in
(
'
talairach
'
,
'
striatum-structural
'
,
'
jhu-labels
'
):
kwargs
=
{}
else
:
kwargs
=
{
'
loadData
'
:
False
,
'
calcRange
'
:
False
,
'
indexed
'
:
True
}
atlas
=
fslatlases
.
loadAtlas
(
atlasID
,
atlas
=
fslatlases
.
loadAtlas
(
atlasID
,
loadSummary
=
summary
,
loadSummary
=
summary
,
resolution
=
res
,
resolution
=
res
,
loadData
=
False
,
**
kwargs
)
calcRange
=
False
,
indexed
=
True
)
_atlases
.
put
((
atlasID
,
res
,
summary
),
atlas
)
_atlases
.
put
((
atlasID
,
res
,
summary
),
atlas
)
return
atlas
return
atlas
...
@@ -268,12 +274,13 @@ def _eval_mask_query(atlas, query, qtype, qin):
...
@@ -268,12 +274,13 @@ def _eval_mask_query(atlas, query, qtype, qin):
res
=
atlas
.
pixdim
[
0
]
res
=
atlas
.
pixdim
[
0
]
if
maskres
==
res
:
if
maskres
==
res
:
mask
=
mask
[:]
r
mask
=
mask
[:]
else
:
else
:
mask
=
mask
.
resample
(
atlas
.
shape
[:
3
],
dtype
=
np
.
float32
,
order
=
0
)[
0
]
r
mask
=
mask
.
resample
(
atlas
.
shape
[:
3
],
dtype
=
np
.
float32
,
order
=
0
)[
0
]
mask
=
np
.
array
(
mask
,
dtype
=
np
.
bool
)
r
mask
=
np
.
array
(
r
mask
,
dtype
=
np
.
bool
)
@profile
def
evalLabel
():
def
evalLabel
():
if
qin
==
'
out
'
:
if
qin
==
'
out
'
:
...
@@ -283,17 +290,18 @@ def _eval_mask_query(atlas, query, qtype, qin):
...
@@ -283,17 +290,18 @@ def _eval_mask_query(atlas, query, qtype, qin):
if
qin
==
'
in
'
:
if
qin
==
'
in
'
:
voxels
=
np
.
array
(
np
.
where
(
mask
)).
T
voxels
=
np
.
array
(
np
.
where
(
rmask
)).
T
valcounts
=
defaultdict
(
lambda
:
0.0
)
maxval
=
int
(
atlas
[:].
max
())
valcounts
=
np
.
zeros
((
maxval
+
1
,
))
nvoxels
=
voxels
.
shape
[
0
]
nvoxels
=
voxels
.
shape
[
0
]
for
x
,
y
,
z
in
voxels
:
for
x
,
y
,
z
in
voxels
:
x
,
y
,
z
=
[
int
(
v
)
for
v
in
[
x
,
y
,
z
]]
x
,
y
,
z
=
[
int
(
v
)
for
v
in
[
x
,
y
,
z
]]
valcounts
[
atlas
[
x
,
y
,
z
]]
+=
1.0
valcounts
[
int
(
atlas
[
x
,
y
,
z
]
)
]
+=
1.0
# make sure the values are sorted
# make sure the values are sorted
# according to their atlas ordering
# according to their atlas ordering
expvals
=
list
(
valcounts
.
keys
())
expvals
=
np
.
where
(
valcounts
>
0
)[
0
]
explabels
=
[]
explabels
=
[]
# There may be more values in an image
# There may be more values in an image
...
...
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