Skip to content

Commit c51947d

Browse files
committed
Fixed indexing of components
1 parent c6e2b04 commit c51947d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

flamingo_tools/segmentation/postprocessing.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,8 @@ def downscaled_centroids(
290290
new_array[int(c[0]), int(c[1]), int(c[2])] += 1
291291

292292
elif downsample_mode == "capped":
293-
new_array = np.round(new_array).astype(int)
294-
new_array[new_array >= 1] = 1
293+
for c in centroids_scaled:
294+
new_array[int(c[0]), int(c[1]), int(c[2])] = 1
295295

296296
elif downsample_mode == "components":
297297
if "component_labels" not in table.columns:
@@ -300,11 +300,12 @@ def downscaled_centroids(
300300
for comp, centr in zip(component_labels, centroids_scaled):
301301
if comp != 0:
302302
new_array[int(centr[0]), int(centr[1]), int(centr[2])] = comp
303-
new_array = np.round(new_array).astype(int)
304303

305304
else:
306305
raise ValueError("Choose one of the downsampling modes 'accumulated', 'capped', or 'components'.")
307306

307+
new_array = np.round(new_array).astype(int)
308+
308309
return new_array
309310

310311

@@ -531,7 +532,7 @@ def component_labels_graph(table: pd.DataFrame) -> List[int]:
531532
component_labels = [0 for _ in range(len(table))]
532533
for lab, comp in enumerate(components):
533534
for comp_index in comp:
534-
component_labels[comp_index] = lab + 1
535+
component_labels[comp_index - 1] = lab + 1
535536

536537
return component_labels
537538

0 commit comments

Comments
 (0)