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
d5caf156
Commit
d5caf156
authored
1 year ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Renamed a few output files
parent
5aca68af
No related branches found
Branches containing commit
No related tags found
Tags containing commit
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
+16
-18
16 additions, 18 deletions
.../examples/transfer_labels_to_ilastik_object_classifier.py
with
16 additions
and
18 deletions
extensions/chaeo/examples/transfer_labels_to_ilastik_object_classifier.py
+
16
−
18
View file @
d5caf156
...
...
@@ -8,7 +8,6 @@ import skimage
import
uuid
import
vigra
from
extensions.chaeo.util
import
autonumber_new_file
from
extensions.ilastik.models
import
IlastikObjectClassifierFromSegmentationModel
from
model_server.accessors
import
generate_file_accessor
,
GenericImageDataAccessor
,
InMemoryDataAccessor
,
write_accessor_data_to_file
...
...
@@ -88,7 +87,13 @@ def get_dataset_info(h5: h5py.File, lane : int = 0):
return
info
def
generate_ilastik_object_classifier
(
template_ilp
:
str
,
where
:
str
,
stack_name
:
str
=
'
train
'
,
lane
:
int
=
0
):
def
generate_ilastik_object_classifier
(
template_ilp
:
str
,
where
:
str
,
stack_name
:
str
=
'
train
'
,
lane
:
int
=
0
,
proj_name
=
'
auto_obj
'
):
"""
Starting with a template project file, transfer input data and labels to a duplicate project file.
...
...
@@ -134,11 +139,11 @@ def generate_ilastik_object_classifier(template_ilp: str, where: str, stack_name
assert
info
[
hg
][
'
location
'
]
==
b
'
FileSystem
'
assert
info
[
hg
][
'
axes
'
]
==
[
'
t
'
,
'
y
'
,
'
x
'
]
new_ilp
=
shutil
.
copy
(
template_ilp
,
root
/
autonumber_new_file
(
root
,
'
auto-obj
'
,
'
ilp
'
))
new_ilp
=
shutil
.
copy
(
template_ilp
,
where
/
(
proj_name
+
'
.
ilp
'
))
# write to new project file
lns
=
f
'
{
lane
:
04
d
}
'
with
h5py
.
File
(
new_ilp
,
'
r+
'
)
as
h5
:
with
h5py
.
File
(
where
/
new_ilp
,
'
r+
'
)
as
h5
:
def
set_ds
(
grp
,
ds
,
val
):
ds
=
h5
[
f
'
Input Data/infos/lane
{
lns
}
/
{
grp
}
/
{
ds
}
'
]
ds
[()]
=
val
...
...
@@ -203,13 +208,14 @@ def compare_object_maps(truth: GenericImageDataAccessor, inferred: GenericImageD
if
__name__
==
'
__main__
'
:
root
=
Path
(
'
c:/Users/rhodes/projects/proj0011-plankton-seg/
'
)
template_ilp
=
root
/
'
exp0014/template_obj.ilp
'
where_patch_stack
=
root
/
'
exp0009/output/labeled_patches-20231018-000
1
'
where_patch_stack
=
root
/
'
exp0009/output/labeled_patches-20231018-000
2
'
# auto-populate an object classifier
new
_ilp
=
generate_ilastik_object_classifier
(
auto
_ilp
=
generate_ilastik_object_classifier
(
template_ilp
,
where_patch_stack
,
stack_name
=
'
train
'
stack_name
=
'
train
'
,
proj_name
=
'
auto_obj_before
'
)
def
infer_and_compare
(
ilp
,
suffix
):
...
...
@@ -223,24 +229,16 @@ if __name__ == '__main__':
# write comparison tables
train_truth_labels
=
generate_file_accessor
(
where_patch_stack
/
f
'
zstack_train_label.tif
'
)
df_comp
=
compare_object_maps
(
train_truth_labels
,
result_acc
)
df_comp
.
to_csv
(
where_patch_stack
/
autonumber_new_file
(
where_patch_stack
,
f
'
compare_train_result_
{
suffix
}
'
,
'
csv
'
),
index
=
False
)
df_comp
.
to_csv
(
where_patch_stack
/
f
'
compare_train_result_
{
suffix
}
.csv
'
,
index
=
False
)
print
(
f
'
Generated ilastik project
{
ilp
}
'
)
print
(
'
Truth and inferred labels match?
'
)
print
(
pd
.
value_counts
(
df_comp
[
'
truth_label
'
]
==
df_comp
[
'
inferred_label
'
]))
# infer object labels from the same data used to train the classifier
infer_and_compare
(
new
_ilp
,
'
before
'
)
infer_and_compare
(
auto
_ilp
,
'
before
'
)
# copy project and prompt user input once ilastik file has been modified in-app
mod_ilp
=
shutil
.
copy
(
new_ilp
,
where_patch_stack
/
autonumber_new_file
(
where_patch_stack
,
'
auto-obj
'
,
'
ilp
'
)
)
mod_ilp
=
shutil
.
copy
(
auto_ilp
,
where_patch_stack
/
'
auto_obj_after.ilp
'
)
print
(
f
'
Press enter when project file
{
mod_ilp
}
has been updated in ilastik
'
)
input
()
...
...
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