Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gnomon-package-tissueimagemesh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
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
gnomon
gnomon-packages
gnomon-package-tissueimagemesh
Commits
32b72ad7
Commit
32b72ad7
authored
1 year ago
by
CERUTTI Guillaume
Browse files
Options
Downloads
Patches
Plain Diff
enable label properties in mesh -> cell transfer
parent
2dd554a2
No related branches found
No related tags found
No related merge requests found
Pipeline
#939639
failed
1 year ago
Stage: test
Stage: build
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/gnomon_package_tissueimagemesh/algorithm/cellImageQuantification/surfaceMeshCellProperty.py
+14
-0
14 additions, 0 deletions
...orithm/cellImageQuantification/surfaceMeshCellProperty.py
with
14 additions
and
0 deletions
src/gnomon_package_tissueimagemesh/algorithm/cellImageQuantification/surfaceMeshCellProperty.py
+
14
−
0
View file @
32b72ad7
...
...
@@ -35,6 +35,7 @@ class surfaceMeshCellProperty(gnomonAbstractCellImageQuantification):
self
.
_parameters
=
{}
self
.
_parameters
[
'
attribute_names
'
]
=
d_inliststringlist
(
"
Attributes
"
,
[
""
],
[
""
],
"
List of vertex attributes to transfer from the surface mesh
"
)
self
.
_parameters
[
'
label_threshold
'
]
=
d_int
(
"
Max Label Number
"
,
64
,
0
,
1e4
,
"
Maximal number of different values for an attribute to be considered a label
"
)
def
refreshParameters
(
self
):
if
len
(
self
.
surface_topomesh
)
>
0
:
...
...
@@ -42,6 +43,8 @@ class surfaceMeshCellProperty(gnomonAbstractCellImageQuantification):
attribute_names
=
self
[
'
attribute_names
'
]
property_names
=
list
(
surface_topomesh
.
wisp_property_names
(
0
))
property_names
=
[
p
for
p
in
property_names
if
surface_topomesh
.
has_wisp_property
(
p
,
0
,
is_computed
=
True
)]
property_names
=
[
p
for
p
in
property_names
if
surface_topomesh
.
wisp_property
(
p
,
0
).
values
().
dtype
!=
np
.
dtype
(
'
O
'
)]
if
len
(
property_names
)
==
0
:
property_names
=
[
""
]
attribute_names
=
[
p
for
p
in
attribute_names
if
p
in
property_names
]
...
...
@@ -92,9 +95,20 @@ class surfaceMeshCellProperty(gnomonAbstractCellImageQuantification):
vertex_property
=
surface_topomesh
.
wisp_property
(
property_name
,
0
).
values
(
list
(
surface_topomesh
.
wisps
(
0
)))
property_values
=
np
.
unique
(
vertex_property
)
property_is_binary
=
vertex_property
.
ndim
==
1
and
len
(
property_values
)
<=
2
and
(
0
in
property_values
or
1
in
property_values
)
property_is_label
=
vertex_property
.
ndim
==
1
and
len
(
property_values
)
<=
self
[
'
label_threshold
'
]
cell_property
=
None
if
property_is_binary
:
cell_property
=
(
nd
.
sum
(
vertex_property
,
vertex_cells
,
index
=
cell_labels
)
>
0
).
astype
(
int
)
elif
property_is_label
:
def
most_represented
(
array
):
values
,
counts
=
np
.
unique
(
array
,
return_counts
=
True
)
return
values
[
np
.
argmax
(
counts
)]
dtype
=
property_values
.
dtype
default
=
np
.
iinfo
(
dtype
).
min
if
np
.
issubdtype
(
dtype
,
np
.
integer
)
else
np
.
nan
cell_property
=
nd
.
labeled_comprehension
(
vertex_property
,
vertex_cells
,
index
=
cell_labels
,
func
=
most_represented
,
out_dtype
=
dtype
,
default
=
default
)
else
:
if
vertex_property
.
ndim
==
1
:
cell_property
=
nd
.
mean
(
vertex_property
,
vertex_cells
,
index
=
cell_labels
)
...
...
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