From 962379882f2f804f8c1e2f15bd29544ffebe50f0 Mon Sep 17 00:00:00 2001 From: jacobpennington Date: Sat, 13 Apr 2024 10:01:25 -0700 Subject: [PATCH] fixed bug with center-finding for single-shank --- kilosort/clustering_qr.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kilosort/clustering_qr.py b/kilosort/clustering_qr.py index bc2052c0..4d1f1ab1 100644 --- a/kilosort/clustering_qr.py +++ b/kilosort/clustering_qr.py @@ -248,7 +248,9 @@ def x_centers(ops): # peaks are indices, translate back to position in microns approx_centers = [edges[p] for p in peaks] # Use these as initial guesses for centroids in k-means to get - # a more accurate value for the actual centers. + # a more accurate value for the actual centers. Or, if there's only 1, + # just look for one centroid. + if len(approx_centers) == 1: approx_centers = 1 centers, distortion = kmeans(ops['xc'], approx_centers) # TODO: Maybe use distortion to raise warning if it seems too large?