9
9
10
10
11
11
def activate (
12
- schema_name : str ,
13
- * ,
12
+ schema_name : str ,
13
+ * ,
14
14
create_schema : bool = True ,
15
- create_tables : bool = True ,
15
+ create_tables : bool = True ,
16
16
):
17
- """Activates the `probe` schemas.
17
+ """Activates the `probe` schemas.
18
18
19
19
Args:
20
20
schema_name (str): A string containing the name of the probe scehma.
21
21
create_schema (bool): If True, schema will be created in the database.
22
22
create_tables (bool): If True, tables related to the schema will be created in the database.
23
-
23
+
24
24
Dependencies:
25
25
Upstream tables:
26
26
Session: A parent table to ProbeInsertion.
27
-
27
+
28
28
Functions:
29
29
"""
30
- schema .activate (schema_name , create_schema = create_schema , create_tables = create_tables )
30
+ schema .activate (
31
+ schema_name , create_schema = create_schema , create_tables = create_tables
32
+ )
31
33
32
34
# Add neuropixels probes
33
35
for probe_type in (
@@ -47,6 +49,7 @@ class ProbeType(dj.Lookup):
47
49
Attributes:
48
50
probe_type (foreign key, varchar (32) ): Name of the probe type.
49
51
"""
52
+
50
53
definition = """
51
54
# Type of probe, with specific electrodes geometry defined
52
55
probe_type: varchar(32) # e.g. neuropixels_1.0
@@ -64,16 +67,16 @@ class Electrode(dj.Part):
64
67
x_coord (float): x-coordinate of the electrode within the probe in micrometers.
65
68
y_coord (float): y-coordinate of the electrode within the probe in micrometers.
66
69
"""
67
-
70
+
68
71
definition = """
69
72
-> master
70
73
electrode: int # electrode index, starts at 0
71
74
---
72
75
shank: int # shank index, starts at 0, advance left to right
73
76
shank_col: int # column index, starts at 0, advance left to right
74
77
shank_row: int # row index, starts at 0, advance tip to tail
75
- x_coord=NULL: float # (um ) x coordinate of the electrode within the probe, (0, 0) is the bottom left corner of the probe
76
- y_coord=NULL: float # (um ) y coordinate of the electrode within the probe, (0, 0) is the bottom left corner of the probe
78
+ x_coord=NULL: float # (μm ) x coordinate of the electrode within the probe, (0, 0) is the bottom left corner of the probe
79
+ y_coord=NULL: float # (μm ) y coordinate of the electrode within the probe, (0, 0) is the bottom left corner of the probe
77
80
"""
78
81
79
82
@staticmethod
@@ -139,62 +142,7 @@ def create_neuropixels_probe(probe_type: str = "neuropixels 1.0 - 3A"):
139
142
),
140
143
}
141
144
142
- def build_electrodes (
143
- site_count : int ,
144
- col_spacing : float ,
145
- row_spacing : float ,
146
- white_spacing : float ,
147
- col_count : int ,
148
- shank_count : int ,
149
- shank_spacing : float ,
150
- ) -> dict :
151
- """Builds electrode layouts.
152
-
153
- Args:
154
- site_count (int): site count per shank
155
- col_spacing (float): (um) horrizontal spacing between sites
156
- row_spacing (float): (um) vertical spacing between columns
157
- white_spacing (float): (um) offset spacing
158
- col_count (int): number of column per shank
159
- shank_count (int): number of shank
160
- shank_spacing (float): spacing between shanks
161
- """
162
- row_count = int (site_count / col_count )
163
- x_coords = np .tile (
164
- np .arange (0 , col_spacing * col_count , col_spacing ), row_count
165
- )
166
- y_coords = np .repeat (np .arange (row_count ) * row_spacing , col_count )
167
-
168
- if white_spacing :
169
- x_white_spaces = np .tile (
170
- [white_spacing , white_spacing , 0 , 0 ], int (row_count / 2 )
171
- )
172
- x_coords = x_coords + x_white_spaces
173
-
174
- shank_cols = np .tile (range (col_count ), row_count )
175
- shank_rows = np .repeat (range (row_count ), col_count )
176
-
177
- npx_electrodes = []
178
- for shank_no in range (shank_count ):
179
- npx_electrodes .extend (
180
- [
181
- {
182
- "electrode" : (site_count * shank_no ) + e_id ,
183
- "shank" : shank_no ,
184
- "shank_col" : c_id ,
185
- "shank_row" : r_id ,
186
- "x_coord" : x + (shank_no * shank_spacing ),
187
- "y_coord" : y ,
188
- }
189
- for e_id , (c_id , r_id , x , y ) in enumerate (
190
- zip (shank_cols , shank_rows , x_coords , y_coords )
191
- )
192
- ]
193
- )
194
-
195
- return npx_electrodes
196
-
197
- electrodes = build_electrodes (** neuropixels_probes_config [probe_type ])
145
+ electrodes = build_electrode_layouts (** neuropixels_probes_config [probe_type ])
198
146
probe_type = {"probe_type" : probe_type }
199
147
with ProbeType .connection .transaction :
200
148
ProbeType .insert1 (probe_type , skip_duplicates = True )
@@ -247,8 +195,65 @@ class Electrode(dj.Part):
247
195
ElectrodeConfig (foreign key): ElectrodeConfig primary key.
248
196
ProbeType.Electrode (foreign key): ProbeType.Electrode primary key.
249
197
"""
250
-
198
+
251
199
definition = """ # Electrodes selected for recording
252
200
-> master
253
201
-> ProbeType.Electrode
254
202
"""
203
+
204
+
205
+ def build_electrode_layouts (
206
+ site_count : int ,
207
+ col_spacing : float = 1 ,
208
+ row_spacing : float = 1 ,
209
+ white_spacing : float = None ,
210
+ col_count : int = 1 ,
211
+ shank_count : int = 1 ,
212
+ shank_spacing : float = 1 ,
213
+ y_origin = "bottom" ,
214
+ ) -> dict :
215
+
216
+ """Builds electrode layouts.
217
+
218
+ Args:
219
+ site_count (int): site count per shank
220
+ col_spacing (float): (μm) horizontal spacing between sites. Defaults to 1 (single column).
221
+ row_spacing (float): (μm) vertical spacing between columns. Defaults to 1 (single row).
222
+ white_spacing (float): (μm) offset spacing. Defaults to None.
223
+ col_count (int): number of column per shank. Defaults to 1 (single column).
224
+ shank_count (int): number of shank. Defaults to 1 (single shank).
225
+ shank_spacing (float): spacing between shanks. Defaults to 1 (single shank).
226
+ y_origin (str): {"bottom", "top"}. y value decrements if "top". Defaults to "bottom".
227
+ """
228
+ row_count = int (site_count / col_count )
229
+ x_coords = np .tile (np .arange (0 , col_spacing * col_count , col_spacing ), row_count )
230
+ y_coords = np .repeat (np .arange (row_count ) * row_spacing , col_count )
231
+
232
+ if white_spacing :
233
+ x_white_spaces = np .tile (
234
+ [white_spacing , white_spacing , 0 , 0 ], int (row_count / 2 )
235
+ )
236
+ x_coords = x_coords + x_white_spaces
237
+
238
+ shank_cols = np .tile (range (col_count ), row_count )
239
+ shank_rows = np .repeat (range (row_count ), col_count )
240
+
241
+ electrode_layouts = []
242
+ for shank_no in range (shank_count ):
243
+ electrode_layouts .extend (
244
+ [
245
+ {
246
+ "electrode" : (site_count * shank_no ) + e_id ,
247
+ "shank" : shank_no ,
248
+ "shank_col" : c_id ,
249
+ "shank_row" : r_id ,
250
+ "x_coord" : x + (shank_no * shank_spacing ),
251
+ "y_coord" : y * {"top" : - 1 , "bottom" : 1 }[y_origin ],
252
+ }
253
+ for e_id , (c_id , r_id , x , y ) in enumerate (
254
+ zip (shank_cols , shank_rows , x_coords , y_coords )
255
+ )
256
+ ]
257
+ )
258
+
259
+ return electrode_layouts
0 commit comments