Skip to content

Commit 5e45e90

Browse files
authored
Merge pull request #323 from alejoe91/npix-nxt
Remove `oe_x_shift`, add `NP2020`, and fix OE contour
2 parents 26634d6 + e665941 commit 5e45e90

1 file changed

Lines changed: 37 additions & 28 deletions

File tree

src/probeinterface/neuropixels_tools.py

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
55
Note:
66
* the centre of the first left columns and the first bottom row is our reference (x=0, y=0)
7-
* "oe_x_shift" is a global shift on x axis to make spikeglx and openephys compatible.
87
98
"""
109

@@ -81,7 +80,6 @@
8180
"lf_gains",
8281
"ap_hp_filters",
8382
),
84-
"oe_x_shift": -11,
8583
},
8684
# Neuropixels 2.0 - Single Shank - Prototype
8785
"21": {
@@ -97,7 +95,6 @@
9795
"contour_description": "np70",
9896
"contour_shift": [-27, -11],
9997
"fields_in_imro_table": ("channel_ids", "banks", "references", "elec_ids"),
100-
"oe_x_shift": -8,
10198
},
10299
# Neuropixels 2.0 - Four Shank - Prototype
103100
"24": {
@@ -119,7 +116,6 @@
119116
"references",
120117
"elec_ids",
121118
),
122-
"oe_x_shift": -8,
123119
},
124120
# Neuropixels 2.0 - Single Shank - Commercial without metal cap
125121
"2003": {
@@ -135,7 +131,6 @@
135131
"contour_description": "np70",
136132
"contour_shift": [-27, -11],
137133
"fields_in_imro_table": ("channel_ids", "banks", "references", "elec_ids"),
138-
"oe_x_shift": -8,
139134
},
140135
# Neuropixels 2.0 - Single Shank - Commercial with metal cap
141136
"2004": {
@@ -151,7 +146,6 @@
151146
"contour_description": "np70",
152147
"contour_shift": [-27, -11],
153148
"fields_in_imro_table": ("channel_ids", "banks", "references", "elec_ids"),
154-
"oe_x_shift": -8,
155149
},
156150
# Neuropixels 2.0 - Four Shank - Commercial without metal cap
157151
"2013": {
@@ -173,7 +167,6 @@
173167
"references",
174168
"elec_ids",
175169
),
176-
"oe_x_shift": -8,
177170
},
178171
# Neuropixels 2.0 - Four Shank - Commercial with metal cap
179172
"2014": {
@@ -195,7 +188,27 @@
195188
"references",
196189
"elec_ids",
197190
),
198-
"oe_x_shift": -8,
191+
},
192+
# Neuropixels 2.0 Quad Base
193+
"2020": {
194+
"model_name": "Neuropixels 2.0 Quad Base",
195+
"x_pitch": 32,
196+
"y_pitch": 15,
197+
"contact_width": 12,
198+
"stagger": 0.0,
199+
"shank_pitch": 250,
200+
"shank_number": 4,
201+
"ncols_per_shank": 2,
202+
"nrows_per_shank": 640,
203+
"contour_description": "np70",
204+
"contour_shift": [-27, -11],
205+
"fields_in_imro_table": (
206+
"channel_ids",
207+
"shank_id",
208+
"banks",
209+
"references",
210+
"elec_ids",
211+
),
199212
},
200213
# Experimental probes previous to 1.0
201214
"Phase3a": {
@@ -217,7 +230,6 @@
217230
"ap_gains",
218231
"lf_gains",
219232
),
220-
"oe_x_shift": -11,
221233
},
222234
# Neuropixels 1.0-NHP Short (10mm)
223235
"1015": {
@@ -240,7 +252,6 @@
240252
"lf_gains",
241253
"ap_hp_filters",
242254
),
243-
"oe_x_shift": -11,
244255
},
245256
#################
246257
# Neuropixels 1.0-NHP Medium (25mm)
@@ -264,7 +275,6 @@
264275
"lf_gains",
265276
"ap_hp_filters",
266277
),
267-
"oe_x_shift": -11,
268278
},
269279
# Neuropixels 1.0-NHP Medium (25mm)
270280
"1021": {
@@ -287,7 +297,6 @@
287297
"lf_gains",
288298
"ap_hp_filters",
289299
),
290-
"oe_x_shift": -11,
291300
},
292301
#################
293302
# Neuropixels 1.0-NHP Medium (25mm)
@@ -311,7 +320,6 @@
311320
"lf_gains",
312321
"ap_hp_filters",
313322
),
314-
"oe_x_shift": -11,
315323
},
316324
# Neuropixels 1.0-NHP 45mm SOI90 - NHP long 90um wide, staggered contacts
317325
"1030": {
@@ -334,7 +342,6 @@
334342
"lf_gains",
335343
"ap_hp_filters",
336344
),
337-
"oe_x_shift": -11,
338345
},
339346
# Neuropixels 1.0-NHP 45mm SOI125 - NHP long 125um wide, staggered contacts
340347
"1031": {
@@ -357,7 +364,6 @@
357364
"lf_gains",
358365
"ap_hp_filters",
359366
),
360-
"oe_x_shift": -11,
361367
},
362368
# 1.0-NHP 45mm SOI115 / 125 linear - NHP long 125um wide, linear contacts
363369
"1032": {
@@ -380,7 +386,6 @@
380386
"lf_gains",
381387
"ap_hp_filters",
382388
),
383-
"oe_x_shift": -11,
384389
},
385390
# Ultra probes 1 bank
386391
"1100": {
@@ -403,7 +408,6 @@
403408
"lf_gains",
404409
"ap_hp_filters",
405410
),
406-
"oe_x_shift": -8,
407411
},
408412
# Ultra probes 16 banks
409413
"1110": {
@@ -426,7 +430,6 @@
426430
"lf_gains",
427431
"ap_hp_filters",
428432
),
429-
"oe_x_shift": -8,
430433
},
431434
"1121": {
432435
"model_name": "Neuropixels Ultra - Type 2",
@@ -448,7 +451,6 @@
448451
"lf_gains",
449452
"ap_hp_filters",
450453
),
451-
"oe_x_shift": 18,
452454
},
453455
# NP-Opto
454456
"1300": {
@@ -471,7 +473,6 @@
471473
"lf_gains",
472474
"ap_hp_filters",
473475
),
474-
"oe_x_shift": -11,
475476
},
476477
}
477478

@@ -506,6 +507,8 @@
506507
"NP2004": "2004",
507508
"PRB2_1_2_0640_0": "21",
508509
"PRB2_4_2_0640_0": "24",
510+
# NXT
511+
"NP2020": "2020",
509512
# Ultra
510513
"NP1100": "1100", # Ultra probe - 1 bank
511514
"NP1110": "1110", # Ultra probe - 16 banks no handle beacuse
@@ -1052,7 +1055,9 @@ def read_openephys(
10521055

10531056
# check if shank ids is present
10541057
if all(":" in val for val in channel_values):
1055-
shank_ids = np.array([int(val[val.find(":") + 1 :]) for val in channel_values])
1058+
shank_ids = np.array([int(val.split(":")[1]) for val in channel_values])
1059+
elif all("_" in val for val in channel_names):
1060+
shank_ids = np.array([int(val.split("_")[1]) for val in channel_names])
10561061
else:
10571062
shank_ids = None
10581063

@@ -1071,13 +1076,16 @@ def read_openephys(
10711076
if probe_part_number not in probe_part_number_to_probe_type:
10721077
raise NotImplementedError(f"Probe part number {probe_part_number} is not supported yet")
10731078
ptype = probe_part_number_to_probe_type[probe_part_number]
1074-
x_shift = npx_descriptions[ptype]["oe_x_shift"] if ptype is not None else 0
10751079

10761080
if fix_x_position_for_oe_5 and oe_version < parse("0.6.0") and shank_ids is not None:
10771081
positions[:, 1] = positions[:, 1] - npx_descriptions[ptype]["shank_pitch"] * shank_ids
10781082

1079-
# x offset
1080-
positions[:, 0] += x_shift
1083+
# x offset so that the first column is at 0x
1084+
offset = np.min(positions[:, 0])
1085+
# if some shanks are not used, we need to adjust the offset
1086+
if shank_ids is not None:
1087+
offset -= np.min(shank_ids) * npx_descriptions[ptype]["shank_pitch"]
1088+
positions[:, 0] -= offset
10811089

10821090
contact_ids = []
10831091
for i, pos in enumerate(positions):
@@ -1122,6 +1130,7 @@ def read_openephys(
11221130
# now select correct probe (if multiple)
11231131
if len(np_probes) > 1:
11241132
found = False
1133+
probe_names = [p["name"] for p in np_probes_info]
11251134

11261135
if stream_name is not None:
11271136
assert probe_name is None and serial_number is None, (
@@ -1166,8 +1175,8 @@ def read_openephys(
11661175
return None
11671176
else:
11681177
raise Exception(
1169-
"More than one probe found. Use one of 'stream_name', 'probe_name', or 'serial_number' "
1170-
"to select the right probe"
1178+
f"More than one probe found. Use one of 'stream_name', 'probe_name', or 'serial_number' "
1179+
f"to select the right probe.\nProbe names: {probe_names}"
11711180
)
11721181
else:
11731182
# in case of a single probe, make sure it is consistent with optional
@@ -1205,7 +1214,6 @@ def read_openephys(
12051214
np_probe = np_probes[probe_idx]
12061215
positions = np_probe_info["positions"]
12071216
shank_ids = np_probe_info["shank_ids"]
1208-
pname = np_probe_info["name"]
12091217

12101218
ptype = np_probe_info["ptype"]
12111219
if ptype in npx_descriptions:
@@ -1257,6 +1265,7 @@ def read_openephys(
12571265
probe.set_contact_ids(contact_ids)
12581266

12591267
polygon = polygon_contour_description[contour_description]
1268+
contour_shift = np.array(npx_descriptions[ptype]["contour_shift"])
12601269
if shank_ids is None:
12611270
contour = polygon
12621271
else:
@@ -1265,7 +1274,7 @@ def read_openephys(
12651274
contour += list(np.array(polygon) + [shank_pitch * i, 0])
12661275

12671276
# shift
1268-
contour = np.array(contour) - x_shift
1277+
contour = np.array(contour) + contour_shift
12691278
probe.set_planar_contour(contour)
12701279

12711280
# wire it

0 commit comments

Comments
 (0)