Skip to content

Commit 31bba8c

Browse files
committed
bugfix in assigning unit electrode indices
1 parent 19616ef commit 31bba8c

File tree

1 file changed

+4
-1
lines changed
  • element_array_ephys/export

1 file changed

+4
-1
lines changed

element_array_ephys/export/nwb.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ def curated_clusterings_to_nwb(curated_clustering_keys, nwbfile):
8585
location=electrode_group.location)
8686

8787
# ---- Units ----
88+
electrode_df = nwbfile.electrodes.to_dataframe()
89+
electrode_ind = electrode_df.index[electrode_df.group_name == electrode_group.name]
90+
8891
unit_query = clustering_query @ ephys.CuratedClustering.Unit
8992
for unit in unit_query.fetch(as_dict=True):
9093
if ephys.WaveformSet & curated_clustering_key & {'unit': unit['unit']}:
@@ -99,7 +102,7 @@ def curated_clusterings_to_nwb(curated_clustering_keys, nwbfile):
99102
waveform_mean = waveform_std = np.full(1, np.nan)
100103

101104
nwbfile.add_unit(id=unit['unit'],
102-
electrodes=np.where(nwbfile.electrodes.id.data == int(unit['electrode']))[0],
105+
electrodes=np.where(electrode_ind == unit['electrode'])[0],
103106
electrode_group=electrode_group,
104107
sampling_rate=unit['sampling_rate'],
105108
cluster_quality_label=unit['cluster_quality_label'],

0 commit comments

Comments
 (0)