Skip to content

Commit b0716af

Browse files
timblakelycopybara-github
authored andcommitted
Allow specifying threshold_abs and threshold_rel. This fixes the drop-everything-under-zero bug in ExaSPIM
PiperOrigin-RevId: 897242664
1 parent 61e43ff commit b0716af

1 file changed

Lines changed: 29 additions & 1 deletion

File tree

ffn/inference/seed.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,39 @@ def init_coords(self):
316316
class PolicyMaxPeaks(BaseSeedPolicy):
317317
"""Local peaks of intensity."""
318318

319+
def __init__(
320+
self, canvas, min_distance=3, threshold_abs=0, threshold_rel=0, **kwargs
321+
):
322+
"""Initialize settings.
323+
324+
Args:
325+
canvas: inference Canvas object.
326+
min_distance: forwarded to peak_local_max.
327+
threshold_abs: forwarded to peak_local_max.
328+
threshold_rel: forwarded to peak_local_max.
329+
**kwargs: forwarded to base.
330+
"""
331+
super().__init__(canvas, **kwargs)
332+
logging.info(
333+
'max peaks: min_distance=%s, threshold_abs=%s, threshold_rel=%s',
334+
min_distance,
335+
threshold_abs,
336+
threshold_rel,
337+
)
338+
self.min_distance = min_distance
339+
self.threshold_abs = threshold_abs
340+
self.threshold_rel = threshold_rel
341+
319342
def init_coords(self):
320343
img = self.canvas.image.astype(np.float32).copy()
321344
mask = self.get_exclusion_mask()
322345
img[mask] = 0
323-
idxs = _find_peaks(img, min_distance=3, threshold_abs=0, threshold_rel=0)
346+
idxs = _find_peaks(
347+
img,
348+
min_distance=self.min_distance,
349+
threshold_abs=self.threshold_abs,
350+
threshold_rel=self.threshold_rel,
351+
)
324352
self.coords = np.array(sorted((z, y, x) for z, y, x in idxs))
325353

326354

0 commit comments

Comments
 (0)