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

Accidentally not taking mask MIP

parent 8e56b0e6
No related branches found
No related tags found
2 merge requests!65Release 2024.10.01,!57RoiSet facilitates object detection models
This commit is part of merge request !57. Comments created here will be created in the context of that merge request.
......@@ -174,12 +174,10 @@ def _make_df_from_object_ids(acc_raw, acc_obj_ids, expand_box_by) -> pd.DataFram
# TODO: make this contingent on whether seg is included
def _make_binary_mask(r):
acc = InMemoryDataAccessor(acc_obj_ids.data == r.label)
acc.get_mono(0, mip=True)
cropped = acc.crop_hw((r.y0, r.x0, (r.y1 - r.y0), (r.x1 - r.x0))).data
cropped = acc.get_mono(0, mip=True).crop_hw((r.y0, r.x0, (r.y1 - r.y0), (r.x1 - r.x0))).data
return cropped
df['binary_mask'] = df.apply(
# lambda r: (acc_obj_ids.data == r.label).max(axis=-1)[r.y0: r.y1, r.x0: r.x1, 0],
_make_binary_mask,
axis=1,
result_type='reduce',
......@@ -525,16 +523,13 @@ class RoiSet(object):
patch = np.zeros((roi.ebb_h, roi.ebb_w, 1, 1), dtype='uint8')
patch[roi.relative_slice][:, :, 0, 0] = roi.binary_mask * 255
else:
patch = np.zeros((roi.y1 - roi.y0, roi.x1 - roi.x0, 1, 1), dtype='uint8')
patch = roi.binary_mask * 255
patch = (roi.binary_mask * 255).astype('uint8')
if pad_to:
patch = pad(patch, pad_to)
return patch
dfe = self._df.copy()
# TODO: can just pass function handle
dfe['patch_mask'] = dfe.apply(lambda r: _make_patch_mask(r), axis=1)
dfe['patch_mask'] = dfe.apply(_make_patch_mask, axis=1)
return dfe
def get_patch_masks_acc(self, **kwargs) -> PatchStack:
......
......@@ -634,6 +634,7 @@ class TestRoiSetSerialization(unittest.TestCase):
m_acc = generate_file_accessor(pmf)
self.assertEqual((roi.h, roi.w), m_acc.hw)
patch_filenames.append(pmf.name)
self.assertEqual(m_acc.nz, 1)
# make another RoiSet from just the data table, raw images, and (tight) patch masks
test_roiset = RoiSet.deserialize(self.stack_ch_pa, where_ser, prefix='ref')
......
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