Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Aug 13, 2024
1 parent 4183451 commit 1335ecf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/spikeinterface/widgets/sorting_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ class SortingSummaryWidget(BaseWidget):
List of labels to be added to the curation table
(sortingview backend)
unit_table_properties : list or None, default: None
List of properties to be added to the unit table.
These may be drawn from the sorting extractor, and, if available,
List of properties to be added to the unit table.
These may be drawn from the sorting extractor, and, if available,
the quality_metrics and template_metrics extensions of the SortingAnalyzer.
See all properties available with sorting.get_property_keys(), and, if available,
analyzer.get_extension("quality_metrics").get_data().columns and
analyzer.get_extension("quality_metrics").get_data().columns and
analyzer.get_extension("template_metrics").get_data().columns.
(sortingview backend)
"""
Expand Down
16 changes: 11 additions & 5 deletions src/spikeinterface/widgets/utils_sortingview.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from ..core.core_tools import check_json
from warnings import warn


def make_serializable(*args):
dict_to_serialize = {int(i): a for i, a in enumerate(args)}
serializable_dict = check_json(dict_to_serialize)
Expand Down Expand Up @@ -47,8 +48,9 @@ def handle_display_and_url(widget, view, **backend_kwargs):

def generate_unit_table_view(analyzer, unit_properties=None, similarity_scores=None):
import sortingview.views as vv

sorting = analyzer.sorting

# Find available unit properties from all sources
sorting_props = sorting.get_property_keys()
if analyzer.get_extension("quality_metrics") is not None:
Expand All @@ -66,7 +68,9 @@ def generate_unit_table_view(analyzer, unit_properties=None, similarity_scores=N
all_props = sorting_props + qm_props + tm_props
overlap_props = [prop for prop in all_props if all_props.count(prop) > 1]
if len(overlap_props) > 0:
warn(f"Warning: Overlapping properties found in sorting, quality_metrics, and template_metrics: {overlap_props}")
warn(
f"Warning: Overlapping properties found in sorting, quality_metrics, and template_metrics: {overlap_props}"
)

# Get unit properties
if unit_properties is None:
Expand All @@ -92,7 +96,7 @@ def generate_unit_table_view(analyzer, unit_properties=None, similarity_scores=N
property_values = tm_data[prop_name].values
else:
raise ValueError(f"Property '{prop_name}' not found in sorting, quality_metrics, or template_metrics")

# make dtype available
val0 = np.array(property_values[0])
if val0.dtype.kind in ("i", "u"):
Expand Down Expand Up @@ -121,8 +125,10 @@ def generate_unit_table_view(analyzer, unit_properties=None, similarity_scores=N
elif prop_name in tm_props:
property_values = tm_data[prop_name].values
else:
raise ValueError(f"Property '{prop_name}' not found in sorting, quality_metrics, or template_metrics")

raise ValueError(
f"Property '{prop_name}' not found in sorting, quality_metrics, or template_metrics"
)

# Check for NaN values
val0 = np.array(property_values[0])
if val0.dtype.kind == "f":
Expand Down

0 comments on commit 1335ecf

Please sign in to comment.