Skip to content

Conversation

@yger
Copy link
Collaborator

@yger yger commented Nov 12, 2025

While restructuring the components, we introduced a slowdown in template_similarity, by mistake. I don't think this causes bug, but rather a global problem with speed since we are computing distances for all templates, instead of only those that are intersecting.

@samuelgarcia
Copy link
Member

In addition, in this PR, I make use of the new sparsity mask in the extension, while computing Templates

I think we should not do this in the same PR. The internal sparse representaion of template will have impact at many places, like merging or plotting. Lets do this more carfully.

@yger
Copy link
Collaborator Author

yger commented Nov 13, 2025

You are right regaring the sparsity masks. This has been moved in #4212

@yger yger changed the title Speedup similarity Speedup template_similarity Nov 13, 2025
@yger
Copy link
Collaborator Author

yger commented Nov 13, 2025

@samuelgarcia this one is needed for runtimes of both SC2, TDC2, and very large in vitro recordings

@yger yger added bug Something isn't working sortingcomponents Related to sortingcomponents module postprocessing Related to postprocessing module labels Nov 13, 2025
Comment on lines +119 to +122
for old_ind1, unit_ind1 in zip(old_units_inds, sub_units_inds):
s = self.data["similarity"][old_ind1, old_units_inds]
similarity[unit_ind1, sub_units_inds] = s
similarity[sub_units_inds, unit_ind1] = s
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. Smater

Comment on lines +322 to +329
connected_mask = np.logical_and(sparsity_mask[i, :], other_sparsity_mask)
not_connected_mask = np.sum(connected_mask, axis=1) == 0
local_mask = np.logical_or(
sparsity_mask[i, :], other_sparsity_mask
) # shape (other_num_templates, num_channels)
for local_i in np.flatnonzero(not_connected_mask):
local_mask[local_i] = False

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course!

@samuelgarcia
Copy link
Member

Merci pour le bug!

@samuelgarcia
Copy link
Member

I merge this, this is important.

@samuelgarcia samuelgarcia merged commit 4417d32 into SpikeInterface:main Nov 14, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working postprocessing Related to postprocessing module sortingcomponents Related to sortingcomponents module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants