Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SVLT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
ALMF
SVLT
Commits
b973846b
Commit
b973846b
authored
1 year ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Wrote comparison table, caught case where ilastik can label multiple fragments of an object
parent
9d49942a
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
extensions/chaeo/examples/transfer_labels_to_ilastik_object_classifier.py
+30
-4
30 additions, 4 deletions
.../examples/transfer_labels_to_ilastik_object_classifier.py
with
30 additions
and
4 deletions
extensions/chaeo/examples/transfer_labels_to_ilastik_object_classifier.py
+
30
−
4
View file @
b973846b
...
...
@@ -4,6 +4,7 @@ import h5py
import
json
import
numpy
as
np
import
pandas
as
pd
import
skimage
import
uuid
import
vigra
...
...
@@ -149,6 +150,32 @@ def generate_ilastik_object_classifier(template_ilp, where: str, lane=0):
return
new_ilp
def
compare_object_maps
(
truth
:
GenericImageDataAccessor
,
inferred
:
GenericImageDataAccessor
)
->
pd
.
DataFrame
:
assert
truth
.
shape
==
inferred
.
shape
assert
np
.
all
((
truth
.
data
==
0
)
==
(
inferred
.
data
==
0
))
assert
inferred
.
chroma
==
1
labels
=
[]
for
zi
in
range
(
0
,
inferred
.
nz
):
inf_img
=
inferred
.
data
[:,
:,
:,
zi
]
unique
=
np
.
unique
(
inf_img
)
assert
unique
[
0
]
==
0
dd
=
{
'
zi
'
:
zi
,
'
truth_label
'
:
np
.
unique
(
truth
.
data
[:,
:,
:,
zi
])[
1
],
'
multiples
'
:
False
}
if
len
(
unique
)
==
1
:
# no object in frame
dd
[
'
inferred_label
'
]
=
unique
[
0
]
elif
len
(
unique
)
>
2
:
# multiple objects in frame, so mask out all but largest
ob_id
=
skimage
.
measure
.
label
(
inf_img
)
pr
=
skimage
.
measure
.
regionprops_table
(
ob_id
,
properties
=
[
'
label
'
,
'
area
'
])
mask
=
inf_img
==
pr
[
'
label
'
][
pr
[
'
area
'
].
argmax
()]
dd
[
'
inferred_label
'
]
=
np
.
unique
(
mask
*
inf_img
)[
1
]
dd
[
'
multiples
'
]
=
True
else
:
# exactly one unique object class in frame
dd
[
'
inferred_label
'
]
=
unique
[
1
]
labels
.
append
(
dd
)
return
pd
.
DataFrame
(
labels
)
if
__name__
==
'
__main__
'
:
root
=
Path
(
'
c:/Users/rhodes/projects/proj0011-plankton-seg/
'
)
...
...
@@ -172,7 +199,6 @@ if __name__ == '__main__':
# write comparison
train_labels
=
generate_file_accessor
(
where_patch_stack
/
'
zstack_train_label.tif
'
)
write_accessor_data_to_file
(
where_patch_stack
/
'
comp.tif
'
,
InMemoryDataAccessor
(
result_acc
.
data
==
train_labels
.
data
)
)
\ No newline at end of file
df_comp
=
compare_object_maps
(
train_labels
,
result_acc
)
df_comp
.
to_csv
(
where_patch_stack
/
autonumber_new_file
(
where_patch_stack
,
'
comp
'
,
'
csv
'
),
index
=
False
)
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