Hide diagonal in similarity plot
@@ -17,6 +17,9 @@ class TemplateSimilarityWidget(BaseWidget):
The object to compute/get template similarity from
unit_ids : list
List of unit ids.
+ display_diagonal_values : bool
+ If False, the diagonal is displayed as zeros.
+ If True, the similarity values (all 1s) are displayed. Default False
cmap : Matplotlib colormap
The matplotlib colormap. Default 'viridis'. (matplotlib backend)
show_unit_ticks : bool
@@ -27,7 +30,7 @@ class TemplateSimilarityWidget(BaseWidget):
possible_backends = {}
def __init__(self, waveform_extractor: WaveformExtractor,
- unit_ids=None, cmap='viridis',
+ unit_ids=None, cmap='viridis', display_diagonal_values=False,
show_unit_ticks=False, show_colorbar=True,
backend=None, **backend_kwargs):
self.check_extensions(waveform_extractor, "similarity")
@@ -41,6 +44,9 @@ class TemplateSimilarityWidget(BaseWidget):
unit_indices = sorting.ids_to_indices(unit_ids)
similarity = similarity[unit_indices][:, unit_indices]
+ if not display_diagonal_values:
+ np.fill_diagonal(similarity, 0)
+
plot_data = dict(
similarity=similarity,
unit_ids=unit_ids,
