Skip to content

Commit

Permalink
Merge pull request #2718 from catalystneuro/add_templates_repr
Browse files Browse the repository at this point in the history
Add basic repr to `Templates` object
  • Loading branch information
alejoe91 authored Apr 14, 2024
2 parents 482bd74 + efde882 commit 6bb7360
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/spikeinterface/core/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,23 @@ def __post_init__(self):
if not self._are_passed_templates_sparse():
raise ValueError("Sparsity mask passed but the templates are not sparse")

def __repr__(self):
sampling_frequency_khz = self.sampling_frequency / 1000
repr_str = (
f"Templates: {self.num_units} units - {self.num_samples} samples - {self.num_channels} channels \n"
f"sampling_frequency={sampling_frequency_khz:.2f} kHz - "
f"ms_before={self.ms_before:.2f} ms - "
f"ms_after={self.ms_after:.2f} ms"
)

if self.probe is not None:
repr_str += f"\n{self.probe.__repr__()}"

if self.sparsity is not None:
repr_str += f"\n{self.sparsity.__repr__()}"

return repr_str

def to_sparse(self, sparsity):
# Turn a dense representation of templates into a sparse one, given some sparsity.
# Note that nothing prevent Templates tobe empty after sparsification if the sparse mask have no channels for some units
Expand Down

0 comments on commit 6bb7360

Please sign in to comment.