@@ -371,31 +371,30 @@ def make(self, key):
371
371
probe_type , electrode_group_members
372
372
)
373
373
374
- self .insert1 (
375
- {
376
- ** key ,
377
- "electrode_config_hash" : econfig_entry ["electrode_config_hash" ],
378
- "acq_software" : acq_software ,
379
- "sampling_rate" : spikeglx_meta .meta ["imSampRate" ],
380
- "recording_datetime" : spikeglx_meta .recording_time ,
381
- "recording_duration" : (
382
- spikeglx_meta .recording_duration
383
- or spikeglx .retrieve_recording_duration (spikeglx_meta_filepath )
384
- ),
385
- }
386
- )
374
+ ephys_recording_entry = {
375
+ ** key ,
376
+ "electrode_config_hash" : econfig_entry ["electrode_config_hash" ],
377
+ "acq_software" : acq_software ,
378
+ "sampling_rate" : spikeglx_meta .meta ["imSampRate" ],
379
+ "recording_datetime" : spikeglx_meta .recording_time ,
380
+ "recording_duration" : (
381
+ spikeglx_meta .recording_duration
382
+ or spikeglx .retrieve_recording_duration (spikeglx_meta_filepath )
383
+ ),
384
+ }
387
385
388
386
root_dir = find_root_directory (
389
387
get_ephys_root_data_dir (), spikeglx_meta_filepath
390
388
)
391
- self .EphysFile .insert1 (
389
+
390
+ ephys_file_entries = [
392
391
{
393
392
** key ,
394
393
"file_path" : spikeglx_meta_filepath .relative_to (
395
394
root_dir
396
395
).as_posix (),
397
396
}
398
- )
397
+ ]
399
398
400
399
# Insert channel information
401
400
# Get channel and electrode-site mapping
@@ -417,13 +416,11 @@ def make(self, key):
417
416
spikeglx_meta .shankmap ["data" ]
418
417
)
419
418
}
420
- self .Channel .insert (
421
- [
422
- {** key , "channel_idx" : channel_idx , ** channel_info }
423
- for channel_idx , channel_info in channel2electrode_map .items ()
424
- ]
425
- )
426
419
420
+ ephys_channel_entries = [
421
+ {** key , "channel_idx" : channel_idx , ** channel_info }
422
+ for channel_idx , channel_info in channel2electrode_map .items ()
423
+ ]
427
424
elif acq_software == "Open Ephys" :
428
425
dataset = openephys .OpenEphys (session_dir )
429
426
for serial_number , probe_data in dataset .probes .items ():
@@ -460,31 +457,29 @@ def make(self, key):
460
457
probe_type , electrode_group_members
461
458
)
462
459
463
- self .insert1 (
464
- {
465
- ** key ,
466
- "electrode_config_hash" : econfig_entry ["electrode_config_hash" ],
467
- "acq_software" : acq_software ,
468
- "sampling_rate" : probe_data .ap_meta ["sample_rate" ],
469
- "recording_datetime" : probe_data .recording_info [
470
- "recording_datetimes"
471
- ][0 ],
472
- "recording_duration" : np .sum (
473
- probe_data .recording_info ["recording_durations" ]
474
- ),
475
- }
476
- )
460
+ ephys_recording_entry = {
461
+ ** key ,
462
+ "electrode_config_hash" : econfig_entry ["electrode_config_hash" ],
463
+ "acq_software" : acq_software ,
464
+ "sampling_rate" : probe_data .ap_meta ["sample_rate" ],
465
+ "recording_datetime" : probe_data .recording_info ["recording_datetimes" ][
466
+ 0
467
+ ],
468
+ "recording_duration" : np .sum (
469
+ probe_data .recording_info ["recording_durations" ]
470
+ ),
471
+ }
477
472
478
473
root_dir = find_root_directory (
479
474
get_ephys_root_data_dir (),
480
475
probe_data .recording_info ["recording_files" ][0 ],
481
476
)
482
- self . EphysFile . insert (
483
- [
484
- {** key , "file_path" : fp .relative_to (root_dir ).as_posix ()}
485
- for fp in probe_data .recording_info ["recording_files" ]
486
- ]
487
- )
477
+
478
+ ephys_file_entries = [
479
+ {** key , "file_path" : fp .relative_to (root_dir ).as_posix ()}
480
+ for fp in probe_data .recording_info ["recording_files" ]
481
+ ]
482
+
488
483
# Explicitly garbage collect "dataset" as these may have large memory footprint and may not be cleared fast enough
489
484
del probe_data , dataset
490
485
gc .collect ()
@@ -503,11 +498,14 @@ def make(self, key):
503
498
channel_idx : probe_electrodes [channel_idx ]
504
499
for channel_idx in probe_dataset .ap_meta ["channels_indices" ]
505
500
}
506
- self .Channel .insert (
507
- [
508
- {** key , "channel_idx" : channel_idx , ** channel_info }
509
- for channel_idx , channel_info in channel2electrode_map .items ()
510
- ]
501
+
502
+ ephys_channel_entries = [
503
+ {** key , "channel_idx" : channel_idx , ** channel_info }
504
+ for channel_idx , channel_info in channel2electrode_map .items ()
505
+ ]
506
+ else :
507
+ raise NotImplementedError (
508
+ f"Processing ephys files from acquisition software of type { acq_software } is not yet implemented."
511
509
)
512
510
513
511
# Insert into probe.ElectrodeConfig (recording configuration)
@@ -517,6 +515,10 @@ def make(self, key):
517
515
probe .ElectrodeConfig .insert1 (econfig_entry )
518
516
probe .ElectrodeConfig .Electrode .insert (econfig_electrodes )
519
517
518
+ self .insert1 (ephys_recording_entry )
519
+ self .EphysFile .insert (ephys_file_entries )
520
+ self .Channel .insert (ephys_channel_entries )
521
+
520
522
521
523
@schema
522
524
class LFP (dj .Imported ):
0 commit comments