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

Passes, long warnings that convex hull calcs don't work

parent 8254cad5
No related branches found
No related tags found
2 merge requests!18Completed (de)serialization of RoiSet,!16Completed (de)serialization of RoiSet
......@@ -154,18 +154,17 @@ class RoiSet(object):
return self._df.itertuples(name='Roi')
@staticmethod
def make_df(acc_raw, acc_obj_ids, expand_box_by, deproject=True) -> pd.DataFrame:
def make_df(acc_raw, acc_obj_ids, expand_box_by) -> pd.DataFrame:
"""
Build dataframe associate object IDs with summary stats
:param acc_raw: accessor to raw image data
:param acc_obj_ids: accessor to map of object IDs
:param expand_box_by: number of pixels to expand bounding box in all directions (without exceeding image boundary)
:param deproject: assign object's z-position based on argmax of raw data if True
# :param deproject: assign object's z-position based on argmax of raw data if True
:return: pd.DataFrame
"""
# build dataframe of objects, assign z index to each object
if deproject:
assert acc_obj_ids.nz == 1, 'Can only deproject a 2D object identity map'
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(
......@@ -180,7 +179,7 @@ class RoiSet(object):
)
)
df['zi'] = df['intensity_mean'].round().astype('int')
else:
else: # objects' z-coordinates come from arg of max count in object identities map
df = (
pd.DataFrame(
regionprops_table(
......@@ -192,7 +191,10 @@ class RoiSet(object):
columns={'bbox-0': 'y0', 'bbox-1': 'x0', 'bbox-2': 'y1', 'bbox-3': 'x1', }
)
)
df['zi'] = ... # from somewhere in obmap floor of avg z for each label...
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)
# compute expanded bounding boxes
......
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