@@ -116,7 +116,17 @@ def neighbors_in_radius(table: pd.DataFrame, radius: float = 15) -> np.ndarray:
116116
117117
118118def compute_table_on_the_fly (segmentation : np .typing .ArrayLike , resolution : float ) -> pd .DataFrame :
119- """
119+ """Compute a segmentation table compatible with MoBIE.
120+
121+ The table contains information about the number of pixels per object,
122+ the anchor (= centroid) and the bounding box. Anchor and bounding box are given in physical coordinates.
123+
124+ Args:
125+ segmentation: The segmentation for which to compute the table.
126+ resolution: The physical voxel spacing of the data.
127+
128+ Returns:
129+ The segmentation table.
120130 """
121131 props = measure .regionprops (segmentation )
122132 label_ids = np .array ([prop .label for prop in props ])
@@ -128,7 +138,6 @@ def compute_table_on_the_fly(segmentation: np.typing.ArrayLike, resolution: floa
128138 sizes = np .array ([prop .area for prop in props ])
129139 table = pd .DataFrame ({
130140 "label_id" : label_ids ,
131- "n_pixels" : sizes ,
132141 "anchor_x" : coordinates [:, 2 ],
133142 "anchor_y" : coordinates [:, 1 ],
134143 "anchor_z" : coordinates [:, 0 ],
@@ -138,6 +147,7 @@ def compute_table_on_the_fly(segmentation: np.typing.ArrayLike, resolution: floa
138147 "bb_max_x" : bb_max [:, 2 ],
139148 "bb_max_y" : bb_max [:, 1 ],
140149 "bb_max_z" : bb_max [:, 0 ],
150+ "n_pixels" : sizes ,
141151 })
142152 return table
143153
@@ -170,8 +180,8 @@ def filter_segmentation(
170180 spatial_statistics_kwargs: Arguments for spatial statistics function
171181
172182 Returns:
173- n_ids
174- n_ids_filtered
183+ The number of objects before filtering.
184+ The number of objects after filtering.
175185 """
176186 # Compute the table on the fly. This doesn't work for large segmentations.
177187 if table is None :
0 commit comments