Skip to content

Commit

Permalink
Add warning and ability to pass synchrony_sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
chrishalcrow committed Dec 2, 2024
1 parent 5af4f85 commit 45eb5b7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/spikeinterface/qualitymetrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
get_default_qm_params,
)
from .pca_metrics import get_quality_pca_metric_list
from .misc_metrics import get_synchrony_counts
from .misc_metrics import _get_synchrony_counts
6 changes: 5 additions & 1 deletion src/spikeinterface/qualitymetrics/misc_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ def _get_synchrony_counts(spikes, all_unit_ids, synchrony_sizes=np.array([2, 4,
return synchrony_counts


def compute_synchrony_metrics(sorting_analyzer, unit_ids=None):
def compute_synchrony_metrics(sorting_analyzer, unit_ids=None, synchrony_sizes=None):
"""
Compute synchrony metrics. Synchrony metrics represent the rate of occurrences of
spikes at the exact same sample index, with synchrony sizes 2, 4 and 8.
Expand All @@ -588,6 +588,10 @@ def compute_synchrony_metrics(sorting_analyzer, unit_ids=None):
This code was adapted from `Elephant - Electrophysiology Analysis Toolkit <https://github.com/NeuralEnsemble/elephant/blob/master/elephant/spike_train_synchrony.py#L245>`_
"""

if synchrony_sizes is not None:
warning_message = "Custom `synchrony_sizes` is deprecated; the `synchrony_metrics` will be computed using `synchrony_sizes = [2,4,8]`"
warnings.warn(warning_message)

synchrony_sizes = np.array([2, 4, 8])

res = namedtuple("synchrony_metrics", [f"sync_spike_{size}" for size in synchrony_sizes])
Expand Down

0 comments on commit 45eb5b7

Please sign in to comment.