Skip to content

Commit

Permalink
Force CellExplorer unit ids as int
Browse files Browse the repository at this point in the history
  • Loading branch information
alejoe91 committed Oct 2, 2023
1 parent 8343d3a commit 89d1f82
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/spikeinterface/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ def __init__(self, main_ids: Sequence) -> None:
# They is used for properties
self._main_ids = np.array(main_ids)
if len(self._main_ids) > 0:
assert self._main_ids.dtype.kind in "uiSU", "Main IDs can only be integers (signed/unsigned) or strings"
assert (
self._main_ids.dtype.kind in "uiSU"
), f"Main IDs can only be integers (signed/unsigned) or strings, not {self._main_ids.dtype}"

# dict at object level
self._annotations = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def __init__(
spike_times = spikes_data["times"]

# CellExplorer reports spike times in units seconds; SpikeExtractors uses time units of sampling frames
unit_ids = unit_ids[:].tolist()
unit_ids = unit_ids[:].astype(int).tolist()
spiketrains_dict = {unit_id: spike_times[index] for index, unit_id in enumerate(unit_ids)}
for unit_id in unit_ids:
spiketrains_dict[unit_id] = (sampling_frequency * spiketrains_dict[unit_id]).round().astype(np.int64)
Expand Down

0 comments on commit 89d1f82

Please sign in to comment.