Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
from client import hit_endpoint
from os.path import basename, dirname
from ij import IJ
from ij import ImagePlus
def setup(where, px_ilp):
# configure input and output paths
resp = hit_endpoint(
'PUT',
'/paths/watch_input',
{
'path': where,
}
)
assert resp.status_code == 200, 'Error setting up image directory'
resp = hit_endpoint(
'PUT',
'/paths/watch_output',
{
'path': where,
}
)
assert resp.status_code == 200, 'Error setting up image directory'
# load pixel classifier
resp = hit_endpoint(
'PUT',
'/ilastik/pixel_classification/load/',
{
'project_file': px_ilp,
'duplicate': False,
},
)
assert resp.status_code == 200, 'Error loading pixel classifier: ' + {px_ilp}
return resp['model_id']
def ilastik_map_objects_simple(imp, px_ilp, ob_ilp, channel):
"""
:param pixel_classifier: (str)
:param object_classifier: (str)
:return: ImagePlus
"""
# get info from input ImagePlus
abspath = imp.getProp('Location')
# assert imp is not z-stack
id_px_mod = setup(dirname(abspath), px_ilp)
# load object classifier
resp = hit_endpoint(
'PUT', '/ilastik/pxmap_to_obj/load/',
{
'project_file': ob_ilp,
'duplicate': False,
},
)
assert resp.status_code == 200, 'Error loading object classifier: ' + {ob_ilp}
id_ob_mod = resp['model_id']
# run inference
resp = hit_endpoint(
'PUT',
'/ilastik/pixel_then_object_classification/infer',
{
'px_model_id': id_px_mod,
'ob_model_id': id_ob_mod,
'input_filename': basename(abspath),
'channel': channel,
}
)
assert resp.status_code == 200, 'Error calling workfow'
obmap = resp.json()['object_map_filepath']
return obmap # obviously need imp
def ilastik_map_objects_with_zmask(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: ImagePlus
"""
# get info from input ImagePlus
abspath = imp.getProp('Location')
# assert imp is not z-stack
id_px_mod = setup(dirname(abspath), px_ilp)
# load object classifier
resp = hit_endpoint(
'PUT', '/ilastik/seg_to_obj/load/',
{
'project_file': ob_ilp,
'duplicate': False,
},
)
assert resp.status_code == 200, 'Error loading object classifier: ' + {ob_ilp}
id_ob_mod = resp['model_id']
# run inference
resp = hit_endpoint(
'PUT',
'/chaeo/classify_zstack/infer',
{
'px_model_id': id_px_mod,
'ob_model_id': id_ob_mod,
'input_filename': basename(abspath),
'pxmap_threshold': pxmap_threshold,
'pxmap_foreground_channel': pxmap_foreground_channel,
'segmentation_channel': segmentation_channel,
'patches_channel': patches_channel,
'zmask_filters': zmask_filters,
}
)
assert resp.status_code == 200, 'Error calling workfow'
obmap = resp.json()['output_path']
return obmap # obviously need imp