@@ -88,6 +88,7 @@ def compute_overlaps(templates, num_samples, num_channels, sparsities):
8888
8989 return new_overlaps
9090
91+
9192class CircusOMPSVDPeeler (BaseTemplateMatching ):
9293 """
9394 Orthogonal Matching Pursuit inspired from Spyking Circus sorter
@@ -121,17 +122,21 @@ class CircusOMPSVDPeeler(BaseTemplateMatching):
121122 """
122123
123124 _more_output_keys = [
124- "norms" ,
125- "temporal" ,
126- "spatial" ,
127- "singular" ,
128- "units_overlaps" ,
129- "unit_overlaps_indices" ,
130- "normed_templates" ,
131- "overlaps" ,
132- ]
133-
134- def __init__ (self , recording , return_output = True , parents = None ,
125+ "norms" ,
126+ "temporal" ,
127+ "spatial" ,
128+ "singular" ,
129+ "units_overlaps" ,
130+ "unit_overlaps_indices" ,
131+ "normed_templates" ,
132+ "overlaps" ,
133+ ]
134+
135+ def __init__ (
136+ self ,
137+ recording ,
138+ return_output = True ,
139+ parents = None ,
135140 templates = None ,
136141 amplitudes = [0.6 , np .inf ],
137142 stop_criteria = "max_failures" ,
@@ -142,7 +147,7 @@ def __init__(self, recording, return_output=True, parents=None,
142147 ignore_inds = [],
143148 vicinity = 3 ,
144149 precomputed = None ,
145- ):
150+ ):
146151
147152 BaseTemplateMatching .__init__ (self , recording , templates , return_output = True , parents = None )
148153
@@ -169,7 +174,6 @@ def __init__(self, recording, return_output=True, parents=None,
169174 assert precomputed [key ] is not None , "If templates are provided, %d should also be there" % key
170175 setattr (self , key , precomputed [key ])
171176
172-
173177 self .ignore_inds = np .array (ignore_inds )
174178
175179 self .unit_overlaps_tables = {}
@@ -182,7 +186,6 @@ def __init__(self, recording, return_output=True, parents=None,
182186 else :
183187 self .margin = 2 * self .num_samples
184188
185-
186189 def _prepare_templates (self ):
187190
188191 assert self .stop_criteria in ["max_failures" , "omp_min_sps" , "relative_error" ]
@@ -256,11 +259,8 @@ def get_extra_outputs(self):
256259 output [key ] = getattr (self , key )
257260 return output
258261
259-
260-
261-
262262 def get_trace_margin (self ):
263- return self .margin
263+ return self .margin
264264
265265 def compute_matching (self , traces , start_frame , end_frame , segment_index ):
266266 import scipy .spatial
@@ -468,10 +468,8 @@ def compute_matching(self, traces, start_frame, end_frame, segment_index):
468468 if spikes .size > 0 :
469469 order = np .argsort (spikes ["sample_index" ])
470470 spikes = spikes [order ]
471-
472- return spikes
473-
474471
472+ return spikes
475473
476474
477475class CircusPeeler (BaseTemplateMatching ):
@@ -519,19 +517,23 @@ class CircusPeeler(BaseTemplateMatching):
519517
520518
521519 """
522- def __init__ (self , recording , return_output = True , parents = None ,
523-
524- templates = None ,
525- peak_sign = "neg" ,
526- exclude_sweep_ms = 0.1 ,
527- jitter_ms = 0.1 ,
528- detect_threshold = 5 ,
529- noise_levels = None ,
530- random_chunk_kwargs = {},
531- max_amplitude = 1.5 ,
532- min_amplitude = 0.5 ,
533- use_sparse_matrix_threshold = 0.25 ,
534- ):
520+
521+ def __init__ (
522+ self ,
523+ recording ,
524+ return_output = True ,
525+ parents = None ,
526+ templates = None ,
527+ peak_sign = "neg" ,
528+ exclude_sweep_ms = 0.1 ,
529+ jitter_ms = 0.1 ,
530+ detect_threshold = 5 ,
531+ noise_levels = None ,
532+ random_chunk_kwargs = {},
533+ max_amplitude = 1.5 ,
534+ min_amplitude = 0.5 ,
535+ use_sparse_matrix_threshold = 0.25 ,
536+ ):
535537
536538 BaseTemplateMatching .__init__ (self , recording , templates , return_output = True , parents = None )
537539
@@ -544,7 +546,9 @@ def __init__(self, recording, return_output=True, parents=None,
544546
545547 assert HAVE_SKLEARN , "CircusPeeler needs sklearn to work"
546548
547- assert (use_sparse_matrix_threshold >= 0 ) and (use_sparse_matrix_threshold <= 1 ), f"use_sparse_matrix_threshold should be in [0, 1]"
549+ assert (use_sparse_matrix_threshold >= 0 ) and (
550+ use_sparse_matrix_threshold <= 1
551+ ), f"use_sparse_matrix_threshold should be in [0, 1]"
548552
549553 self .num_channels = recording .get_num_channels ()
550554 self .num_samples = templates .num_samples
@@ -580,8 +584,6 @@ def __init__(self, recording, return_output=True, parents=None,
580584 self .margin = max (self .nbefore , self .nafter ) * 2
581585 self .peak_sign = peak_sign
582586
583-
584-
585587 def _prepare_templates (self ):
586588 import scipy .spatial
587589 import scipy
@@ -617,7 +619,6 @@ def _prepare_templates(self):
617619 def get_trace_margin (self ):
618620 return self .margin
619621
620-
621622 def compute_matching (self , traces , start_frame , end_frame , segment_index ):
622623
623624 neighbor_window = self .num_samples - 1
@@ -702,4 +703,3 @@ def compute_matching(self, traces, start_frame, end_frame, segment_index):
702703 spikes = spikes [order ]
703704
704705 return spikes
705-
0 commit comments