From e8b4fe12e1674bd4e3d95734b33a94cd011a0fef Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 17 Jan 2025 16:00:59 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/spikeinterface/widgets/sorting_summary.py | 11 +++++------ src/spikeinterface/widgets/utils.py | 10 ++++++---- src/spikeinterface/widgets/utils_sortingview.py | 5 ++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/spikeinterface/widgets/sorting_summary.py b/src/spikeinterface/widgets/sorting_summary.py index 76d418b64d..2271e5a4cb 100644 --- a/src/spikeinterface/widgets/sorting_summary.py +++ b/src/spikeinterface/widgets/sorting_summary.py @@ -18,6 +18,7 @@ _default_displayed_unit_properties = ["firing_rate", "num_spikes", "x", "y", "amplitude", "snr", "rp_violation"] + class SortingSummaryWidget(BaseWidget): """ Plots spike sorting summary. @@ -65,6 +66,7 @@ class SortingSummaryWidget(BaseWidget): This replaces the label_choices in the curation_format. (spikeinterface_gui backend) """ + def __init__( self, sorting_analyzer: SortingAnalyzer, @@ -82,16 +84,15 @@ def __init__( unit_table_properties=None, **backend_kwargs, ): - + if unit_table_properties is not None: warnings.warn( "plot_sorting_summary() : unit_table_properties is deprecated, use displayed_unit_properties instead", category=DeprecationWarning, stacklevel=2, - ) + ) displayed_unit_properties = unit_table_properties - sorting_analyzer = self.ensure_sorting_analyzer(sorting_analyzer) self.check_extensions( sorting_analyzer, ["correlograms", "spike_amplitudes", "unit_locations", "template_similarity"] @@ -108,7 +109,7 @@ def __init__( displayed_unit_properties = list(_default_displayed_unit_properties) if extra_unit_properties is not None: displayed_unit_properties += list(extra_unit_properties.keys()) - + data_plot = dict( sorting_analyzer=sorting_analyzer, unit_ids=unit_ids, @@ -230,7 +231,6 @@ def plot_spikeinterface_gui(self, data_plot, **backend_kwargs): from spikeinterface_gui import run_mainwindow - run_mainwindow( sorting_analyzer, with_traces=True, @@ -240,4 +240,3 @@ def plot_spikeinterface_gui(self, data_plot, **backend_kwargs): extra_unit_properties=data_plot["extra_unit_properties"], displayed_unit_properties=data_plot["displayed_unit_properties"], ) - diff --git a/src/spikeinterface/widgets/utils.py b/src/spikeinterface/widgets/utils.py index 89025dea31..7d5cf98c01 100644 --- a/src/spikeinterface/widgets/utils.py +++ b/src/spikeinterface/widgets/utils.py @@ -245,7 +245,6 @@ def array_to_image( return output_image - def make_units_table_from_sorting(sorting, units_table=None): """ Make a DataFrame from sorting properties. @@ -266,6 +265,7 @@ def make_units_table_from_sorting(sorting, units_table=None): if units_table is None: import pandas as pd + units_table = pd.DataFrame(index=sorting.unit_ids) for col in sorting.get_property_keys(): @@ -275,10 +275,11 @@ def make_units_table_from_sorting(sorting, units_table=None): return units_table + def make_units_table_from_analyzer( - analyzer, - extra_properties=None, - ): + analyzer, + extra_properties=None, +): """ Make a DataFrame by aggregating : * quality metrics @@ -302,6 +303,7 @@ def make_units_table_from_analyzer( Table containing all columns. """ import pandas as pd + all_df = [] if analyzer.get_extension("unit_locations") is not None: diff --git a/src/spikeinterface/widgets/utils_sortingview.py b/src/spikeinterface/widgets/utils_sortingview.py index 2a7a8d5ec4..451b1d145e 100644 --- a/src/spikeinterface/widgets/utils_sortingview.py +++ b/src/spikeinterface/widgets/utils_sortingview.py @@ -9,7 +9,6 @@ from .utils import make_units_table_from_sorting, make_units_table_from_analyzer - def make_serializable(*args): dict_to_serialize = {int(i): a for i, a in enumerate(args)} serializable_dict = check_json(dict_to_serialize) @@ -65,7 +64,7 @@ def generate_unit_table_view( sorting = sorting_or_sorting_analyzer units_tables = make_units_table_from_sorting(sorting) # analyzer = None - + if unit_properties is None: ut_columns = [] ut_rows = [vv.UnitsTableRow(unit_id=u, values={}) for u in sorting.unit_ids] @@ -105,5 +104,5 @@ def generate_unit_table_view( ut_rows.append(vv.UnitsTableRow(unit_id=unit_id, values=check_json(row_values))) v_units_table = vv.UnitsTable(rows=ut_rows, columns=ut_columns, similarity_scores=similarity_scores) - + return v_units_table