Skip to content

Commit 76dfc94

Browse files
committed
fix: minor bug in spikes ingestion
1 parent 3fcf542 commit 76dfc94

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

element_array_ephys/ephys_no_curation.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,8 +1048,8 @@ def make(self, key):
10481048
si.ChannelSparsity.from_best_channels(
10491049
sorting_analyzer, 1, peak_sign="neg"
10501050
).unit_id_to_channel_indices
1051-
) # {unit: peak_channel_index}
1052-
unit_peak_channel = {u: chn[0] for u, chn in unit_peak_channel.items()}
1051+
)
1052+
unit_peak_channel: dict[int, int] = {u: chn[0] for u, chn in unit_peak_channel.items()}
10531053

10541054
spike_count_dict: dict[int, int] = si_sorting.count_num_spikes_per_unit()
10551055
# {unit: spike_count}
@@ -1076,9 +1076,9 @@ def make(self, key):
10761076
spikes_df = pd.DataFrame(spike_locations.spikes)
10771077

10781078
units = []
1079-
for unit_id in si_sorting.unit_ids:
1079+
for unit_idx, unit_id in enumerate(si_sorting.unit_ids):
10801080
unit_id = int(unit_id)
1081-
unit_spikes_df = spikes_df[spikes_df.unit_index == unit_id]
1081+
unit_spikes_df = spikes_df[spikes_df.unit_index == unit_idx]
10821082
spike_sites = np.array(
10831083
[
10841084
channel2electrode_map[chn_idx]["electrode"]
@@ -1087,16 +1087,17 @@ def make(self, key):
10871087
)
10881088
unit_spikes_loc = spike_locations.get_data()[unit_spikes_df.index]
10891089
_, spike_depths = zip(*unit_spikes_loc) # x-coordinates, y-coordinates
1090+
spike_times = si_sorting.get_unit_spike_train(unit_id, return_times=True)
1091+
1092+
assert len(spike_times) == len(spike_sites) == len(spike_depths)
10901093

10911094
units.append(
10921095
{
10931096
**key,
10941097
**channel2electrode_map[unit_peak_channel[unit_id]],
10951098
"unit": unit_id,
10961099
"cluster_quality_label": cluster_quality_label_map[unit_id],
1097-
"spike_times": si_sorting.get_unit_spike_train(
1098-
unit_id, return_times=True
1099-
),
1100+
"spike_times": spike_times,
11001101
"spike_count": spike_count_dict[unit_id],
11011102
"spike_sites": spike_sites,
11021103
"spike_depths": spike_depths,

0 commit comments

Comments
 (0)