Skip to content
Snippets Groups Projects
Commit 7138abc2 authored by Christopher Randolph Rhodes's avatar Christopher Randolph Rhodes
Browse files

More test coverage of number of channels in multichannel export

parent efc48f21
No related branches found
No related tags found
No related merge requests found
...@@ -235,6 +235,7 @@ def export_patches_from_zstack( ...@@ -235,6 +235,7 @@ def export_patches_from_zstack(
exported.append({ exported.append({
'df_index': roi.Index, 'df_index': roi.Index,
'patch_filename': fname, 'patch_filename': fname,
'location': where.__str__(),
}) })
exported = [] exported = []
......
import unittest import unittest
import numpy as np import numpy as np
from pathlib import Path
from model_server.conf.testing import output_path from model_server.conf.testing import output_path
...@@ -131,9 +132,7 @@ class TestZStackDerivedDataProducts(unittest.TestCase): ...@@ -131,9 +132,7 @@ class TestZStackDerivedDataProducts(unittest.TestCase):
) )
files = export_patches_from_zstack( files = export_patches_from_zstack(
output_path / '3d_patches', output_path / '3d_patches',
# self.stack_ch_pa,
roiset, roiset,
# roiset.zmask_meta,
make_3d=True) make_3d=True)
self.assertGreaterEqual(len(files), 1) self.assertGreaterEqual(len(files), 1)
...@@ -145,8 +144,6 @@ class TestZStackDerivedDataProducts(unittest.TestCase): ...@@ -145,8 +144,6 @@ class TestZStackDerivedDataProducts(unittest.TestCase):
from model_server.extensions.chaeo.zmask import project_stack_from_focal_points from model_server.extensions.chaeo.zmask import project_stack_from_focal_points
# dff = df[df['keeper']]
img = project_stack_from_focal_points( img = project_stack_from_focal_points(
df['centroid-0'].to_numpy(), df['centroid-0'].to_numpy(),
df['centroid-1'].to_numpy(), df['centroid-1'].to_numpy(),
...@@ -168,49 +165,42 @@ class TestZStackDerivedDataProducts(unittest.TestCase): ...@@ -168,49 +165,42 @@ class TestZStackDerivedDataProducts(unittest.TestCase):
id_map, id_map,
self.stack, self.stack,
params=RoiSetMetaParams( params=RoiSetMetaParams(
mask_type=mask_type, filters=kwargs.get('filters') expand_box_by=(128, 2),
mask_type=mask_type,
filters={'area': {'min': 1e3, 'max': 1e4}},
) )
) )
def test_make_multichannel_2d_patches_from_zmask(self): def test_make_multichannel_2d_patches_from_zmask(self):
roiset = self._setup_multichannel_tests( roiset = self._setup_multichannel_tests()
filters={'area': {'min': 1e3, 'max': 1e4}},
expand_box_by=(128, 2)
)
files = export_multichannel_patches_from_zstack( files = export_multichannel_patches_from_zstack(
output_path / '2d_patches_chlorophyl_bbox_overlay', output_path / '2d_patches_chlorophyl_bbox_overlay',
# InMemoryDataAccessor(self.stack.data),
# roiset.zmask_meta,
roiset, roiset,
rgb_white_channel=4, white_channel=4,
draw_bounding_box=True, draw_bounding_box=True,
bounding_box_channel=1, bounding_box_channel=1,
) )
self.assertGreaterEqual(len(files), 1) self.assertGreaterEqual(len(files), 1)
result = generate_file_accessor(Path(files[0]['location']) / files[0]['patch_filename'])
self.assertEqual(result.chroma, 1)
def test_make_multichannel_2d_patches_with_mask_overlay(self): def test_make_multichannel_2d_patches_with_mask_overlay(self):
roiset = self.test_zmask_makes_correct_boxes( roiset = self._setup_multichannel_tests()
filters={'area': {'min': 1e3, 'max': 1e4}},
expand_box_by=(128, 2)
)
files = export_multichannel_patches_from_zstack( files = export_multichannel_patches_from_zstack(
output_path / '2d_patches_chlorophyl_mask_overlay', output_path / '2d_patches_chlorophyl_mask_overlay',
# InMemoryDataAccessor(self.stack.data),
# roiset.zmask_meta,
roiset, roiset,
rgb_white_channel=4, white_channel=4,
ch_rgb_overlay=(3, None, None), # rgb_overlay_channels=(3, None, None),
draw_mask=True, draw_mask=True,
mask_channel=0, mask_channel=0,
overlay_gain=(0.1, 1.0, 1.0) # rgb_overlay_weights=(0.1, 1.0, 1.0)
) )
self.assertGreaterEqual(len(files), 1) self.assertGreaterEqual(len(files), 1)
result = generate_file_accessor(Path(files[0]['location']) / files[0]['patch_filename'])
self.assertEqual(result.chroma, 1)
def test_make_multichannel_2d_patches_with_contour_overlay(self): def test_make_multichannel_2d_patches_with_contour_overlay(self):
roiset = self.test_zmask_makes_correct_boxes( roiset = self._setup_multichannel_tests()
filters={'area': {'min': 1e3, 'max': 1e4}},
expand_box_by=(128, 2)
)
files = export_multichannel_patches_from_zstack( files = export_multichannel_patches_from_zstack(
output_path / '2d_patches_chlorophyl_contour_overlay', output_path / '2d_patches_chlorophyl_contour_overlay',
# InMemoryDataAccessor(self.stack.data), # InMemoryDataAccessor(self.stack.data),
...@@ -222,6 +212,18 @@ class TestZStackDerivedDataProducts(unittest.TestCase): ...@@ -222,6 +212,18 @@ class TestZStackDerivedDataProducts(unittest.TestCase):
overlay_gain=(0.1, 1.0, 1.0) overlay_gain=(0.1, 1.0, 1.0)
) )
self.assertGreaterEqual(len(files), 1) self.assertGreaterEqual(len(files), 1)
result = generate_file_accessor(Path(files[0]['location']) / files[0]['patch_filename'])
self.assertEqual(result.chroma, 3)
def test_make_2d_patches_as_multichannel_tif(self):
roiset = self._setup_multichannel_tests()
files = export_multichannel_patches_from_zstack(
output_path / '2d_patches_chlorophyl_contour_overlay',
roiset,
)
self.assertGreaterEqual(len(files), 1)
result = generate_file_accessor(Path(files[0]['location']) / files[0]['patch_filename'])
self.assertEqual(result.chroma, 5)
# TODO: rewrite with direct call to RoiSet methods # TODO: rewrite with direct call to RoiSet methods
def test_make_binary_masks_from_zmask(self): def test_make_binary_masks_from_zmask(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment