Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
model_server
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
Christopher Randolph Rhodes
model_server
Commits
2397e58d
Commit
2397e58d
authored
1 year ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Repaired all multichannel export cases
parent
1f72661a
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
model_server/extensions/chaeo/products.py
+16
-4
16 additions, 4 deletions
model_server/extensions/chaeo/products.py
model_server/extensions/chaeo/tests/test_zstack.py
+30
-36
30 additions, 36 deletions
model_server/extensions/chaeo/tests/test_zstack.py
with
46 additions
and
40 deletions
model_server/extensions/chaeo/products.py
+
16
−
4
View file @
2397e58d
...
...
@@ -118,7 +118,7 @@ def get_patches_from_zmask_meta(
assert
white_channel
<
raw
.
chroma
stack
=
raw
.
data
[:,
:,
[
white_channel
,
white_channel
,
white_channel
],
:]
else
:
stack
=
np
.
zeros
([
*
raw
.
shape
[
0
:
1
],
3
,
raw
.
shape
[
3
]],
dtype
=
raw
.
dtype
)
stack
=
np
.
zeros
([
*
raw
.
shape
[
0
:
2
],
3
,
raw
.
shape
[
3
]],
dtype
=
raw
.
dtype
)
for
ii
,
ci
in
enumerate
(
rgb_overlay_channels
):
if
ci
is
None
:
...
...
@@ -128,12 +128,24 @@ def get_patches_from_zmask_meta(
stack
[:,
:,
ii
,
:]
=
_safe_add
(
stack
[:,
:,
ii
,
:],
# either black or grayscale channel
rgb_overlay_weights
[
ii
],
stack
[:,
:,
ci
,
:]
raw
.
data
[:,
:,
ci
,
:]
)
else
:
if
white_channel
:
if
white_channel
:
# interpret as just a single channel
assert
white_channel
<
raw
.
chroma
stack
=
raw
.
data
[:,
:,
[
white_channel
],
:]
annotate_rgb
=
False
for
k
in
[
'
contour_channel
'
,
'
bounding_box_channel
'
,
'
mask_channel
'
]:
ca
=
kwargs
.
get
(
k
)
if
ca
is
None
:
continue
assert
(
ca
<
raw
.
chroma
)
if
ca
!=
white_channel
:
annotate_rgb
=
True
break
if
annotate_rgb
:
# make RGB patches anyway to include annotation color
stack
=
raw
.
data
[:,
:,
[
white_channel
,
white_channel
,
white_channel
],
:]
else
:
# make monochrome patches
stack
=
raw
.
data
[:,
:,
[
white_channel
],
:]
else
:
stack
=
raw
.
data
...
...
This diff is collapsed.
Click to expand it.
model_server/extensions/chaeo/tests/test_zstack.py
+
30
−
36
View file @
2397e58d
...
...
@@ -39,6 +39,17 @@ class TestZStackDerivedDataProducts(unittest.TestCase):
)
write_accessor_data_to_file
(
output_path
/
'
seg_mask.tif
'
,
self
.
seg_mask
)
id_map
=
get_label_ids
(
self
.
seg_mask
)
self
.
roiset
=
RoiSet
(
id_map
,
self
.
stack
,
params
=
RoiSetMetaParams
(
expand_box_by
=
(
128
,
2
),
mask_type
=
'
boxes
'
,
filters
=
{
'
area
'
:
{
'
min
'
:
1e3
,
'
max
'
:
1e4
}},
)
)
def
test_zmask_makes_correct_boxes
(
self
,
mask_type
=
'
boxes
'
,
**
kwargs
):
id_map
=
get_label_ids
(
self
.
seg_mask
)
roiset
=
RoiSet
(
...
...
@@ -159,34 +170,20 @@ class TestZStackDerivedDataProducts(unittest.TestCase):
InMemoryDataAccessor
(
img
)
)
def
_setup_multichannel_tests
(
self
,
mask_type
=
'
boxes
'
,
**
kwargs
):
id_map
=
get_label_ids
(
self
.
seg_mask
)
return
RoiSet
(
id_map
,
self
.
stack
,
params
=
RoiSetMetaParams
(
expand_box_by
=
(
128
,
2
),
mask_type
=
mask_type
,
filters
=
{
'
area
'
:
{
'
min
'
:
1e3
,
'
max
'
:
1e4
}},
)
)
def
test_make_mono_2d_patches_from_multichannel_zmask
(
self
):
roiset
=
self
.
_setup_multichannel_tests
()
def
test_multichannel_to_mono_2d_patches
(
self
):
files
=
export_multichannel_patches_from_zstack
(
output_path
/
'
test_m
ake
_mono_2d_patches
_from_multichannel_zmask
'
,
roiset
,
output_path
/
'
test_m
ultichannel_to
_mono_2d_patches
'
,
self
.
roiset
,
white_channel
=
3
,
draw_bounding_box
=
True
,
)
result
=
generate_file_accessor
(
Path
(
files
[
0
][
'
location
'
])
/
files
[
0
][
'
patch_filename
'
])
self
.
assertEqual
(
result
.
chroma
,
1
)
def
test_make_rgb_annotated_mono_2d_patches_from_multichannel_zmask
(
self
):
roiset
=
self
.
_setup_multichannel_tests
()
def
test_multichannnel_to_mono_2d_patches_rgb_bbox
(
self
):
files
=
export_multichannel_patches_from_zstack
(
output_path
/
'
test_make_rgb_annotated_mono_2d_patches_from_multichannel_zmask
'
,
roiset
,
output_path
/
'
multichannnel_to_mono_2d_patches_rgb_bbox
'
,
self
.
roiset
,
white_channel
=
3
,
draw_bounding_box
=
True
,
bounding_box_channel
=
1
,
...
...
@@ -194,11 +191,10 @@ class TestZStackDerivedDataProducts(unittest.TestCase):
result
=
generate_file_accessor
(
Path
(
files
[
0
][
'
location
'
])
/
files
[
0
][
'
patch_filename
'
])
self
.
assertEqual
(
result
.
chroma
,
3
)
def
test_make_multichannel_2d_patches_with_mask_overlay
(
self
):
roiset
=
self
.
_setup_multichannel_tests
()
def
test_multichannnel_to_rgb_2d_patches_bbox
(
self
):
files
=
export_multichannel_patches_from_zstack
(
output_path
/
'
test_make_
multichannel_2d_patches_
with_mask_overlay
'
,
roiset
,
output_path
/
'
multichann
n
el_
to_rgb_
2d_patches_
bbox
'
,
self
.
roiset
,
white_channel
=
4
,
rgb_overlay_channels
=
(
3
,
None
,
None
),
draw_mask
=
True
,
...
...
@@ -208,26 +204,24 @@ class TestZStackDerivedDataProducts(unittest.TestCase):
result
=
generate_file_accessor
(
Path
(
files
[
0
][
'
location
'
])
/
files
[
0
][
'
patch_filename
'
])
self
.
assertEqual
(
result
.
chroma
,
3
)
def
test_make_multichannel_2d_patches_with_contour_overlay
(
self
):
roiset
=
self
.
_setup_multichannel_tests
()
def
test_multichannnel_to_rgb_2d_patches_contour
(
self
):
files
=
export_multichannel_patches_from_zstack
(
output_path
/
'
2d_patches_chlorophyl_contour_overlay
'
,
# InMemoryDataAccessor(self.stack.data),
roiset
,
rgb_white_channel
=
4
,
ch_rgb_overlay
=
(
3
,
None
,
None
),
output_path
/
'
multichannnel_to_rgb_2d_patches_contour
'
,
self
.
roiset
,
rgb_overlay_channels
=
(
3
,
None
,
None
),
draw_contour
=
True
,
contour_channel
=
1
,
overlay_
gain
=
(
0.1
,
1.0
,
1.0
)
rgb_
overlay_
weights
=
(
0.1
,
1.0
,
1.0
)
)
result
=
generate_file_accessor
(
Path
(
files
[
0
][
'
location
'
])
/
files
[
0
][
'
patch_filename
'
])
self
.
assertEqual
(
result
.
chroma
,
3
)
self
.
assertEqual
(
result
.
get_one_channel_data
(
2
).
data
.
max
(),
0
)
# blue channel is black
def
test_m
ake_2d_patches_as
_multichannel_tif
(
self
):
roiset
=
self
.
_setup_multichannel_tests
()
def
test_m
ultichannel_to
_multichannel_tif
_patches
(
self
):
#
roiset = self._setup_multichannel_tests()
files
=
export_multichannel_patches_from_zstack
(
output_path
/
'
2d_patches
_multichannel_tif
'
,
roiset
,
output_path
/
'
multichannel_to
_multichannel_tif
_patches
'
,
self
.
roiset
,
)
result
=
generate_file_accessor
(
Path
(
files
[
0
][
'
location
'
])
/
files
[
0
][
'
patch_filename
'
])
self
.
assertEqual
(
result
.
chroma
,
5
)
...
...
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