Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change phy exporter to not save template_ind in the case of dense waveform_extractor #2148

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/spikeinterface/exporters/to_phy.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,16 @@ def export_to_phy(
"argument to enforce sparsity (see compute_sparsity())"
)

save_sparse = True
if waveform_extractor.is_sparse():
used_sparsity = waveform_extractor.sparsity
assert sparsity is None
if sparsity is not None:
warnings.warn("If the waveform_extractor is sparse the 'sparsity' argument is ignored")
Copy link
Member

Choose a reason for hiding this comment

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

Great idea!

elif sparsity is not None:
used_sparsity = sparsity
else:
used_sparsity = ChannelSparsity.create_dense(waveform_extractor)
save_sparse = False
# convenient sparsity dict for the 3 cases to retrieve channl_inds
sparse_dict = used_sparsity.unit_id_to_channel_indices

Expand Down Expand Up @@ -200,7 +203,8 @@ def export_to_phy(
template_similarity = compute_template_similarity(waveform_extractor, method="cosine_similarity")

np.save(str(output_folder / "templates.npy"), templates)
np.save(str(output_folder / "template_ind.npy"), templates_ind)
if save_sparse:
np.save(str(output_folder / "template_ind.npy"), templates_ind)
np.save(str(output_folder / "similar_templates.npy"), template_similarity)

channel_maps = np.arange(num_chans, dtype="int32")
Expand Down