From d6e8310d8ccea20a643f945293125d6353b6187c Mon Sep 17 00:00:00 2001 From: Ethan Blackwood Date: Sun, 25 Aug 2024 21:55:54 -0400 Subject: [PATCH] Make computing_indicator work with sparse A_in --- caiman/source_extraction/cnmf/spatial.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/caiman/source_extraction/cnmf/spatial.py b/caiman/source_extraction/cnmf/spatial.py index 0ba5f2b4e..a72c28385 100644 --- a/caiman/source_extraction/cnmf/spatial.py +++ b/caiman/source_extraction/cnmf/spatial.py @@ -1063,8 +1063,15 @@ def computing_indicator(Y, A_in, b, C, f, nb, method, dims, min_size, max_size, Y) - dist_indicator_av.T.dot(b).dot(f), 0) A_in = scipy.sparse.coo_matrix(A_in.astype(np.float32)) nr, _ = np.shape(C) # number of neurons - ind2_ = [np.hstack((np.where(iid_)[0], nr + np.arange(f.shape[0]))) - if np.size(np.where(iid_)[0]) > 0 else [] for iid_ in dist_indicator] + ind2_ = [] + for iid_ in dist_indicator: + if scipy.sparse.issparse(iid_): + iid_ = iid_.toarray().squeeze() + comps = np.where(iid_)[0] + if np.size(comps) > 0: + ind2_.append(np.hstack((comps, nr + np.arange(f.shape[0])))) + else: + ind2_.append([]) else: if C is None: