Skip to content

Commit b92d06e

Browse files
authored
Refactor return value and update mask_window calculation
Modified return value to return an array instead of a single item. Updated mask_window calculation to handle float conversion and adjusted logging for spatial scale.
1 parent e6ed85f commit b92d06e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

suite2p/detection/sparsedetect.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ def estimate_spatial_scale(I):
452452
ipk = np.abs(I0 - maximum_filter(I0, size=(11, 11))).flatten() < 1e-4
453453
isort = np.argsort(I0.flatten()[ipk])[::-1]
454454
im, _ = mode(imap[ipk][isort[:50]], keepdims=True)
455-
return im.item()
455+
return im
456456

457457

458458
def find_best_scale(I, spatial_scale):
@@ -565,12 +565,13 @@ def sparsery(mov, sdmov, highpass_neuropil,
565565
scale, estimate_mode = find_best_scale(I=I, spatial_scale=spatial_scale)
566566

567567
spatscale_pix = 3 * 2**scale
568-
mask_window = int(((spatscale_pix * 1.5) // 2) * 2)
568+
print(np.size(spatscale_pix))
569+
mask_window = int(((float(np.asarray(spatscale_pix).item()) * 1.5) // 2) * 2)
569570
Th2 = threshold_scaling * 5 * max(
570571
1, scale) # threshold for accepted peaks (scale it by spatial scale)
571572
vmultiplier = max(1, mov.shape[0] / 1200)
572573
logger.info("NOTE: %s spatial scale ~%d pixels, time epochs %2.2f, threshold %2.2f " %
573-
(estimate_mode.value, spatscale_pix, vmultiplier, vmultiplier * Th2))
574+
(estimate_mode.value, np.asarray(spatscale_pix).item(), vmultiplier, vmultiplier * Th2))
574575

575576
# get standard deviation for pixels for all values > Th2
576577
v_map = [threshold_reduce(movu0, Th2) for movu0 in movu]

0 commit comments

Comments
 (0)