Skip to content

Commit f9a4754

Browse files
author
Thinh Nguyen
authored
Merge pull request #3 from ttngu207/nwb-export
bugfix in assigning unit electrode indices
2 parents aa47c8a + 31bba8c commit f9a4754

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
@@ -98,6 +98,9 @@ def curated_clusterings_to_nwb(curated_clustering_keys, nwbfile, ephys_module=No
9898
location=electrode_group.location)
9999

100100
# ---- Units ----
101+
electrode_df = nwbfile.electrodes.to_dataframe()
102+
electrode_ind = electrode_df.index[electrode_df.group_name == electrode_group.name]
103+
101104
unit_query = clustering_query @ ephys.CuratedClustering.Unit
102105
for unit in unit_query.fetch(as_dict=True):
103106
waveform_mean = waveform_std = np.full(1, np.nan)
@@ -113,7 +116,7 @@ def curated_clusterings_to_nwb(curated_clustering_keys, nwbfile, ephys_module=No
113116
waveform_std = np.std(electrode_waveforms, axis=0)
114117

115118
nwbfile.add_unit(id=unit['unit'],
116-
electrodes=np.where(nwbfile.electrodes.id.data == int(unit['electrode']))[0],
119+
electrodes=np.where(electrode_ind == unit['electrode'])[0],
117120
electrode_group=electrode_group,
118121
sampling_rate=unit['sampling_rate'],
119122
cluster_quality_label=unit['cluster_quality_label'],

0 commit comments

Comments
 (0)