From d520b28bd0fb6db24cf7a2baf21c46dd15f29950 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 25 Jun 2024 08:49:13 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/spikeinterface/core/sorting_tools.py | 3 ++- src/spikeinterface/core/sortinganalyzer.py | 1 + src/spikeinterface/curation/curation_tools.py | 5 +++-- src/spikeinterface/curation/mergeunitssorting.py | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/spikeinterface/core/sorting_tools.py b/src/spikeinterface/core/sorting_tools.py index 55b6cf44b7..ba67bda66e 100644 --- a/src/spikeinterface/core/sorting_tools.py +++ b/src/spikeinterface/core/sorting_tools.py @@ -225,7 +225,7 @@ def random_spikes_selection( def get_ids_after_merging(sorting, units_to_merge, new_unit_ids): assert len(new_unit_ids) == len(units_to_merge), "new_unit_ids should have the same len as units_to_merge" - + merged_unit_ids = set(sorting.unit_ids) for count in range(len(units_to_merge)): assert len(units_to_merge[count]) > 1, "A merge should have at least two units" @@ -269,6 +269,7 @@ def apply_merges_to_sorting(sorting, units_to_merge, new_unit_ids=None, censor_m to_keep = np.ones(len(spikes), dtype=bool) from spikeinterface.curation.curation_tools import get_new_unit_ids_for_merges + new_unit_ids = get_new_unit_ids_for_merges(sorting, units_to_merge, new_unit_ids) all_unit_ids = get_ids_after_merging(sorting, units_to_merge, new_unit_ids) diff --git a/src/spikeinterface/core/sortinganalyzer.py b/src/spikeinterface/core/sortinganalyzer.py index 6f6a413c83..3d11d3f89e 100644 --- a/src/spikeinterface/core/sortinganalyzer.py +++ b/src/spikeinterface/core/sortinganalyzer.py @@ -856,6 +856,7 @@ def merge_units( assert merging_mode in ["soft", "hard"], "Merging mode should be either soft or hard" from spikeinterface.curation.curation_tools import get_new_unit_ids_for_merges + new_unit_ids = get_new_unit_ids_for_merges(self.sorting, units_to_merge, new_unit_ids) if not isinstance(units_to_merge[0], (list, tuple)): diff --git a/src/spikeinterface/curation/curation_tools.py b/src/spikeinterface/curation/curation_tools.py index 106e238388..1716dcbf26 100644 --- a/src/spikeinterface/curation/curation_tools.py +++ b/src/spikeinterface/curation/curation_tools.py @@ -134,6 +134,7 @@ def find_duplicated_spikes( else: raise ValueError(f"Method '{method}' isn't a valid method for find_duplicated_spikes. Use one of {_methods}") + def get_new_unit_ids_for_merges(sorting, units_to_merge, new_unit_ids): all_removed_ids = [] @@ -166,5 +167,5 @@ def get_new_unit_ids_for_merges(sorting, units_to_merge, new_unit_ids): else: # dtype int new_unit_ids = list(max(sorting.unit_ids) + 1 + np.arange(num_merge, dtype=dtype)) - - return new_unit_ids \ No newline at end of file + + return new_unit_ids diff --git a/src/spikeinterface/curation/mergeunitssorting.py b/src/spikeinterface/curation/mergeunitssorting.py index 98d9652b2f..c51ffcef2d 100644 --- a/src/spikeinterface/curation/mergeunitssorting.py +++ b/src/spikeinterface/curation/mergeunitssorting.py @@ -50,8 +50,8 @@ def __init__(self, sorting, units_to_merge, new_unit_ids=None, properties_policy keep_unit_ids = [u for u in parents_unit_ids if u not in all_removed_ids] from .curation_tools import get_new_unit_ids_for_merges - new_unit_ids = get_new_unit_ids_for_merges(sorting, units_to_merge, new_unit_ids) + new_unit_ids = get_new_unit_ids_for_merges(sorting, units_to_merge, new_unit_ids) assert len(new_unit_ids) == num_merge, "new_unit_ids must have the same size as units_to_merge"