Skip to content

Commit c16fda2

Browse files
committed
Handle case where pc_features does not exist
1 parent cdce624 commit c16fda2

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

element_array_ephys/ephys_acute.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,8 @@ def make(self, key):
533533
# -- Spike-sites and Spike-depths --
534534
spike_sites = np.array([channel2electrodes[s]['electrode']
535535
for s in kilosort_dataset.data['spike_sites']])
536-
spike_depths = kilosort_dataset.data['spike_depths']
536+
spike_depths = kilosort_dataset.data['spike_depths'] \
537+
if 'pc_features' in kilosort_dataset.data else None
537538

538539
# -- Insert unit, label, peak-chn
539540
units = []
@@ -551,7 +552,7 @@ def make(self, key):
551552
'spike_times': unit_spike_times,
552553
'spike_count': spike_count,
553554
'spike_sites': spike_sites[kilosort_dataset.data['spike_clusters'] == unit],
554-
'spike_depths': spike_depths[kilosort_dataset.data['spike_clusters'] == unit]})
555+
'spike_depths': spike_depths[kilosort_dataset.data['spike_clusters'] == unit] if spike_depths else None})
555556

556557
self.insert1(key)
557558
self.Unit.insert([{**key, **u} for u in units])

element_array_ephys/ephys_chronic.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,8 @@ def make(self, key):
532532
# -- Spike-sites and Spike-depths --
533533
spike_sites = np.array([channel2electrodes[s]['electrode']
534534
for s in kilosort_dataset.data['spike_sites']])
535-
spike_depths = kilosort_dataset.data['spike_depths']
535+
spike_depths = kilosort_dataset.data['spike_depths'] \
536+
if 'pc_features' in kilosort_dataset.data else None
536537

537538
# -- Insert unit, label, peak-chn
538539
units = []
@@ -550,7 +551,7 @@ def make(self, key):
550551
'spike_times': unit_spike_times,
551552
'spike_count': spike_count,
552553
'spike_sites': spike_sites[kilosort_dataset.data['spike_clusters'] == unit],
553-
'spike_depths': spike_depths[kilosort_dataset.data['spike_clusters'] == unit]})
554+
'spike_depths': spike_depths[kilosort_dataset.data['spike_clusters'] == unit] if spike_depths else None})
554555

555556
self.insert1(key)
556557
self.Unit.insert([{**key, **u} for u in units])

0 commit comments

Comments
 (0)