21
21
_linking_module = None
22
22
23
23
24
- def activate (ephys_schema_name , probe_schema_name = None , * , create_schema = True ,
25
- create_tables = True , linking_module = None ):
24
+ def activate (
25
+ ephys_schema_name : str ,
26
+ probe_schema_name : str = None ,
27
+ * ,
28
+ create_schema : bool = True ,
29
+ create_tables : bool = True ,
30
+ linking_module : str = None ,
31
+ ):
26
32
"""Activates the `ephys` and `probe` schemas.
27
33
28
34
Args:
@@ -31,6 +37,17 @@ def activate(ephys_schema_name, probe_schema_name=None, *, create_schema=True,
31
37
create_schema (bool): If True, schema will be created in the database.
32
38
create_tables (bool): If True, tables related to the schema will be created in the database.
33
39
linking_module (str): A string containing the module name or module containing the required dependencies to activate the schema.
40
+
41
+ Dependencies:
42
+
43
+ Upstream tables:
44
+ Session: A parent table to ProbeInsertion
45
+ Probe: A parent table to EphysRecording. Probe information is required before electrophysiology data is imported.
46
+
47
+ Functions:
48
+ get_ephys_root_data_dir(): Returns absolute path for root data director(y/ies) with all electrophysiological recording sessions, as a list of string(s).
49
+ get_session_direction(session_key: dict): Returns path to electrophysiology data for the a particular session as a list of strings.
50
+ get_processed_data_dir(): Optional. Returns absolute path for processed data. Defaults to root directory.
34
51
"""
35
52
36
53
if isinstance (linking_module , str ):
@@ -71,7 +88,8 @@ def get_session_directory(session_key: dict) -> str:
71
88
"""Retrieve the session directory with Neuropixels for the given session.
72
89
73
90
Args:
74
- session_key (dict): A dictionary mapping subject to an entry in the subject table, and session_datetime corresponding to a session in the database.
91
+ session_key (dict): A dictionary mapping subject to an entry in the subject table, and session_datetime corresponding to a session in the database.
92
+
75
93
Returns:
76
94
A string for the path to the session directory.
77
95
"""
@@ -216,8 +234,8 @@ class EphysRecording(dj.Imported):
216
234
217
235
Attributes:
218
236
ProbeInsertion (foreign key): ProbeInsertion primary key.
219
- probe.ElectrodeConfig (query ): probe.ElectrodeConfig primary key.
220
- AcquisitionSoftware (query ): AcquisitionSoftware primary key.
237
+ probe.ElectrodeConfig (dict ): probe.ElectrodeConfig primary key.
238
+ AcquisitionSoftware (dict ): AcquisitionSoftware primary key.
221
239
sampling_rate (float): sampling rate of the recording in Hertz (Hz).
222
240
recording_datetime (datetime): datetime of the recording from this probe.
223
241
recording_duration (float): duration of the entire recording from this probe in seconds.
@@ -238,7 +256,7 @@ class EphysFile(dj.Part):
238
256
"""Paths of electrophysiology recording files for each insertion.
239
257
240
258
Attributes:
241
- master (foreign key): EphysRecording primary key.
259
+ EphysRecording (foreign key): EphysRecording primary key.
242
260
file_path (varchar(255) ): relative file path for electrophysiology recording.
243
261
"""
244
262
@@ -384,7 +402,7 @@ class Electrode(dj.Part):
384
402
"""Saves local field potential data for each electrode.
385
403
386
404
Attributes:
387
- master (foreign key): LFP primary key.
405
+ LFP (foreign key): LFP primary key.
388
406
probe.ElectrodeConfig.Electrode (foreign key): probe.ElectrodeConfig.Electrode primary key.
389
407
lfp (longblob): LFP recording at this electrode in microvolts.
390
408
"""
@@ -496,7 +514,7 @@ class ClusteringParamSet(dj.Lookup):
496
514
497
515
Attributes:
498
516
paramset_idx (foreign key): Unique ID for the clustering parameter set.
499
- ClusteringMethod (query ): ClusteringMethod primary key.
517
+ ClusteringMethod (dict ): ClusteringMethod primary key.
500
518
paramset_desc (varchar(128) ): Description of the clustering parameter set.
501
519
param_set_hash (uuid): UUID hash for the parameter set.
502
520
params (longblob)
@@ -583,7 +601,7 @@ class ClusteringTask(dj.Manual):
583
601
EphysRecording (foreign key): EphysRecording primary key.
584
602
ClusteringParamSet (foreign key): ClusteringParamSet primary key.
585
603
clustering_outdir_dir (varchar (255) ): Relative path to output clustering results.
586
- task_mode (enum('load', 'trigger') ): Either loads or computes clustering.
604
+ task_mode (enum): `Trigger` and `load` either computes clustering or imports existing clustering data, respectively .
587
605
"""
588
606
589
607
definition = """
@@ -596,7 +614,7 @@ class ClusteringTask(dj.Manual):
596
614
"""
597
615
598
616
@classmethod
599
- def infer_output_dir (cls , key , relative = False , mkdir = False ):
617
+ def infer_output_dir (cls , key : dict , relative : bool = False , mkdir : bool = False ):
600
618
"""Infer output directory if it is not provided.
601
619
602
620
Args:
@@ -626,7 +644,7 @@ def infer_output_dir(cls, key, relative=False, mkdir=False):
626
644
return output_dir .relative_to (processed_dir ) if relative else output_dir
627
645
628
646
@classmethod
629
- def auto_generate_entries (cls , ephys_recording_key , paramset_idx = 0 ):
647
+ def auto_generate_entries (cls , ephys_recording_key : dict , paramset_idx : int = 0 ):
630
648
"""Autogenerate entries based on a particular ephys recording.
631
649
632
650
Args:
@@ -822,10 +840,10 @@ class Unit(dj.Part):
822
840
"""Single unit properties after clustering and curation.
823
841
824
842
Attributes:
825
- master (foreign key): CuratedClustering primary key.
843
+ CuratedClustering (foreign key): CuratedClustering primary key.
826
844
unit (foreign key, int): Unique integer identifying a single unit.
827
- probe.ElectrodeConfig.Electrode (query ): probe.ElectrodeConfig.Electrode primary key.
828
- ClusteringQualityLabel (query ): CLusteringQualityLabel primary key.
845
+ probe.ElectrodeConfig.Electrode (dict ): probe.ElectrodeConfig.Electrode primary key.
846
+ ClusteringQualityLabel (dict ): CLusteringQualityLabel primary key.
829
847
spike_count (int): Number of spikes in this recording for this unit.
830
848
spike_times (longblob): Spike times of this unit, relative to start time of EphysRecording.
831
849
spike_sites (longblob): Array of electrode associated with each spike.
@@ -918,7 +936,7 @@ class PeakWaveform(dj.Part):
918
936
"""Mean waveform across spikes for a given unit.
919
937
920
938
Attributes:
921
- master (foreign key): WaveformSet primary key.
939
+ WaveformSet (foreign key): WaveformSet primary key.
922
940
CuratedClustering.Unit (foreign key): CuratedClustering.Unit primary key.
923
941
peak_electrode_waveform (longblob): Mean waveform for a given unit at its representative electrode.
924
942
"""
@@ -935,7 +953,7 @@ class Waveform(dj.Part):
935
953
"""Spike waveforms for a given unit.
936
954
937
955
Attributes:
938
- master (foreign key): WaveformSet primary key.
956
+ WaveformSet (foreign key): WaveformSet primary key.
939
957
CuratedClustering.Unit (foreign key): CuratedClustering.Unit primary key.
940
958
probe.ElectrodeConfig.Electrode (foreign key): probe.ElectrodeConfig.Electrode primary key.
941
959
waveform_mean (longblob): mean waveform across spikes of the unit in microvolts.
@@ -1051,7 +1069,7 @@ class Cluster(dj.Part):
1051
1069
"""Cluster metrics for a unit.
1052
1070
1053
1071
Attributes:
1054
- master (foreign key): QualityMetrics primary key.
1072
+ QualityMetrics (foreign key): QualityMetrics primary key.
1055
1073
CuratedClustering.Unit (foreign key): CuratedClustering.Unit primary key.
1056
1074
firing_rate (float): Firing rate of the unit.
1057
1075
snr (float): Signal-to-noise ratio for a unit.
@@ -1095,7 +1113,7 @@ class Waveform(dj.Part):
1095
1113
"""Waveform metrics for a particular unit.
1096
1114
1097
1115
Attributes:
1098
- master (foreign key): QualityMetrics primary key.
1116
+ QualityMetrics (foreign key): QualityMetrics primary key.
1099
1117
CuratedClustering.Unit (foreign key): CuratedClustering.Unit primary key.
1100
1118
amplitude (float): Absolute difference between waveform peak and trough in microvolts.
1101
1119
duration (float): Time between waveform peak and trough in milliseconds.
@@ -1150,7 +1168,7 @@ def make(self, key):
1150
1168
1151
1169
# ---------------- HELPER FUNCTIONS ----------------
1152
1170
1153
- def get_spikeglx_meta_filepath (ephys_recording_key ) :
1171
+ def get_spikeglx_meta_filepath (ephys_recording_key : dict ) -> str :
1154
1172
"""Get spikeGLX data filepath.
1155
1173
"""
1156
1174
# attempt to retrieve from EphysRecording.EphysFile
@@ -1187,7 +1205,7 @@ def get_spikeglx_meta_filepath(ephys_recording_key):
1187
1205
return spikeglx_meta_filepath
1188
1206
1189
1207
1190
- def get_openephys_probe_data (ephys_recording_key ) :
1208
+ def get_openephys_probe_data (ephys_recording_key : dict ) -> list :
1191
1209
"""Get OpenEphys probe data from file.
1192
1210
"""
1193
1211
inserted_probe_serial_number = (ProbeInsertion * probe .Probe
@@ -1205,7 +1223,7 @@ def get_openephys_probe_data(ephys_recording_key):
1205
1223
return probe_data
1206
1224
1207
1225
1208
- def get_neuropixels_channel2electrode_map (ephys_recording_key , acq_software ) :
1226
+ def get_neuropixels_channel2electrode_map (ephys_recording_key : dict , acq_software : str ) -> dict :
1209
1227
"""Get the channel map for neuropixels probe.
1210
1228
"""
1211
1229
if acq_software == 'SpikeGLX' :
@@ -1243,12 +1261,13 @@ def get_neuropixels_channel2electrode_map(ephys_recording_key, acq_software):
1243
1261
return channel2electrode_map
1244
1262
1245
1263
1246
- def generate_electrode_config (probe_type : str , electrodes : list ):
1264
+ def generate_electrode_config (probe_type : str , electrodes : list ) -> dict :
1247
1265
"""Generate and insert new ElectrodeConfig
1248
1266
1249
1267
Args:
1250
1268
probe_type (str): probe type (e.g. neuropixels 2.0 - SS)
1251
1269
electrodes (list): Electrode dict (keys of the probe.ProbeType.Electrode table)
1270
+
1252
1271
Returns:
1253
1272
dict: representing a key of the probe.ElectrodeConfig table
1254
1273
"""
@@ -1275,8 +1294,8 @@ def generate_electrode_config(probe_type: str, electrodes: list):
1275
1294
return electrode_config_key
1276
1295
1277
1296
1278
- def get_recording_channels_details (ephys_recording_key ) :
1279
- """Get details of recording channels for a givenn recording.
1297
+ def get_recording_channels_details (ephys_recording_key : dict ) -> np . array :
1298
+ """Get details of recording channels for a given recording.
1280
1299
"""
1281
1300
channels_details = {}
1282
1301
0 commit comments