@@ -120,31 +120,31 @@ the unit (among the redundant ones), with a better template alignment.
120120Auto-merging units
121121^^^^^^^^^^^^^^^^^^
122122
123- The :py:func: `~spikeinterface.curation.get_potential_auto_merge ` function returns a list of potential merges.
123+ The :py:func: `~spikeinterface.curation.compute_merge_unit_groups ` function returns a list of potential merges.
124124The list of potential merges can be then applied to the sorting output.
125- :py:func: `~spikeinterface.curation.get_potential_auto_merge ` has many internal tricks and steps to identify potential
125+ :py:func: `~spikeinterface.curation.compute_merge_unit_groups ` has many internal tricks and steps to identify potential
126126merges. It offers multiple "presets" and the flexibility to apply individual steps, with different parameters.
127127**Read the function documentation carefully and do not apply it blindly! **
128128
129129
130130.. code-block :: python
131131
132132 from spikeinterface import create_sorting_analyzer
133- from spikeinterface.curation import get_potential_auto_merge
133+ from spikeinterface.curation import compute_merge_unit_groups
134134
135135 analyzer = create_sorting_analyzer(sorting = sorting, recording = recording)
136136
137137 # some extensions are required
138138 analyzer.compute([" random_spikes" , " templates" , " template_similarity" , " correlograms" ])
139139
140140 # merges is a list of unit pairs, with unit_ids to be merged.
141- merge_unit_pairs = get_potential_auto_merge (
141+ merge_unit_pairs = compute_merge_unit_groups (
142142 analyzer = analyzer,
143143 preset = " similarity_correlograms" ,
144144 )
145145 # with resolve_graph=True, merges_resolved is a list of merge groups,
146146 # which can contain more than two units
147- merge_unit_groups = get_potential_auto_merge (
147+ merge_unit_groups = compute_merge_unit_groups (
148148 analyzer = analyzer,
149149 preset = " similarity_correlograms" ,
150150 resolve_graph = True
@@ -153,6 +153,44 @@ merges. It offers multiple "presets" and the flexibility to apply individual ste
153153 # here we apply the merges
154154 analyzer_merged = analyzer.merge_units(merge_unit_groups = merge_unit_groups)
155155
156+ There is also the convenient :py:func: `~spikeinterface.curation.auto_merge_units ` function that combines the
157+ :py:func: `~spikeinterface.curation.compute_merge_unit_groups ` and :py:func: `~spikeinterface.core.SortingAnalyzer.merge_units ` functions.
158+ This is a high level function that allows you to apply either one or several presets/lists of steps in one go. For example, let's
159+ assume you want to apply the "x_contamination" preset, but iteratively and with slightly different parameters: first,
160+ you want to focus on the templates that are very similar, according to their template similarities, before
161+ considering those that might be more distant. Such a greedy and iterative scheme has been proved to be less
162+ prone to wrong merges. To do so, you'll need to do the following:
163+
164+ .. code-block :: python
165+
166+ from spikeinterface import create_sorting_analyzer
167+ from spikeinterface.curation import auto_merge_units
168+
169+ analyzer = create_sorting_analyzer(sorting = sorting, recording = recording)
170+
171+ # some extensions are required
172+ analyzer.compute([" random_spikes" , " templates" , " template_similarity" , " correlograms" ])
173+ analyzer.compute(" unit_locations" , method = " monopolar_triangulation" )
174+
175+ template_diff_thresh = [0.05 , 0.15 , 0.25 ]
176+ presets = [" x_contaminations" ] * len (template_diff_thresh)
177+ steps_params = [
178+ {" template_similarity" : {" template_diff_thresh" : i}}
179+ for i in template_diff_thresh
180+ ]
181+
182+ analyzer_merged = auto_merge_units(
183+ analyzer,
184+ presets = presets,
185+ steps_params = steps_params,
186+ recursive = True ,
187+ ** job_kwargs,
188+ )
189+
190+ The extra keyword ``recursive `` specifies that for each presets/sequences of steps, merges are performed
191+ until no further merges are possible. The ``job_kwargs `` are the parameters for the parallelization.
192+ **Be careful that the merges can not be reverted, so be sure to not erase your analyzer and create a new variable **
193+
156194
157195Manual curation
158196---------------
0 commit comments