Skip to content

Commit a4d601c

Browse files
Try to debug CLI tests
1 parent 632834b commit a4d601c

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

flamingo_tools/measurements.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ def intensity_measures(seg_id):
5353

5454
bb_min = np.array([
5555
row.bb_min_z.item(), row.bb_min_y.item(), row.bb_min_x.item()
56-
]) / resolution
56+
]).astype("float32") / resolution
5757
bb_min = np.round(bb_min, 0).astype("uint32")
5858

5959
bb_max = np.array([
6060
row.bb_max_z.item(), row.bb_max_y.item(), row.bb_max_x.item()
61-
]) / resolution
61+
]).astype("float32") / resolution
6262
bb_max = np.round(bb_max, 0).astype("uint32")
6363

6464
bb = tuple(
@@ -68,15 +68,16 @@ def intensity_measures(seg_id):
6868

6969
local_image = image[bb]
7070
mask = segmentation[bb] == seg_id
71+
assert mask.sum() > 0, f"Segmentation ID {seg_id} is empty."
7172
masked_intensity = local_image[mask]
7273

7374
# Do the base intensity measurements.
7475
measures = {
7576
"label_id": seg_id,
7677
"mean": np.mean(masked_intensity),
7778
"stdev": np.std(masked_intensity),
78-
"min": np.nanmin(masked_intensity),
79-
"max": np.nanmax(masked_intensity),
79+
"min": np.min(masked_intensity),
80+
"max": np.max(masked_intensity),
8081
"median": np.median(masked_intensity),
8182
}
8283
for percentile in (5, 10, 25, 75, 90, 95):

flamingo_tools/segmentation/postprocessing.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ def neighbors_in_radius(table: pd.DataFrame, radius: float = 15) -> np.ndarray:
118118
def _compute_table(segmentation, resolution):
119119
props = measure.regionprops(segmentation)
120120
label_ids = np.array([prop.label for prop in props])
121-
coordinates = np.array([prop.centroid for prop in props])
121+
coordinates = np.array([prop.centroid for prop in props]).astype("float32")
122122
# transform pixel distance to physical units
123123
coordinates = coordinates * resolution
124-
bb_min = np.array([prop.bbox[:3] for prop in props]) * resolution
125-
bb_max = np.array([prop.bbox[3:] for prop in props]) * resolution
124+
bb_min = np.array([prop.bbox[:3] for prop in props]).astype("float32") * resolution
125+
bb_max = np.array([prop.bbox[3:] for prop in props]).astype("float32") * resolution
126126
sizes = np.array([prop.area for prop in props])
127127
table = pd.DataFrame({
128128
"label_id": label_ids,

0 commit comments

Comments
 (0)