Skip to content

Commit 957861f

Browse files
committed
Sparsify the weights
1 parent 0ae32e7 commit 957861f

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/spikeinterface/sortingcomponents/peak_detection.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ def __init__(
631631
weight_method={},
632632
):
633633
PeakDetector.__init__(self, recording, return_output=True)
634-
634+
import scipy
635635
if not HAVE_NUMBA:
636636
raise ModuleNotFoundError('matched_filtering" needs numba which is not installed')
637637

@@ -664,7 +664,7 @@ def __init__(
664664
self.num_templates *= 2
665665

666666
self.weights = self.weights.reshape(self.num_templates * self.num_z_factors, -1)
667-
667+
self.weights = scipy.sparse.csr_matrix(self.weights)
668668
random_data = get_random_data_chunks(recording, return_scaled=False, **random_chunk_kwargs)
669669
conv_random_data = self.get_convolved_traces(random_data)
670670
medians = np.median(conv_random_data, axis=1)
@@ -737,7 +737,7 @@ def get_convolved_traces(self, traces):
737737
import scipy.signal
738738

739739
tmp = scipy.signal.oaconvolve(self.prototype[None, :], traces.T, axes=1, mode="valid")
740-
scalar_products = np.dot(self.weights, tmp)
740+
scalar_products = self.weights.dot(tmp)
741741
return scalar_products
742742

743743

0 commit comments

Comments
 (0)