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
No related merge requests found
...@@ -174,12 +174,10 @@ def _make_df_from_object_ids(acc_raw, acc_obj_ids, expand_box_by) -> pd.DataFram ...@@ -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 # TODO: make this contingent on whether seg is included
def _make_binary_mask(r): def _make_binary_mask(r):
acc = InMemoryDataAccessor(acc_obj_ids.data == r.label) acc = InMemoryDataAccessor(acc_obj_ids.data == r.label)
acc.get_mono(0, mip=True) cropped = acc.get_mono(0, mip=True).crop_hw((r.y0, r.x0, (r.y1 - r.y0), (r.x1 - r.x0))).data
cropped = acc.crop_hw((r.y0, r.x0, (r.y1 - r.y0), (r.x1 - r.x0))).data
return cropped return cropped
df['binary_mask'] = df.apply( 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, _make_binary_mask,
axis=1, axis=1,
result_type='reduce', result_type='reduce',
...@@ -525,16 +523,13 @@ class RoiSet(object): ...@@ -525,16 +523,13 @@ class RoiSet(object):
patch = np.zeros((roi.ebb_h, roi.ebb_w, 1, 1), dtype='uint8') patch = np.zeros((roi.ebb_h, roi.ebb_w, 1, 1), dtype='uint8')
patch[roi.relative_slice][:, :, 0, 0] = roi.binary_mask * 255 patch[roi.relative_slice][:, :, 0, 0] = roi.binary_mask * 255
else: else:
patch = np.zeros((roi.y1 - roi.y0, roi.x1 - roi.x0, 1, 1), dtype='uint8') patch = (roi.binary_mask * 255).astype('uint8')
patch = roi.binary_mask * 255
if pad_to: if pad_to:
patch = pad(patch, pad_to) patch = pad(patch, pad_to)
return patch return patch
dfe = self._df.copy() dfe = self._df.copy()
# TODO: can just pass function handle dfe['patch_mask'] = dfe.apply(_make_patch_mask, axis=1)
dfe['patch_mask'] = dfe.apply(lambda r: _make_patch_mask(r), axis=1)
return dfe return dfe
def get_patch_masks_acc(self, **kwargs) -> PatchStack: def get_patch_masks_acc(self, **kwargs) -> PatchStack:
......
...@@ -634,6 +634,7 @@ class TestRoiSetSerialization(unittest.TestCase): ...@@ -634,6 +634,7 @@ class TestRoiSetSerialization(unittest.TestCase):
m_acc = generate_file_accessor(pmf) m_acc = generate_file_accessor(pmf)
self.assertEqual((roi.h, roi.w), m_acc.hw) self.assertEqual((roi.h, roi.w), m_acc.hw)
patch_filenames.append(pmf.name) 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 # 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') 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