@@ -1096,7 +1096,7 @@ def make(self, key):
1096
1096
}
1097
1097
)
1098
1098
1099
- else :
1099
+ else : # read from kilosort outputs
1100
1100
kilosort_dataset = kilosort .Kilosort (output_dir )
1101
1101
acq_software , sample_rate = (EphysRecording & key ).fetch1 (
1102
1102
"acq_software" , "sampling_rate"
@@ -1131,14 +1131,19 @@ def make(self, key):
1131
1131
kilosort_dataset .extract_spike_depths ()
1132
1132
1133
1133
# Get channel and electrode-site mapping
1134
- channel2electrodes = get_neuropixels_channel2electrode_map (
1135
- key , acq_software
1134
+ channel_info = (
1135
+ (EphysRecording .Channel & key )
1136
+ .proj (..., "-channel_name" )
1137
+ .fetch (as_dict = True , order_by = "channel_idx" )
1136
1138
)
1139
+ channel_info : dict [int , dict ] = {
1140
+ ch .pop ("channel_idx" ): ch for ch in channel_info
1141
+ } # e.g., {0: {'subject': 'sglx', 'session_id': 912231859, 'insertion_number': 1, 'electrode_config_hash': UUID('8d4cc6d8-a02d-42c8-bf27-7459c39ea0ee'), 'probe_type': 'neuropixels 1.0 - 3A', 'electrode': 0}}
1137
1142
1138
1143
# -- Spike-sites and Spike-depths --
1139
1144
spike_sites = np .array (
1140
1145
[
1141
- channel2electrodes [s ]["electrode" ]
1146
+ channel_info [s ]["electrode" ]
1142
1147
for s in kilosort_dataset .data ["spike_sites" ]
1143
1148
]
1144
1149
)
@@ -1157,9 +1162,10 @@ def make(self, key):
1157
1162
1158
1163
units .append (
1159
1164
{
1165
+ ** key ,
1160
1166
"unit" : unit ,
1161
1167
"cluster_quality_label" : unit_lbl ,
1162
- ** channel2electrodes [unit_channel ],
1168
+ ** channel_info [unit_channel ],
1163
1169
"spike_times" : unit_spike_times ,
1164
1170
"spike_count" : spike_count ,
1165
1171
"spike_sites" : spike_sites [
@@ -1228,13 +1234,21 @@ class Waveform(dj.Part):
1228
1234
1229
1235
def make (self , key ):
1230
1236
"""Populates waveform tables."""
1231
- output_dir = (ClusteringTask & key ).fetch1 ("clustering_output_dir" )
1237
+ clustering_method , output_dir = (
1238
+ ClusteringTask * ClusteringParamSet & key
1239
+ ).fetch1 ("clustering_method" , "clustering_output_dir" )
1232
1240
output_dir = find_full_path (get_ephys_root_data_dir (), output_dir )
1241
+ sorter_name = (
1242
+ "kilosort2_5" if clustering_method == "kilosort2.5" else clustering_method
1243
+ )
1233
1244
1234
- if (output_dir / "waveform" ).exists (): # read from spikeinterface outputs
1245
+ if (
1246
+ output_dir / sorter_name / "waveform"
1247
+ ).exists (): # read from spikeinterface outputs
1235
1248
1249
+ waveform_dir = output_dir / sorter_name / "waveform"
1236
1250
we : si .WaveformExtractor = si .load_waveforms (
1237
- output_dir / "waveform" , with_recording = False
1251
+ waveform_dir , with_recording = False
1238
1252
)
1239
1253
unit_id_to_peak_channel_indices : dict [int , np .ndarray ] = (
1240
1254
si .ChannelSparsity .from_best_channels (
@@ -1299,11 +1313,15 @@ def make(self, key):
1299
1313
EphysRecording * ProbeInsertion & key
1300
1314
).fetch1 ("acq_software" , "probe" )
1301
1315
1302
- # -- Get channel and electrode-site mapping
1303
- recording_key = (EphysRecording & key ).fetch1 ("KEY" )
1304
- channel2electrodes = get_neuropixels_channel2electrode_map (
1305
- recording_key , acq_software
1316
+ # Get channel and electrode-site mapping
1317
+ channel_info = (
1318
+ (EphysRecording .Channel & key )
1319
+ .proj (..., "-channel_name" )
1320
+ .fetch (as_dict = True , order_by = "channel_idx" )
1306
1321
)
1322
+ channel_info : dict [int , dict ] = {
1323
+ ch .pop ("channel_idx" ): ch for ch in channel_info
1324
+ } # e.g., {0: {'subject': 'sglx', 'session_id': 912231859, 'insertion_number': 1, 'electrode_config_hash': UUID('8d4cc6d8-a02d-42c8-bf27-7459c39ea0ee'), 'probe_type': 'neuropixels 1.0 - 3A', 'electrode': 0}}
1307
1325
1308
1326
# Get all units
1309
1327
units = {
@@ -1335,12 +1353,12 @@ def yield_unit_waveforms():
1335
1353
unit_electrode_waveforms .append (
1336
1354
{
1337
1355
** units [unit_no ],
1338
- ** channel2electrodes [channel ],
1356
+ ** channel_info [channel ],
1339
1357
"waveform_mean" : channel_waveform ,
1340
1358
}
1341
1359
)
1342
1360
if (
1343
- channel2electrodes [channel ]["electrode" ]
1361
+ channel_info [channel ]["electrode" ]
1344
1362
== units [unit_no ]["electrode" ]
1345
1363
):
1346
1364
unit_peak_waveform = {
@@ -1377,12 +1395,12 @@ def yield_unit_waveforms():
1377
1395
unit_electrode_waveforms .append (
1378
1396
{
1379
1397
** units [unit_no ],
1380
- ** channel2electrodes [channel ],
1398
+ ** channel_info [channel ],
1381
1399
"waveform_mean" : channel_waveform ,
1382
1400
}
1383
1401
)
1384
1402
if (
1385
- channel2electrodes [channel ]["electrode" ]
1403
+ channel_info [channel ]["electrode" ]
1386
1404
== units [unit_no ]["electrode" ]
1387
1405
):
1388
1406
unit_peak_waveform = {
@@ -1451,13 +1469,13 @@ def yield_unit_waveforms():
1451
1469
unit_electrode_waveforms .append (
1452
1470
{
1453
1471
** unit_dict ,
1454
- ** channel2electrodes [channel ],
1472
+ ** channel_info [channel ],
1455
1473
"waveform_mean" : channel_waveform .mean (axis = 0 ),
1456
1474
"waveforms" : channel_waveform ,
1457
1475
}
1458
1476
)
1459
1477
if (
1460
- channel2electrodes [channel ]["electrode" ]
1478
+ channel_info [channel ]["electrode" ]
1461
1479
== unit_dict ["electrode" ]
1462
1480
):
1463
1481
unit_peak_waveform = {
0 commit comments