From a81bb3e22b5687424991afc374e50da6440c8af2 Mon Sep 17 00:00:00 2001 From: Ran Lu Date: Thu, 30 Nov 2023 13:49:40 -0500 Subject: [PATCH] Better conversion from probability map to affinity --- scripts/cut_chunk_common.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/cut_chunk_common.py b/scripts/cut_chunk_common.py index 1a3a2d9..a54f91b 100644 --- a/scripts/cut_chunk_common.py +++ b/scripts/cut_chunk_common.py @@ -42,7 +42,9 @@ def cut_data(data, start_coord, end_coord, padding): bb = tuple(slice(start_coord[i], end_coord[i]) for i in range(3)) if data.shape[3] == 1: if data.dtype == 'float32': - return pad_data(numpy.stack([numpy.squeeze(data[bb])]*3, axis=-1), padding) + pmap = numpy.squeeze(data[bb]) + affinity = [numpy.minimum(numpy.roll(pmap, shift=1, axis=axis), pmap) for axis in range(3)] + return pad_data(numpy.stack(affinity, axis=-1), padding) else: return pad_data(data[bb], padding) elif data.shape[3] == 3: