Skip to content

Commit

Permalink
Merge pull request #3417 from alejoe91/fixes-convert-dtypes
Browse files Browse the repository at this point in the history
Fix metrics widgets for convert_dtypes
  • Loading branch information
alejoe91 authored Sep 16, 2024
2 parents 83bad08 + 9834996 commit 8a1870c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/spikeinterface/widgets/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ def plot_sortingview(self, data_plot, **backend_kwargs):
values = check_json(metrics.loc[unit_id].to_dict())
values_skip_nans = {}
for k, v in values.items():
# convert_dypes returns NaN as None or np.nan (for float)
if v is None:
continue
if np.isnan(v):
continue
values_skip_nans[k] = v
Expand Down
2 changes: 1 addition & 1 deletion src/spikeinterface/widgets/tests/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def setUpClass(cls):
spike_amplitudes=dict(),
unit_locations=dict(),
spike_locations=dict(),
quality_metrics=dict(metric_names=["snr", "isi_violation", "num_spikes"]),
quality_metrics=dict(metric_names=["snr", "isi_violation", "num_spikes", "amplitude_cutoff"]),
template_metrics=dict(),
correlograms=dict(),
template_similarity=dict(),
Expand Down
8 changes: 4 additions & 4 deletions src/spikeinterface/widgets/utils_sortingview.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ def generate_unit_table_view(
if prop_name in sorting_props:
property_values = sorting.get_property(prop_name)
elif prop_name in qm_props:
property_values = qm_data[prop_name].values
property_values = qm_data[prop_name].to_numpy()
elif prop_name in tm_props:
property_values = tm_data[prop_name].values
property_values = tm_data[prop_name].to_numpy()
else:
warn(f"Property '{prop_name}' not found in sorting, quality_metrics, or template_metrics")
continue
Expand Down Expand Up @@ -137,9 +137,9 @@ def generate_unit_table_view(
if prop_name in sorting_props:
property_values = sorting.get_property(prop_name)
elif prop_name in qm_props:
property_values = qm_data[prop_name].values
property_values = qm_data[prop_name].to_numpy()
elif prop_name in tm_props:
property_values = tm_data[prop_name].values
property_values = tm_data[prop_name].to_numpy()

# Check for NaN values and round floats
val0 = np.array(property_values[0])
Expand Down

0 comments on commit 8a1870c

Please sign in to comment.