@@ -72,7 +72,6 @@ def remove_redundant_units(
7272 sorting = sorting_or_sorting_analyzer .sorting
7373 sorting_analyzer = sorting_or_sorting_analyzer
7474 else :
75- assert not align , "The 'align' option is only available when a SortingAnalyzer is used as input"
7675 # other remove strategies rely on sorting analyzer looking at templates
7776 assert remove_strategy == "max_spikes" , "For a Sorting input the remove_strategy must be 'max_spikes'"
7877 sorting = sorting_or_sorting_analyzer
@@ -108,25 +107,15 @@ def remove_redundant_units(
108107 remove_unit_ids .append (u1 )
109108 elif np .abs (unit_peak_shifts [u1 ]) < np .abs (unit_peak_shifts [u2 ]):
110109 remove_unit_ids .append (u2 )
111- else :
112- # equal shift use peak values
113- if np .abs (peak_values [u1 ]) < np .abs (peak_values [u2 ]):
114- remove_unit_ids .append (u1 )
115- else :
116- remove_unit_ids .append (u2 )
110+ else : # equal shift use peak values
111+ remove_unit_ids .append (u1 if peak_values [u1 ] < peak_values [u2 ] else u2 )
117112 elif remove_strategy == "highest_amplitude" :
118113 for u1 , u2 in redundant_unit_pairs :
119- if np .abs (peak_values [u1 ]) < np .abs (peak_values [u2 ]):
120- remove_unit_ids .append (u1 )
121- else :
122- remove_unit_ids .append (u2 )
114+ remove_unit_ids .append (u1 if peak_values [u1 ] < peak_values [u2 ] else u2 )
123115 elif remove_strategy == "max_spikes" :
124116 num_spikes = sorting .count_num_spikes_per_unit (outputs = "dict" )
125117 for u1 , u2 in redundant_unit_pairs :
126- if num_spikes [u1 ] < num_spikes [u2 ]:
127- remove_unit_ids .append (u1 )
128- else :
129- remove_unit_ids .append (u2 )
118+ remove_unit_ids .append (u1 if num_spikes [u1 ] < num_spikes [u2 ] else u2 )
130119 elif remove_strategy == "with_metrics" :
131120 # TODO
132121 # @aurelien @alessio
@@ -162,9 +151,7 @@ def find_redundant_units(sorting, delta_time: float = 0.4, agreement_threshold=0
162151
163152 Returns
164153 -------
165- list
166- The list of duplicate units
167- list of 2-element lists
154+ list of 2-element tuples
168155 The list of duplicate pairs
169156 """
170157 from spikeinterface .comparison import compare_two_sorters
@@ -186,6 +173,6 @@ def find_redundant_units(sorting, delta_time: float = 0.4, agreement_threshold=0
186173 event_counts = comparison .event_counts1
187174 shared = max (n_coincidents / event_counts [unit_i ], n_coincidents / event_counts [unit_j ])
188175 if shared > duplicate_threshold :
189- redundant_unit_pairs .append ([ unit_i , unit_j ] )
176+ redundant_unit_pairs .append (( unit_i , unit_j ) )
190177
191178 return redundant_unit_pairs
0 commit comments