88from collections .abc import Mapping
99
1010from .readers import neuropixels , kilosort
11- from .probe import schema as probe_schema , ProbeType , ElectrodeConfig
12-
11+ from . import probe
1312
1413schema = dj .schema ()
1514
1615
1716def activate (ephys_schema_name , probe_schema_name = None , create_schema = True , create_tables = True , add_objects = None ):
1817 upstream_tables = ("Session" , "SkullReference" )
19- required_functions = ("get_neuropixels_data_directory" , "get_paramset_idx" , "get_kilosort_output_directory" )
2018 assert isinstance (add_objects , Mapping )
2119 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 ) )))
2523 except StopIteration :
2624 pass # all ok
2725
26+ required_functions = ("get_neuropixels_data_directory" , "get_paramset_idx" , "get_kilosort_output_directory" )
2827 assert isinstance (add_objects , Mapping )
2928 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 ) )))
3332 except StopIteration :
3433 pass # all ok
3534
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 ,
3837 create_schema = create_schema , create_tables = create_tables )
3938 schema .activate (ephys_schema_name , create_schema = create_schema ,
4039 create_tables = create_tables , add_objects = add_objects )
@@ -67,7 +66,6 @@ def get_paramset_idx(ephys_rec_key: dict) -> int:
6766 raise NotImplementedError ('Workflow module should define' )
6867
6968
70-
7169def dict_to_uuid (key ):
7270 """
7371 Given a dictionary `key`, returns a hash string
@@ -87,7 +85,7 @@ class ProbeInsertion(dj.Manual): # (acute)
8785 -> Session
8886 insertion_number: tinyint unsigned
8987 ---
90- -> Probe
88+ -> probe. Probe
9189 """
9290
9391
@@ -134,7 +132,7 @@ def make(self, key):
134132 if re .search ('(1.0|2.0)' , neuropixels_meta .probe_model ):
135133 eg_members = []
136134 probe_type = {'probe_type' : neuropixels_meta .probe_model }
137- q_electrodes = ProbeType .Electrode & probe_type
135+ q_electrodes = probe . ProbeType .Electrode & probe_type
138136 for shank , shank_col , shank_row , is_used in neuropixels_meta .shankmap ['data' ]:
139137 electrode = (q_electrodes & {'shank' : shank ,
140138 'shank_col' : shank_col ,
@@ -181,7 +179,7 @@ class LFP(dj.Imported):
181179 class Electrode (dj .Part ):
182180 definition = """
183181 -> master
184- -> ElectrodeConfig.Electrode
182+ -> probe. ElectrodeConfig.Electrode
185183 ---
186184 lfp: longblob # (mV) recorded lfp at this electrode
187185 """
@@ -200,7 +198,7 @@ def make(self, key):
200198 Only store LFP for every 9th channel (defined in skip_chn_counts), counting in reverse
201199 Due to high channel density, close-by channels exhibit highly similar lfp
202200 '''
203- q_electrodes = ProbeType .Electrode * ElectrodeConfig .Electrode & key
201+ q_electrodes = probe . ProbeType .Electrode * probe . ElectrodeConfig .Electrode & key
204202 electrodes = []
205203 for recorded_site in np .arange (lfp .shape [0 ]):
206204 shank , shank_col , shank_row , _ = neuropixels_recording .neuropixels_meta .shankmap ['data' ][recorded_site ]
@@ -311,7 +309,7 @@ class Unit(dj.Part):
311309 -> master
312310 unit: int
313311 ---
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
315313 -> ClusterQualityLabel
316314 spike_count: int # how many spikes in this recording of this unit
317315 spike_times: longblob # (s) spike times of this unit, relative to the start of the EphysRecording
@@ -376,7 +374,7 @@ class Waveform(dj.Imported):
376374 class Electrode (dj .Part ):
377375 definition = """
378376 -> master
379- -> ElectrodeConfig.Electrode
377+ -> probe. ElectrodeConfig.Electrode
380378 ---
381379 waveform_mean: longblob # mean over all spikes
382380 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):
466464 neuropixels_dir = EphysRecording ._get_neuropixels_data_directory (ephys_recording_key )
467465 meta_filepath = next (pathlib .Path (neuropixels_dir ).glob ('*.ap.meta' ))
468466 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' )
470468
471- q_electrodes = ProbeType .Electrode * ElectrodeConfig .Electrode & e_config_key
469+ q_electrodes = probe . ProbeType .Electrode * probe . ElectrodeConfig .Electrode & e_config_key
472470 chn2electrode_map = {}
473471 for recorded_site , (shank , shank_col , shank_row , _ ) in enumerate (neuropixels_meta .shankmap ['data' ]):
474472 chn2electrode_map [recorded_site ] = (q_electrodes
0 commit comments