Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Michiel Cottaar
gyral_structure
Commits
7f1c7ed2
Commit
7f1c7ed2
authored
May 03, 2020
by
Michiel Cottaar
Browse files
ENH: more efficiently compute idx_centroid for precomputed grid
parent
2407d7c4
Pipeline
#5294
failed with stage
in 9 minutes and 54 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
gyral_structure/basis/radial.py
View file @
7f1c7ed2
...
...
@@ -159,13 +159,14 @@ class RadialBasis(BasisFunc):
use
=
(
voxels
>=
0
).
all
(
-
1
)
&
(
voxels
<
intersects
.
shape
).
all
(
-
1
)
list_of_lists
[
use
]
=
intersects
[
tuple
(
voxels
[
use
].
T
)]
list_of_lists
=
list
(
list_of_lists
)
idx_centroid
=
sp
.
concatenate
(
list_of_lists
)
else
:
tree2
=
spatial
.
cKDTree
(
req
.
center
())
size1
=
sp
.
asarray
(
self
.
size
)
max_size
=
size1
.
max
()
+
req
.
radius
().
max
()
list_of_lists
=
tree2
.
query_ball_tree
(
self
.
tree
,
r
=
max_size
)
idx_centroid
=
sp
.
fromiter
(
itertools
.
chain
(
*
list_of_lists
),
dtype
=
'i4'
)
idx_req_compressed
=
sp
.
append
(
0
,
sp
.
cumsum
([
len
(
l
)
for
l
in
list_of_lists
]))
idx_centroid
=
sp
.
fromiter
(
itertools
.
chain
(
*
list_of_lists
),
dtype
=
'i4'
)
if
return_compressed
:
return
idx_req_compressed
,
idx_centroid
idx_req
=
sp
.
digitize
(
sp
.
arange
(
idx_req_compressed
[
-
1
]),
idx_req_compressed
[
1
:])
...
...
@@ -205,7 +206,7 @@ class RadialBasis(BasisFunc):
center_tree
=
spatial
.
cKDTree
(
coords_center
.
reshape
(
3
,
-
1
).
T
)
intersects
=
np
.
zeros
(
np
.
prod
(
coords_center
.
shape
[
1
:]),
dtype
=
'object'
)
for
idx
,
neighbours
in
enumerate
(
center_tree
.
query_ball_tree
(
self
.
tree
,
r
=
max_size
)):
intersects
[
idx
]
=
n
eighbours
intersects
[
idx
]
=
n
p
.
array
(
neighbours
,
dtype
=
'i4'
)
self
.
_precomputed_grids
=
(
max_size
,
sp
.
linalg
.
inv
(
affine
),
intersects
.
reshape
(
coords_center
.
shape
[
1
:])
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment