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

Removed solidity from features, this was no longer being used and was...

Removed solidity from features, this was no longer being used and was triggering convex hull warnings
parent 691a9fce
No related branches found
No related tags found
2 merge requests!18Completed (de)serialization of RoiSet,!16Completed (de)serialization of RoiSet
......@@ -44,7 +44,6 @@ class RoiFilterRange(BaseModel):
class RoiFilter(BaseModel):
area: Union[RoiFilterRange, None] = None
solidity: Union[RoiFilterRange, None] = None
class RoiSetMetaParams(BaseModel):
......@@ -164,38 +163,21 @@ class RoiSet(object):
:return: pd.DataFrame
"""
# build dataframe of objects, assign z index to each object
if acc_obj_ids.nz == 1: # deproject objects' z-coordinates from argmax of raw image
argmax = acc_raw.data.argmax(axis=3, keepdims=True)[:, :, 0, 0].astype('uint16')
df = (
pd.DataFrame(
regionprops_table(
acc_obj_ids.data[:, :, 0, 0],
intensity_image=argmax,
properties=('label', 'area', 'intensity_mean', 'solidity', 'bbox', 'centroid')
)
)
.rename(
columns={'bbox-0': 'y0', 'bbox-1': 'x0', 'bbox-2': 'y1', 'bbox-3': 'x1', }
)
)
df = pd.DataFrame(regionprops_table(
acc_obj_ids.data[:, :, 0, 0],
intensity_image=acc_raw.data.argmax(axis=3, keepdims=True)[:, :, 0, 0].astype('uint16'),
properties=('label', 'area', 'intensity_mean', 'bbox', 'centroid')
)).rename(columns={'bbox-0': 'y0', 'bbox-1': 'x0', 'bbox-2': 'y1', 'bbox-3': 'x1'})
df['zi'] = df['intensity_mean'].round().astype('int')
else: # objects' z-coordinates come from arg of max count in object identities map
df = (
pd.DataFrame(
regionprops_table(
acc_obj_ids.data[:, :, 0, :],
properties=('label', 'area', 'solidity', 'bbox', 'centroid')
)
)
.rename(
columns={'bbox-0': 'y0', 'bbox-1': 'x0', 'bbox-2': 'y1', 'bbox-3': 'x1', }
)
)
def _get_zi_from_obj_map_counts(la):
return (acc_obj_ids.data == la).sum(axis=(0, 1, 2)).argmax()
df['zi'] = df['label'].apply(_get_zi_from_obj_map_counts)
else: # objects' z-coordinates come from arg of max count in object identities map
df = pd.DataFrame(regionprops_table(
acc_obj_ids.data[:, :, 0, :],
properties=('label', 'area', 'bbox', 'centroid')
)).rename(columns={'bbox-0': 'y0', 'bbox-1': 'x0', 'bbox-2': 'z0', 'bbox-3': 'y1', 'bbox-4': 'x1', 'bbox-5': 'z1'})
df['zi'] = df['label'].apply(lambda x: (acc_obj_ids.data == x).sum(axis=(0, 1, 2)).argmax())
# compute expanded bounding boxes
h, w, c, nz = acc_raw.shape
......@@ -272,7 +254,7 @@ class RoiSet(object):
query_str = 'label > 0' # always true
if filters is not None: # parse filters
for k, val in filters.dict(exclude_unset=True).items():
assert k in ('area', 'solidity')
assert k in ('area')
vmin = val['min']
vmax = val['max']
assert vmin >= 0
......
......@@ -279,11 +279,6 @@ class TestRoiSetFromZmask(unittest.TestCase):
is_2d = all([self._label_is_2d(id_map.data, la) for la in labels])
self.assertTrue(is_2d)
def test_3d_zmask(self):
write_accessor_data_to_file(output_path / 'roiset_from_3d' / 'raw.tif', self.roiset.acc_raw)
# write_accessor_data_to_file(output_path / 'roiset_from_3d' / 'ob_ids.tif', self.roiset.acc_obj_ids)
write_accessor_data_to_file(output_path / 'roiset_from_3d' / 'zmask.tif', self.zmask)
def test_create_roiset_from_3d_obj_ids(self):
id_map = _get_label_ids(self.seg_mask_3d, allow_3d=True, connect_3d=False)
self.assertEqual(self.stack_ch_pa.shape, id_map.shape)
......
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