Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
platy-browser-data
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
Container Registry
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
Christian Tischer
platy-browser-data
Commits
d5656cde
Commit
d5656cde
authored
5 years ago
by
Constantin Pape
Browse files
Options
Downloads
Patches
Plain Diff
Add check for validation data
parent
d9f61770
No related branches found
Branches containing commit
No related tags found
1 merge request
!8
Segmentation validation and correction
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
analysis/validation/check_validation.py
+47
-0
47 additions, 0 deletions
analysis/validation/check_validation.py
scripts/segmentation/validation/eval_cells.py
+16
-6
16 additions, 6 deletions
scripts/segmentation/validation/eval_cells.py
with
63 additions
and
6 deletions
analysis/validation/check_validation.py
0 → 100644
+
47
−
0
View file @
d5656cde
import
h5py
from
heimdall
import
view
,
to_source
def
check_cell_evaluation
():
from
scripts.segmentation.validation.eval_cells
import
(
eval_slice
,
get_ignore_seg_ids
,
get_bounding_box
)
praw
=
'
../../data
'
pseg
=
'
../../data
'
pann
=
'
../../data
'
table_path
=
'
../../data
'
ignore_seg_ids
=
get_ignore_seg_ids
(
table_path
)
with
h5py
.
File
(
pseg
,
'
r
'
)
as
fseg
,
h5py
.
File
(
pann
,
'
r
'
)
as
fann
:
ds_seg
=
fseg
[
'
t00000/s00/0/cells
'
]
ds_ann
=
fann
[
'
xy/
'
]
print
(
"
Run evaluation ...
"
)
res
,
masks
=
eval_slice
(
ds_seg
,
ds_ann
,
ignore_seg_ids
,
min_radius
=
16
,
return_maksks
=
True
)
fm
,
fs
=
masks
[
'
false_merges
'
],
masks
[
'
false_splits
'
]
print
()
print
(
"
Eval result
"
)
print
(
res
)
print
()
print
(
"
Load raw data ...
"
)
bb
=
get_bounding_box
(
ds_ann
)
with
h5py
.
File
(
praw
,
'
r
'
)
as
f
:
raw
=
f
[
'
t00000/s00/1/cells
'
][
bb
]
print
(
"
Load seg data ...
"
)
seg
=
ds_seg
[
bb
].
squeeze
()
view
(
to_source
(
raw
,
name
=
'
raw
'
),
to_source
(
seg
,
name
=
'
seg
'
),
to_source
(
fm
,
name
=
'
merges
'
),
to_source
(
fs
,
name
=
'
splits
'
))
# def check_nucleus_evaluation():
# eval_nuclei()
if
__name__
==
'
__main__
'
:
check_cell_evaluation
()
This diff is collapsed.
Click to expand it.
scripts/segmentation/validation/eval_cells.py
+
16
−
6
View file @
d5656cde
...
...
@@ -5,16 +5,22 @@ from elf.io import open_file, is_dataset
from
.evaluate_annotations
import
evaluate_annotations
,
merge_evaluations
def
eval_slice
(
ds_seg
,
ds_ann
,
ignore_seg_ids
,
min_radius
):
ds_seg
.
n_threads
=
8
ds_ann
.
n_threads
=
8
attrs
=
ds_ann
.
attrs
def
get_bounding_box
(
ds
):
attrs
=
ds
.
attrs
start
,
stop
=
attrs
[
'
starts
'
],
attrs
[
'
stops
'
]
bb
=
tuple
(
slice
(
sta
,
sto
)
for
sta
,
sto
in
zip
(
start
,
stop
))
return
bb
def
eval_slice
(
ds_seg
,
ds_ann
,
ignore_seg_ids
,
min_radius
,
return_masks
=
False
):
ds_seg
.
n_threads
=
8
ds_ann
.
n_threads
=
8
bb
=
get_bounding_box
(
ds_ann
)
annotations
=
ds_ann
[:]
seg
=
ds_seg
[
bb
].
squeeze
()
assert
annotations
.
shape
==
seg
.
shape
seg_eval
=
vigra
.
analysis
.
labelImageWithBackground
(
seg
)
...
...
@@ -28,7 +34,8 @@ def eval_slice(ds_seg, ds_ann, ignore_seg_ids, min_radius):
bg_annotations
=
annotations
==
3
return
evaluate_annotations
(
seg_eval
,
fg_annotations
,
bg_annotations
,
this_ignore_ids
,
min_radius
=
min_radius
)
this_ignore_ids
,
min_radius
=
min_radius
,
return_masks
=
return_masks
)
def
get_ignore_seg_ids
(
table_path
,
ignore_names
=
[
'
cuticle
'
,
'
neuropil
'
,
'
yolk
'
]):
...
...
@@ -55,8 +62,11 @@ def eval_cells(seg_path, seg_key,
def
visit_annotation
(
name
,
node
):
nonlocal
eval_res
if
is_dataset
(
node
):
print
(
"
Evaluating:
"
,
name
)
res
=
eval_slice
(
ds_seg
,
node
,
ignore_seg_ids
,
min_radius
)
eval_res
=
merge_evaluations
(
res
,
eval_res
)
else
:
print
(
"
Group:
"
,
name
)
g
.
visititems
(
visit_annotation
)
...
...
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