diff --git a/model_server/base/roiset.py b/model_server/base/roiset.py index 3b79ee09728bb22f5cfdb115a5f033f9e08cc69e..1993dc42e4c537074ef8cc7bd89259947f0f5278 100644 --- a/model_server/base/roiset.py +++ b/model_server/base/roiset.py @@ -945,7 +945,7 @@ class RoiSet(object): ph, pw, pc, pz = patch3d.shape # make a 3d patch - if make_3d or not expanded: + if make_3d: patch = patch3d # make a 2d patch, find optimal z-position determined by focus_metric function on each channel separately @@ -1166,7 +1166,7 @@ class RoiSet(object): def _poly_from_mask(roi): mask = roi.binary_mask if len(mask.shape) != 2: - raise PatchMaskShapeError(f'Patch mask needs to be two dimensions to fit a polygon') + raise PatchShapeError(f'Patch mask needs to be two dimensions to fit a polygon') # label and fill holes labeled = label(mask) @@ -1402,7 +1402,7 @@ class MissingSegmentationError(Error): pass -class PatchMaskShapeError(Error): +class PatchShapeError(Error): pass diff --git a/tests/base/test_roiset.py b/tests/base/test_roiset.py index 039ae01031211a4f0f2dc74f9097b088fc556fd2..7b371ee4019e4a32d6d8985b796c2e8db1a7c711 100644 --- a/tests/base/test_roiset.py +++ b/tests/base/test_roiset.py @@ -125,6 +125,7 @@ class TestRoiSetMonoProducts(BaseTestRoiSetMonoProducts, unittest.TestCase): draw_bounding_box=True, expanded=True, pad_to=256, + make_3d=False, ) df = roiset.get_df() for f in se_res: @@ -133,6 +134,7 @@ class TestRoiSetMonoProducts(BaseTestRoiSetMonoProducts, unittest.TestCase): roi_q = df.loc[df.label == la, :] self.assertEqual(len(roi_q), 1) self.assertEqual((256, 256), acc.hw) + self.assertEqual(1, acc.nz) def test_make_tight_2d_patches(self): roiset = self._make_roi_set() @@ -140,7 +142,7 @@ class TestRoiSetMonoProducts(BaseTestRoiSetMonoProducts, unittest.TestCase): se_res = roiset.export_patches( where, draw_bounding_box=True, - expanded=False + expanded=False, ) df = roiset.get_df() for f in se_res: # all exported files are same shape as bounding boxes in RoiSet's datatable @@ -150,6 +152,7 @@ class TestRoiSetMonoProducts(BaseTestRoiSetMonoProducts, unittest.TestCase): self.assertEqual(len(roi_q), 1) roi = roi_q.iloc[0] self.assertEqual((roi.h, roi.w), acc.hw) + self.assertEqual(1, acc.nz) def test_make_expanded_3d_patches(self): roiset = self._make_roi_set()