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
db420797
Commit
db420797
authored
1 year ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Still drafting ImageJ-side client
parent
9a2a8a5c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
clients/imagej/example.py
+10
-4
10 additions, 4 deletions
clients/imagej/example.py
clients/imagej/zstack_to_ilastik.py
+46
-26
46 additions, 26 deletions
clients/imagej/zstack_to_ilastik.py
with
56 additions
and
30 deletions
clients/imagej/example.py
+
10
−
4
View file @
db420797
# example top-level script in ImageJ
#
# add scripts dir to python path
#
from
clients.imagej.zstack_to_ilastik
import
get_object_map
from
ij
import
IJ
CHANNEL_TO_ILASTIK
=
1
# i.e. index of color channel from confocal stack
CHANNEL_CHLOROPHYL
=
4
OBJECT_CLASS_FOR_PHOTOACTIVATION
=
1
...
...
@@ -13,12 +19,12 @@ PIXEL_CLASSIFIER_PATH = "D:/DATA/TREC_STOP_15_Kristineberg/Vincent/230805_automi
OBJECT_CLASSIFIER_PATH
=
"
D:/DATA/TREC_STOP_15_Kristineberg/Vincent/230805_automic_AI_PA/ilastik/obj.ilp
"
DEBUG
=
True
HOST
=
'
127.0.0.1
'
PORT
=
8001
uri
=
'
http://{}:{}/
'
.
format
(
HOST
,
PORT
)
#
HOST = '127.0.0.1'
#
PORT = 8001
#
uri = 'http://{}:{}/'.format(HOST, PORT)
abspath
=
IJ
.
getImage
().
getProp
(
'
Location
'
)
input_filename
=
os
.
path
.
split
(
abspath
)[
-
1
]
#
input_filename = os.path.split(abspath)[-1]
channel
=
0
pixel_classifier
=
'
demo_px.ilp
'
...
...
This diff is collapsed.
Click to expand it.
clients/imagej/zstack_to_ilastik.py
+
46
−
26
View file @
db420797
from
pathlib
import
Path
from
clients.imagej.client
import
hit_endpoint
from
ij
import
IJ
from
ij
import
ImagePlus
def
s
et
up
(
pixel_classifier
,
object_classifier
,
input_path
):
def
g
et
_object_map
(
imp
,
px_ilp
,
ob_ilp
,
pxmap_threshold
,
pxmap_foreground_channel
,
segmentation_channel
,
patches_channel
,
zmask_filters
):
"""
:param pixel_classifier: (str)
:param object_classifier: (str)
:return:
:return:
ImagePlus
"""
result
=
[]
# configure input path - no endpoint yet
# get info from input ImagePlus
abspath
=
Path
(
imp
.
getProp
(
'
Location
'
))
image_directory
=
abspath
.
parent
input_filename
=
abspath
.
name
# configure output path - no endpoint yet
# configure input and output paths
resp
=
hit_endpoint
(
'
PUT
'
,
'
/paths/watch_input
'
,
{
'
path
'
:
image_directory
,
}
)
assert
resp
.
status_code
==
200
,
'
Error setting up image directory
'
resp
=
hit_endpoint
(
'
PUT
'
,
'
/paths/watch_output
'
,
{
'
path
'
:
image_directory
,
}
)
assert
resp
.
status_code
==
200
,
'
Error setting up image directory
'
# load pixel classifier
first time only
# load pixel classifier
resp
=
hit_endpoint
(
'
PUT
'
,
'
/
models/
ilastik/pixel_classification/load/
'
,
'
/ilastik/pixel_classification/load/
'
,
{
'
project_file
'
:
p
ixel_classifier
,
'
project_file
'
:
p
x_ilp
,
'
duplicate
'
:
False
,
},
)
result
[
'
pxmid
'
]
=
resp
[
'
model_id
'
]
assert
resp
.
status_code
==
200
,
'
Error loading pixel classifier:
'
+
{
px_ilp
}
id_px_mod
=
resp
[
'
model_id
'
]
# load pixel classifier first time only
resp
=
hit_endpoint
(
'
PUT
'
,
'
/
models/
ilastik/object_classification/load/
'
,
'
PUT
'
,
'
/ilastik/object_classification/load/
'
,
{
'
project_file
'
:
ob
ject_classifier
,
'
project_file
'
:
ob
_ilp
,
'
duplicate
'
:
False
,
},
)
result
[
'
obmid
'
]
=
resp
[
'
model_id
'
]
resp
=
hit_endpoint
(
'
GET
'
,
'
/models
'
,
verbose
=
True
)
return
result
assert
resp
.
status_code
==
200
,
'
Error loading object classifier:
'
+
{
ob_ilp
}
id_ob_mod
=
resp
[
'
model_id
'
]
def
get_object_map
(
pixel_classifier
,
object_classifier
,
input_path
,
input_filename
,
channel
):
"""
return
id_px_mod
,
id_ob_mod
:param pixel_classifier: (str)
:param object_classifier: (str)
:return:
"""
# eventually split this off
ids
=
setup
(
pixel_classifier
,
object_classifier
,
input_path
)
# run inference
resp
=
hit_endpoint
(
'
PUT
'
,
'
/chaeo/classify_zstack/infer
'
,
{
'
px_model_id
'
:
id
s
[
'
pxmid
'
]
'
ob_model_id
'
:
id
s
[
'
obmid
'
]
,
'
px_model_id
'
:
id
_px_mod
'
ob_model_id
'
:
id
_ob_mod
,
'
input_filename
'
:
input_filename
,
'
channel
'
:
channel
'
pxmap_threshold
'
:
pxmap_threshold
,
'
pxmap_foreground_channel
'
:
pxmap_foreground_channel
,
'
segmentation_channel
'
:
segmentation_channel
,
'
patches_channel
'
:
patches_channel
,
'
zmask_filters
'
:
zmask_filters
,
}
)
imp
=
assert
resp
.
status_code
==
200
,
'
Error calling workfow
'
return
IJ
.
ImagePlus
()
\ No newline at end of file
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