8
8
from collections .abc import Mapping
9
9
10
10
from .readers import neuropixels , kilosort
11
- from .probe import schema as probe_schema , ProbeType , ElectrodeConfig
12
-
11
+ from . import probe
13
12
14
13
schema = dj .schema ()
15
14
16
15
17
16
def activate (ephys_schema_name , probe_schema_name = None , create_schema = True , create_tables = True , add_objects = None ):
18
17
upstream_tables = ("Session" , "SkullReference" )
19
- required_functions = ("get_neuropixels_data_directory" , "get_paramset_idx" , "get_kilosort_output_directory" )
20
18
assert isinstance (add_objects , Mapping )
21
19
try :
22
- raise next ( RuntimeError ("Table %s is required for module ephys" % name )
23
- for name in upstream_tables
24
- if not isinstance (add_objects .get (name , None ), (dj .Manual , dj .Lookup , dj .Imported , dj .Computed )))
20
+ raise RuntimeError ("Table %s is required for module ephys" % next (
21
+ name for name in upstream_tables
22
+ if not isinstance (add_objects .get (name , None ), (dj .Manual , dj .Lookup , dj .Imported , dj .Computed ) )))
25
23
except StopIteration :
26
24
pass # all ok
27
25
26
+ required_functions = ("get_neuropixels_data_directory" , "get_paramset_idx" , "get_kilosort_output_directory" )
28
27
assert isinstance (add_objects , Mapping )
29
28
try :
30
- raise next ( RuntimeError ("Function %s is required for module ephys" % name )
31
- for name in required_functions
32
- if not inspect .isfunction (add_objects .get (name , None )))
29
+ raise RuntimeError ("Function %s is required for module ephys" % next (
30
+ name for name in required_functions
31
+ if not inspect .isfunction (add_objects .get (name , None ) )))
33
32
except StopIteration :
34
33
pass # all ok
35
34
36
- if not probe_schema .is_activated :
37
- probe_schema .activate (probe_schema_name or ephys_schema_name ,
35
+ if not probe . schema .is_activated :
36
+ probe . schema .activate (probe_schema_name or ephys_schema_name ,
38
37
create_schema = create_schema , create_tables = create_tables )
39
38
schema .activate (ephys_schema_name , create_schema = create_schema ,
40
39
create_tables = create_tables , add_objects = add_objects )
@@ -67,7 +66,6 @@ def get_paramset_idx(ephys_rec_key: dict) -> int:
67
66
raise NotImplementedError ('Workflow module should define' )
68
67
69
68
70
-
71
69
def dict_to_uuid (key ):
72
70
"""
73
71
Given a dictionary `key`, returns a hash string
@@ -87,7 +85,7 @@ class ProbeInsertion(dj.Manual): # (acute)
87
85
-> Session
88
86
insertion_number: tinyint unsigned
89
87
---
90
- -> Probe
88
+ -> probe. Probe
91
89
"""
92
90
93
91
@@ -134,7 +132,7 @@ def make(self, key):
134
132
if re .search ('(1.0|2.0)' , neuropixels_meta .probe_model ):
135
133
eg_members = []
136
134
probe_type = {'probe_type' : neuropixels_meta .probe_model }
137
- q_electrodes = ProbeType .Electrode & probe_type
135
+ q_electrodes = probe . ProbeType .Electrode & probe_type
138
136
for shank , shank_col , shank_row , is_used in neuropixels_meta .shankmap ['data' ]:
139
137
electrode = (q_electrodes & {'shank' : shank ,
140
138
'shank_col' : shank_col ,
@@ -181,7 +179,7 @@ class LFP(dj.Imported):
181
179
class Electrode (dj .Part ):
182
180
definition = """
183
181
-> master
184
- -> ElectrodeConfig.Electrode
182
+ -> probe. ElectrodeConfig.Electrode
185
183
---
186
184
lfp: longblob # (mV) recorded lfp at this electrode
187
185
"""
@@ -200,7 +198,7 @@ def make(self, key):
200
198
Only store LFP for every 9th channel (defined in skip_chn_counts), counting in reverse
201
199
Due to high channel density, close-by channels exhibit highly similar lfp
202
200
'''
203
- q_electrodes = ProbeType .Electrode * ElectrodeConfig .Electrode & key
201
+ q_electrodes = probe . ProbeType .Electrode * probe . ElectrodeConfig .Electrode & key
204
202
electrodes = []
205
203
for recorded_site in np .arange (lfp .shape [0 ]):
206
204
shank , shank_col , shank_row , _ = neuropixels_recording .neuropixels_meta .shankmap ['data' ][recorded_site ]
@@ -311,7 +309,7 @@ class Unit(dj.Part):
311
309
-> master
312
310
unit: int
313
311
---
314
- -> ElectrodeConfig.Electrode # electrode on the probe that this unit has highest response amplitude
312
+ -> probe. ElectrodeConfig.Electrode # electrode on the probe that this unit has highest response amplitude
315
313
-> ClusterQualityLabel
316
314
spike_count: int # how many spikes in this recording of this unit
317
315
spike_times: longblob # (s) spike times of this unit, relative to the start of the EphysRecording
@@ -376,7 +374,7 @@ class Waveform(dj.Imported):
376
374
class Electrode (dj .Part ):
377
375
definition = """
378
376
-> master
379
- -> ElectrodeConfig.Electrode
377
+ -> probe. ElectrodeConfig.Electrode
380
378
---
381
379
waveform_mean: longblob # mean over all spikes
382
380
waveforms=null: longblob # (spike x sample) waveform of each spike at each electrode
@@ -466,9 +464,9 @@ def get_neuropixels_chn2electrode_map(ephys_recording_key):
466
464
neuropixels_dir = EphysRecording ._get_neuropixels_data_directory (ephys_recording_key )
467
465
meta_filepath = next (pathlib .Path (neuropixels_dir ).glob ('*.ap.meta' ))
468
466
neuropixels_meta = neuropixels .NeuropixelsMeta (meta_filepath )
469
- e_config_key = (EphysRecording * ElectrodeConfig & ephys_recording_key ).fetch1 ('KEY' )
467
+ e_config_key = (EphysRecording * probe . ElectrodeConfig & ephys_recording_key ).fetch1 ('KEY' )
470
468
471
- q_electrodes = ProbeType .Electrode * ElectrodeConfig .Electrode & e_config_key
469
+ q_electrodes = probe . ProbeType .Electrode * probe . ElectrodeConfig .Electrode & e_config_key
472
470
chn2electrode_map = {}
473
471
for recorded_site , (shank , shank_col , shank_row , _ ) in enumerate (neuropixels_meta .shankmap ['data' ]):
474
472
chn2electrode_map [recorded_site ] = (q_electrodes
0 commit comments