Skip to content

Commit 3452ab7

Browse files
author
Thinh Nguyen
committed
bugfix in waveform ingestion
1 parent 3784238 commit 3452ab7

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

elements_ephys/ephys.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,6 @@ def key_source(self):
440440
return Clustering()
441441

442442
def make(self, key):
443-
units = {u['unit']: u for u in (Clustering.Unit & key).fetch(as_dict=True, order_by='unit')}
444-
445443
root_dir = pathlib.Path(get_ephys_root_data_dir())
446444
ks_dir = root_dir / (ClusteringTask & key).fetch1('clustering_output_dir')
447445
ks = kilosort.Kilosort(ks_dir)
@@ -454,6 +452,9 @@ def make(self, key):
454452

455453
is_qc = (Clustering & key).fetch1('quality_control')
456454

455+
# Get all units
456+
units = {u['unit']: u for u in (Clustering.Unit & key).fetch(as_dict=True, order_by='unit')}
457+
457458
unit_waveforms, unit_peak_waveforms = [], []
458459
if is_qc:
459460
unit_wfs = np.load(ks_dir / 'mean_waveforms.npy') # unit x channel x sample
@@ -473,8 +474,8 @@ def make(self, key):
473474
loaded_oe = openephys.OpenEphys(sess_dir)
474475
npx_recording = loaded_oe.probes[probe_sn]
475476

476-
for unit_no, unit_dict in units.items():
477-
spks = (Clustering.Unit & unit_dict).fetch1('unit_spike_times')
477+
for unit_dict in units.values():
478+
spks = unit_dict['spike_times']
478479
wfs = npx_recording.extract_spike_waveforms(spks, ks.data['channel_map']) # (sample x channel x spike)
479480
wfs = wfs.transpose((1, 2, 0)) # (channel x spike x sample)
480481
for chn, chn_wf in zip(ks.data['channel_map'], wfs):

0 commit comments

Comments
 (0)