From dcb0a51bd06059fc4616c819007d7b1d23c44e53 Mon Sep 17 00:00:00 2001 From: Alessio Buccino Date: Thu, 10 Sep 2026 17:16:35 +0200 Subject: [PATCH] fix: sortingview/figpack templates - transpose and float32 --- src/spikeinterface/widgets/unit_templates.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/spikeinterface/widgets/unit_templates.py b/src/spikeinterface/widgets/unit_templates.py index c849a43883..30c39c72ef 100644 --- a/src/spikeinterface/widgets/unit_templates.py +++ b/src/spikeinterface/widgets/unit_templates.py @@ -1,4 +1,5 @@ from spikeinterface.core import SortingAnalyzer + from .unit_waveforms import UnitWaveformsWidget from .base import to_attr @@ -40,12 +41,17 @@ def plot_figpack(self, data_plot, **backend_kwargs): templates_dict = {} for u_i, unit in enumerate(unit_ids): templates_dict[unit] = {} - template_data = dp.templates[u_i] - templates_dict[unit]["mean"] = template_data[:, unit_id_to_channel_indices[unit]] + template_data = dp.templates[u_i][:, unit_id_to_channel_indices[unit]].astype("float32") + if use_sortingview: + template_data = template_data.T + templates_dict[unit]["mean"] = template_data if dp.do_shading: templates_dict[unit]["shading"] = [] for shading_data in dp.templates_shading: - templates_dict[unit]["shading"].append(shading_data[u_i][:, unit_id_to_channel_indices[unit]]) + shading_data_unit = shading_data[u_i][:, unit_id_to_channel_indices[unit]].astype("float32") + if use_sortingview: + shading_data_unit = shading_data_unit.T + templates_dict[unit]["shading"].append(shading_data_unit) else: templates_dict[unit]["shading"] = None @@ -59,7 +65,9 @@ def plot_figpack(self, data_plot, **backend_kwargs): for u, t in templates_dict.items() ] - channel_locations = {str(ch): dp.channel_locations[i_ch].astype(float) for i_ch, ch in enumerate(channel_ids)} + channel_locations = { + str(ch): dp.channel_locations[i_ch].astype("float32") for i_ch, ch in enumerate(channel_ids) + } v_average_waveforms = vv_views.AverageWaveforms(average_waveforms=aw_items, channel_locations=channel_locations) if not dp.hide_unit_selector: