Skip to content

Commit 2c666af

Browse files
authored
Do not unnecessarily increase community numbers in assign_communities (#21)
1 parent b7907e5 commit 2c666af

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

spatiomic/segment/_assign_communities.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ def assign_communities(
5050
# Initialize output with same shape as masks
5151
community_image = np.zeros_like(masks)
5252

53-
# Assign community labels (adding 1 to avoid confusion with background)
53+
# Assign community labels (adding 1 to avoid confusion with background, if needed)
54+
pseudocount = 1 if communities_array.min() == 0 else 0
5455
for i, region_id in enumerate(unique_regions):
55-
community_image[masks == region_id] = communities_array[i] + 1
56+
community_image[masks == region_id] = communities_array[i] + pseudocount
5657

5758
return community_image

0 commit comments

Comments
 (0)