Skip to content

Commit 40ff5ca

Browse files
Donglai Weiclaude
andcommitted
Drop branch_ prefix from merge params: unified naming with face_merge_pairs
branch_iou_threshold → iou_threshold, branch_best_buddy → best_buddy, branch_one_sided_threshold → one_sided_threshold, etc. Same names as face_merge_pairs and waterz_decoding_large.yaml. branch_merge remains as the enable flag. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1f5fb6f commit 40ff5ca

5 files changed

Lines changed: 40 additions & 42 deletions

File tree

connectomics/decoding/decoders/waterz.py

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ def decode_waterz(
4646
dust_merge_affinity: float = 0.0,
4747
dust_remove_size: int = 0,
4848
branch_merge: bool = False,
49-
branch_iou_threshold: float = 0.5,
50-
branch_best_buddy: bool = True,
51-
branch_one_sided_threshold: float = 0.8,
52-
branch_one_sided_min_size: int = 100,
53-
branch_affinity_threshold: float = 0.0,
49+
iou_threshold: float = 0.5,
50+
best_buddy: bool = True,
51+
one_sided_threshold: float = 0.8,
52+
one_sided_min_size: int = 100,
53+
affinity_threshold: float = 0.0,
5454
return_all_thresholds: bool = False,
5555
**kwargs: Any,
5656
) -> "np.ndarray | Dict[float, np.ndarray]":
@@ -123,18 +123,16 @@ def decode_waterz(
123123
branch_merge: Enable branch merge postprocessing. Resolves false
124124
splits by analyzing segment continuity across z-slices using
125125
IOU overlap, best-buddy matching, and one-sided IOU.
126-
Inspired by em_pipeline branch resolution. Default: False
127-
branch_iou_threshold: Stage 1 threshold for full Jaccard IOU
128-
merge between consecutive z-slices. Default: 0.5
129-
branch_best_buddy: Enable Stage 2 mutual best-match merge.
130-
Default: True
131-
branch_one_sided_threshold: Stage 3 one-sided IOU threshold.
132-
Merge if ``overlap / min(size0, size1)`` exceeds this.
133-
Set to 0 to disable. Default: 0.8
134-
branch_one_sided_min_size: Stage 3 minimum segment size in the
135-
slice to be considered for one-sided merge. Default: 100
136-
branch_affinity_threshold: Minimum mean z-boundary affinity for
137-
a branch merge to be accepted. 0 to disable. Default: 0.0
126+
Default: False
127+
iou_threshold: Full Jaccard IOU threshold for branch merge.
128+
Default: 0.5
129+
best_buddy: Enable mutual best-match merge. Default: True
130+
one_sided_threshold: One-sided IOU threshold
131+
(``overlap / min(size0, size1)``). 0 to disable. Default: 0.8
132+
one_sided_min_size: Minimum segment size in slice for one-sided
133+
merge. Default: 100
134+
affinity_threshold: Minimum mean z-boundary affinity for a merge.
135+
0 to disable. Default: 0.0
138136
return_all_thresholds: If True and multiple thresholds are given,
139137
return a dict mapping each threshold to its segmentation.
140138
Otherwise return only the last threshold's result. Default: False
@@ -302,11 +300,11 @@ def decode_waterz(
302300
seg = _branch_merge(
303301
seg,
304302
affinities=affs,
305-
iou_threshold=branch_iou_threshold,
306-
best_buddy=branch_best_buddy,
307-
one_sided_threshold=branch_one_sided_threshold,
308-
one_sided_min_size=branch_one_sided_min_size,
309-
affinity_threshold=branch_affinity_threshold,
303+
iou_threshold=iou_threshold,
304+
best_buddy=best_buddy,
305+
one_sided_threshold=one_sided_threshold,
306+
one_sided_min_size=one_sided_min_size,
307+
affinity_threshold=affinity_threshold,
310308
channel_order="zyx", # already converted above
311309
)
312310
n_after = len(np.unique(seg)) - (1 if 0 in seg else 0)

connectomics/training/lightning/model.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -912,10 +912,10 @@ def _log_decode_experiment(
912912
if decode_params.get("branch_merge"):
913913
param_keys += [
914914
"branch_merge",
915-
"branch_iou_threshold",
916-
"branch_best_buddy",
917-
"branch_one_sided_threshold",
918-
"branch_one_sided_min_size",
915+
"iou_threshold",
916+
"best_buddy",
917+
"one_sided_threshold",
918+
"one_sided_min_size",
919919
]
920920
metric_keys = [
921921
"adapted_rand_error",

connectomics/training/lightning/utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -474,11 +474,11 @@ def _sanitize_decode_component(text: str) -> str:
474474

475475
gated_value_groups = {
476476
"branch_merge": [
477-
"branch_iou_threshold",
478-
"branch_best_buddy",
479-
"branch_one_sided_threshold",
480-
"branch_one_sided_min_size",
481-
"branch_affinity_threshold",
477+
"iou_threshold",
478+
"best_buddy",
479+
"one_sided_threshold",
480+
"one_sided_min_size",
481+
"affinity_threshold",
482482
],
483483
"dust_merge": [
484484
"dust_merge_size",

tutorials/neuron_snemi.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ test:
9292
dust_merge_size: 800
9393
dust_merge_affinity: 0.3
9494
dust_remove_size: 600
95-
branch_merge: false # enable branch merge
96-
branch_iou_threshold: 0.5 # S1: full Jaccard IOU threshold
97-
branch_best_buddy: true # S2: mutual best-match merge
98-
branch_one_sided_threshold: 0.8 # S3: one-sided IOU threshold (0 to disable)
99-
branch_one_sided_min_size: 100 # S3: min segment size for one-sided merge
100-
branch_affinity_threshold: 0.0 # min z-boundary affinity (0=no check)
95+
branch_merge: false
96+
iou_threshold: 0.5
97+
best_buddy: true
98+
one_sided_threshold: 0.8
99+
one_sided_min_size: 100
100+
affinity_threshold: 0.0
101101

102102

103103
# ============================================================================

tutorials/neuron_snemi_sdt_multitask.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,17 +160,17 @@ test:
160160
#use_seg_uint32: true # uint32 segment IDs (2x less seg memory)
161161
thresholds: 0.4
162162
merge_function: aff85_his256
163-
aff_threshold: [0.1, 0.999]
163+
aff_threshold: [0.1, 0.9]
164164
border_threshold: 0
165165
dust_merge: true
166166
dust_merge_size: 800
167167
dust_merge_affinity: 0.3
168168
dust_remove_size: 600
169169
branch_merge: false
170-
branch_iou_threshold: 0.5
171-
branch_best_buddy: true
172-
branch_one_sided_threshold: 0.8
173-
branch_one_sided_min_size: 100
170+
iou_threshold: 0.5
171+
best_buddy: true
172+
one_sided_threshold: 0.8
173+
one_sided_min_size: 100
174174

175175
# ============================================================================
176176
# Parameter tuning for waterz agglomeration thresholds (--mode tune)

0 commit comments

Comments
 (0)