@@ -57,9 +57,9 @@ def activate(ephys_schema_name, probe_schema_name=None, *, create_schema=True,
57
57
58
58
def get_ephys_root_data_dir () -> list :
59
59
"""
60
- All data paths, directories in DataJoint Elements are recommended to be
61
- stored as relative paths, with respect to some user-configured "root"
62
- directory, which varies from machine to machine (e.g. different mounted
60
+ All data paths, directories in DataJoint Elements are recommended to be
61
+ stored as relative paths, with respect to some user-configured "root"
62
+ directory, which varies from machine to machine (e.g. different mounted
63
63
drive locations)
64
64
65
65
get_ephys_root_data_dir() -> list
@@ -130,7 +130,9 @@ class EphysRecording(dj.Imported):
130
130
---
131
131
-> probe.ElectrodeConfig
132
132
-> AcquisitionSoftware
133
- sampling_rate: float # (Hz)
133
+ sampling_rate: float # (Hz)
134
+ recording_datetime: datetime # datetime of the recording from this probe
135
+ recording_duration: float # (seconds) duration of the recording from this probe
134
136
"""
135
137
136
138
class EphysFile (dj .Part ):
@@ -142,7 +144,7 @@ class EphysFile(dj.Part):
142
144
143
145
def make (self , key ):
144
146
145
- session_dir = find_full_path (get_ephys_root_data_dir (),
147
+ session_dir = find_full_path (get_ephys_root_data_dir (),
146
148
get_session_directory (key ))
147
149
148
150
inserted_probe_serial_number = (ProbeInsertion * probe .Probe & key ).fetch1 ('probe' )
@@ -189,9 +191,12 @@ def make(self, key):
189
191
self .insert1 ({** key ,
190
192
** generate_electrode_config (probe_type , electrode_group_members ),
191
193
'acq_software' : acq_software ,
192
- 'sampling_rate' : spikeglx_meta .meta ['imSampRate' ]})
194
+ 'sampling_rate' : spikeglx_meta .meta ['imSampRate' ],
195
+ 'recording_datetime' : spikeglx_meta .recording_time ,
196
+ 'recording_duration' : (spikeglx_meta .recording_duration
197
+ or spikeglx .retrieve_recording_duration (meta_filepath ))})
193
198
194
- root_dir = find_root_directory (get_ephys_root_data_dir (),
199
+ root_dir = find_root_directory (get_ephys_root_data_dir (),
195
200
meta_filepath )
196
201
self .EphysFile .insert1 ({
197
202
** key ,
@@ -223,7 +228,9 @@ def make(self, key):
223
228
self .insert1 ({** key ,
224
229
** generate_electrode_config (probe_type , electrode_group_members ),
225
230
'acq_software' : acq_software ,
226
- 'sampling_rate' : probe_data .ap_meta ['sample_rate' ]})
231
+ 'sampling_rate' : probe_data .ap_meta ['sample_rate' ],
232
+ 'recording_datetime' : probe_data .recording_info ['recording_datetimes' ][0 ],
233
+ 'recording_duration' : np .sum (probe_data .recording_info ['recording_durations' ])})
227
234
228
235
root_dir = find_root_directory (get_ephys_root_data_dir (),
229
236
probe_data .recording_info ['recording_files' ][0 ])
@@ -294,8 +301,7 @@ def make(self, key):
294
301
shank , shank_col , shank_row , _ = spikeglx_recording .apmeta .shankmap ['data' ][recorded_site ]
295
302
electrode_keys .append (probe_electrodes [(shank , shank_col , shank_row )])
296
303
elif acq_software == 'Open Ephys' :
297
-
298
- session_dir = find_full_path (get_ephys_root_data_dir (),
304
+ session_dir = find_full_path (get_ephys_root_data_dir (),
299
305
get_session_directory (key ))
300
306
301
307
loaded_oe = openephys .OpenEphys (session_dir )
@@ -457,9 +463,8 @@ class Curation(dj.Manual):
457
463
458
464
def create1_from_clustering_task (self , key , curation_note = '' ):
459
465
"""
460
- A function to create a new corresponding "Curation" for a particular
461
- "ClusteringTask", which assumes that no curation was performed on the
462
- dataset
466
+ A function to create a new corresponding "Curation" for a particular
467
+ "ClusteringTask"
463
468
"""
464
469
if key not in Clustering ():
465
470
raise ValueError (f'No corresponding entry in Clustering available'
@@ -473,9 +478,9 @@ def create1_from_clustering_task(self, key, curation_note=''):
473
478
# Synthesize curation_id
474
479
curation_id = dj .U ().aggr (self & key , n = 'ifnull(max(curation_id)+1,1)' ).fetch1 ('n' )
475
480
self .insert1 ({** key , 'curation_id' : curation_id ,
476
- 'curation_time' : creation_time ,
481
+ 'curation_time' : creation_time ,
477
482
'curation_output_dir' : output_dir ,
478
- 'quality_control' : is_qc ,
483
+ 'quality_control' : is_qc ,
479
484
'manual_curation' : is_curated ,
480
485
'curation_note' : curation_note })
481
486
@@ -623,7 +628,7 @@ def yield_unit_waveforms():
623
628
spikeglx_meta_filepath = get_spikeglx_meta_filepath (key )
624
629
neuropixels_recording = spikeglx .SpikeGLX (spikeglx_meta_filepath .parent )
625
630
elif acq_software == 'Open Ephys' :
626
- session_dir = find_full_path (get_ephys_root_data_dir (),
631
+ session_dir = find_full_path (get_ephys_root_data_dir (),
627
632
get_session_directory (key ))
628
633
openephys_dataset = openephys .OpenEphys (session_dir )
629
634
neuropixels_recording = openephys_dataset .probes [probe_serial_number ]
@@ -670,7 +675,7 @@ def get_spikeglx_meta_filepath(ephys_recording_key):
670
675
except FileNotFoundError :
671
676
# if not found, search in session_dir again
672
677
if not spikeglx_meta_filepath .exists ():
673
- session_dir = find_full_path (get_ephys_root_data_dir (),
678
+ session_dir = find_full_path (get_ephys_root_data_dir (),
674
679
get_session_directory (
675
680
ephys_recording_key ))
676
681
inserted_probe_serial_number = (ProbeInsertion * probe .Probe
@@ -709,7 +714,7 @@ def get_neuropixels_channel2electrode_map(ephys_recording_key, acq_software):
709
714
for recorded_site , (shank , shank_col , shank_row , _ ) in enumerate (
710
715
spikeglx_meta .shankmap ['data' ])}
711
716
elif acq_software == 'Open Ephys' :
712
- session_dir = find_full_path (get_ephys_root_data_dir (),
717
+ session_dir = find_full_path (get_ephys_root_data_dir (),
713
718
get_session_directory (ephys_recording_key ))
714
719
openephys_dataset = openephys .OpenEphys (session_dir )
715
720
probe_serial_number = (ProbeInsertion & ephys_recording_key ).fetch1 ('probe' )
0 commit comments