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

Rolled back changes to how masks and slices are handled, but kept updated tests

parent e70bab43
No related branches found
No related tags found
2 merge requests!18Completed (de)serialization of RoiSet,!16Completed (de)serialization of RoiSet
...@@ -38,6 +38,16 @@ class TestRoiSetMonoProducts(BaseTestRoiSetMonoProducts, unittest.TestCase): ...@@ -38,6 +38,16 @@ class TestRoiSetMonoProducts(BaseTestRoiSetMonoProducts, unittest.TestCase):
def test_roi_mask_shape(self, **kwargs): def test_roi_mask_shape(self, **kwargs):
roiset = self._make_roi_set(**kwargs) roiset = self._make_roi_set(**kwargs)
# all masks' bounding boxes are at least as big as ROI area
for roi in roiset.get_df().itertuples():
self.assertEqual(roi.mask.dtype, 'bool')
sh = roi.mask.shape
self.assertEqual(sh, (roi.y1 - roi.y0, roi.x1 - roi.x0))
self.assertGreaterEqual(sh[0] * sh[1], roi.area)
def test_roi_zmask(self, **kwargs):
roiset = self._make_roi_set(**kwargs)
zmask = roiset.get_zmask() zmask = roiset.get_zmask()
zmask_acc = InMemoryDataAccessor(zmask) zmask_acc = InMemoryDataAccessor(zmask)
self.assertTrue(zmask_acc.is_mask()) self.assertTrue(zmask_acc.is_mask())
...@@ -51,11 +61,6 @@ class TestRoiSetMonoProducts(BaseTestRoiSetMonoProducts, unittest.TestCase): ...@@ -51,11 +61,6 @@ class TestRoiSetMonoProducts(BaseTestRoiSetMonoProducts, unittest.TestCase):
self.assertTrue(np.any(zmask)) self.assertTrue(np.any(zmask))
self.assertFalse(np.all(zmask)) self.assertFalse(np.all(zmask))
# assert non-trivial meta info in boxes
self.assertGreater(roiset.count, 1)
sh = roiset.get_df().iloc[1]['mask'].shape
ar = roiset.get_df().iloc[1]['area']
self.assertGreaterEqual(sh[0] * sh[1], ar)
def test_roiset_from_non_zstacks(self, **kwargs): def test_roiset_from_non_zstacks(self, **kwargs):
acc_zstack_slice = InMemoryDataAccessor(self.stack_ch_pa.data[:, :, :, 0]) acc_zstack_slice = InMemoryDataAccessor(self.stack_ch_pa.data[:, :, :, 0])
...@@ -75,6 +80,13 @@ class TestRoiSetMonoProducts(BaseTestRoiSetMonoProducts, unittest.TestCase): ...@@ -75,6 +80,13 @@ class TestRoiSetMonoProducts(BaseTestRoiSetMonoProducts, unittest.TestCase):
self.assertEqual(len(ebb.shape), 4) self.assertEqual(len(ebb.shape), 4)
self.assertTrue(np.all([si >= 1 for si in ebb.shape])) self.assertTrue(np.all([si >= 1 for si in ebb.shape]))
def test_dataframe_and_mask_array_in_iterator(self):
roiset = self._make_roi_set()
for roi in roiset:
ma = roi.mask
self.assertEqual(ma.dtype, 'bool')
self.assertEqual(ma.shape, (roi.y1 - roi.y0, roi.x1 - roi.x0))
def test_rel_slices_are_valid(self): def test_rel_slices_are_valid(self):
roiset = self._make_roi_set() roiset = self._make_roi_set()
for roi in roiset: for roi in roiset:
...@@ -85,6 +97,7 @@ class TestRoiSetMonoProducts(BaseTestRoiSetMonoProducts, unittest.TestCase): ...@@ -85,6 +97,7 @@ class TestRoiSetMonoProducts(BaseTestRoiSetMonoProducts, unittest.TestCase):
self.assertEqual(len(rbb.shape), 4) self.assertEqual(len(rbb.shape), 4)
self.assertTrue(np.all([si >= 1 for si in rbb.shape])) self.assertTrue(np.all([si >= 1 for si in rbb.shape]))
def test_make_2d_patches(self): def test_make_2d_patches(self):
roiset = self._make_roi_set() roiset = self._make_roi_set()
files = roiset.export_patches( files = roiset.export_patches(
......
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