diff --git a/model_server/extensions/chaeo/products.py b/model_server/extensions/chaeo/products.py index f7782f8ced3d923c2a15128f96d197eb3846f81c..484756fa77b429d45a1c3fb77bf9b1d3c7d09632 100644 --- a/model_server/extensions/chaeo/products.py +++ b/model_server/extensions/chaeo/products.py @@ -247,24 +247,4 @@ def export_patches_from_zstack( for roi in patches_df.itertuples(): # just used for label info _export_patch(roi) - return exported - - -def export_multichannel_patches_from_zstack( - where: Path, - roiset, - rgb_overlay_channels: list = None, - rgb_overlay_weights: list = [1.0, 1.0, 1.0], - white_channel: int = None, - **kwargs -): - """ - Export RGB patches where each patch is assignable to a channel of the input stack - :param ch_rgb_overlay: tuple of integers (R, G, B) that assign a stack channel index to an RGB channel - :param overlay_gain: optional, tuple of float (R, G, B) multipliers that can be used to balance relative brightness - :param rgb_white_channel: int, index of stack channel that becomes grayscale signal in export patches - """ - kwargs['white_channel'] = white_channel - kwargs['rgb_overlay_channels'] = rgb_overlay_channels - kwargs['rgb_overlay_weights'] = rgb_overlay_weights - return export_patches_from_zstack(where, roiset, **kwargs) \ No newline at end of file + return exported \ No newline at end of file diff --git a/model_server/extensions/chaeo/tests/test_zstack.py b/model_server/extensions/chaeo/tests/test_zstack.py index 41571203cf958781b3a19397b075c1a4537eaa0d..35d73f26b90730cad4e3bf836345a83f24730694 100644 --- a/model_server/extensions/chaeo/tests/test_zstack.py +++ b/model_server/extensions/chaeo/tests/test_zstack.py @@ -7,7 +7,7 @@ from model_server.conf.testing import output_path from model_server.extensions.chaeo.conf.testing import multichannel_zstack, pixel_classifier, pipeline_params from extensions.chaeo.params import RoiSetExportParams, RoiSetMetaParams -from model_server.extensions.chaeo.products import export_patches_from_zstack, export_multichannel_patches_from_zstack +from model_server.extensions.chaeo.products import export_patches_from_zstack from model_server.extensions.chaeo.workflows import infer_object_map_from_zstack from model_server.extensions.chaeo.zmask import get_label_ids, RoiSet from model_server.base.accessors import generate_file_accessor, InMemoryDataAccessor, write_accessor_data_to_file @@ -248,8 +248,7 @@ class TestRoiSetMultichannelProducts(BaseTestRoiSetMonoProducts, unittest.TestCa ) def test_multichannel_to_mono_2d_patches(self): - - files = export_multichannel_patches_from_zstack( + files = export_patches_from_zstack( output_path / 'multichannel' / 'mono_2d_patches', self.roiset, white_channel=3, @@ -259,7 +258,7 @@ class TestRoiSetMultichannelProducts(BaseTestRoiSetMonoProducts, unittest.TestCa self.assertEqual(result.chroma, 1) def test_multichannnel_to_mono_2d_patches_rgb_bbox(self): - files = export_multichannel_patches_from_zstack( + files = export_patches_from_zstack( output_path / 'multichannel' / 'mono_2d_patches_rgb_bbox', self.roiset, white_channel=3, @@ -270,7 +269,7 @@ class TestRoiSetMultichannelProducts(BaseTestRoiSetMonoProducts, unittest.TestCa self.assertEqual(result.chroma, 3) def test_multichannnel_to_rgb_2d_patches_bbox(self): - files = export_multichannel_patches_from_zstack( + files = export_patches_from_zstack( output_path / 'multichannel' / 'rgb_2d_patches_bbox', self.roiset, white_channel=4, @@ -283,7 +282,7 @@ class TestRoiSetMultichannelProducts(BaseTestRoiSetMonoProducts, unittest.TestCa self.assertEqual(result.chroma, 3) def test_multichannnel_to_rgb_2d_patches_contour(self): - files = export_multichannel_patches_from_zstack( + files = export_patches_from_zstack( output_path / 'multichannel' / 'rgb_2d_patches_contour', self.roiset, rgb_overlay_channels=(3, None, None), @@ -296,7 +295,7 @@ class TestRoiSetMultichannelProducts(BaseTestRoiSetMonoProducts, unittest.TestCa self.assertEqual(result.get_one_channel_data(2).data.max(), 0) # blue channel is black def test_multichannel_to_multichannel_tif_patches(self): - files = export_multichannel_patches_from_zstack( + files = export_patches_from_zstack( output_path / 'multichannel' / 'multichannel_tif_patches', self.roiset, ) @@ -309,9 +308,4 @@ class TestRoiSetMultichannelProducts(BaseTestRoiSetMonoProducts, unittest.TestCa 'test_multichannel_annotated_zstack', ) - # files = export_multichannel_patches_from_zstack( - # 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) + diff --git a/model_server/extensions/chaeo/zmask.py b/model_server/extensions/chaeo/zmask.py index 5503073139be137822372926d125d7e5b41213f5..ef30936d7efaa6a11692431d7ce80f69d08d06b9 100644 --- a/model_server/extensions/chaeo/zmask.py +++ b/model_server/extensions/chaeo/zmask.py @@ -14,7 +14,7 @@ from model_server.base.models import InstanceSegmentationModel from model_server.base.process import pad, rescale, resample_to_8bit from model_server.extensions.chaeo.annotators import draw_boxes_on_3d_image -from model_server.extensions.chaeo.products import export_patches_from_zstack, export_multichannel_patches_from_zstack +from model_server.extensions.chaeo.products import export_patches_from_zstack from extensions.chaeo.params import RoiFilter, RoiSetMetaParams, RoiSetExportParams from model_server.extensions.chaeo.accessors import MonoPatchStack, Multichannel3dPatchStack from model_server.extensions.chaeo.process import mask_largest_object @@ -247,12 +247,12 @@ class RoiSet(object): subdir, self, white_channel=channel, prefix=pr, make_3d=True, **kp ) if k == 'annotated_patches_2d': - files = export_multichannel_patches_from_zstack( + files = export_patches_from_zstack( subdir, self, prefix=pr, make_3d=False, white_channel=channel, bounding_box_channel=1, bounding_box_linewidth=2, **kp, ) if k == 'patches_2d': - files = export_multichannel_patches_from_zstack( + files = export_patches_from_zstack( subdir, self, white_channel=channel, prefix=pr, make_3d=False, **kp ) df_patches = pd.DataFrame(files)