Skip to content

Commit f2ecef0

Browse files
Update doc strings
1 parent 944f6ee commit f2ecef0

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

flamingo_tools/measurements.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ def compute_object_measures_impl(
4343
n_threads: The number of threads to use for computation.
4444
resolution: The resolution / voxel size of the data.
4545
table: The segmentation table. Will be computed on the fly if it is not given.
46+
47+
Returns:
48+
The table with per object measurements.
4649
"""
4750
if table is None:
4851
table = compute_table_on_the_fly(segmentation, resolution=resolution)

flamingo_tools/segmentation/postprocessing.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,17 @@ def neighbors_in_radius(table: pd.DataFrame, radius: float = 15) -> np.ndarray:
116116

117117

118118
def 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

Comments
 (0)