|
483 | 483 | None: "0",
|
484 | 484 | # NP1.0
|
485 | 485 | "PRB_1_4_0480_1": "0",
|
486 |
| - "PRB_1_4_0480_1_C": "0", |
| 486 | + "PRB_1_4_0480_1_C": "0", # This is the metal cap version |
487 | 487 | "PRB_1_2_0480_2": "0",
|
488 | 488 | "NP1010": "0",
|
489 | 489 | # NHP probes lin
|
@@ -1090,36 +1090,51 @@ def read_openephys(
|
1090 | 1090 | raise NotImplementedError(f"Probe part number {probe_part_number} is not supported yet")
|
1091 | 1091 | ptype = probe_part_number_to_probe_type[probe_part_number]
|
1092 | 1092 |
|
| 1093 | + probe_dict = npx_descriptions[ptype] |
| 1094 | + shank_pitch = probe_dict["shank_pitch"] |
| 1095 | + |
1093 | 1096 | if fix_x_position_for_oe_5 and oe_version < parse("0.6.0") and shank_ids is not None:
|
1094 |
| - positions[:, 1] = positions[:, 1] - npx_descriptions[ptype]["shank_pitch"] * shank_ids |
| 1097 | + positions[:, 1] = positions[:, 1] - shank_pitch * shank_ids |
1095 | 1098 |
|
1096 | 1099 | # x offset so that the first column is at 0x
|
1097 | 1100 | offset = np.min(positions[:, 0])
|
1098 | 1101 | # if some shanks are not used, we need to adjust the offset
|
1099 | 1102 | if shank_ids is not None:
|
1100 |
| - offset -= np.min(shank_ids) * npx_descriptions[ptype]["shank_pitch"] |
| 1103 | + offset -= np.min(shank_ids) * shank_pitch |
1101 | 1104 | positions[:, 0] -= offset
|
1102 | 1105 |
|
1103 | 1106 | contact_ids = []
|
| 1107 | + y_pitch = probe_dict["y_pitch"] # Vertical spacing between the centers of adjacent contacts |
| 1108 | + x_pitch = probe_dict["x_pitch"] # Horizontal spacing between the centers of contacts within the same row |
| 1109 | + number_of_columns = probe_dict["ncol"] |
| 1110 | + probe_stagger = probe_dict["stagger"] |
| 1111 | + shank_number = probe_dict["shank_number"] |
| 1112 | + |
1104 | 1113 | for i, pos in enumerate(positions):
|
| 1114 | + # Do not calculate contact ids if the probe type is not known |
1105 | 1115 | if ptype is None:
|
1106 | 1116 | contact_ids = None
|
1107 | 1117 | break
|
1108 | 1118 |
|
1109 |
| - stagger = np.mod(pos[1] / npx_descriptions[ptype]["y_pitch"] + 1, 2) * npx_descriptions[ptype]["stagger"] |
1110 |
| - shank_id = shank_ids[i] if npx_descriptions[ptype]["shank_number"] > 1 else 0 |
| 1119 | + x_pos = pos[0] |
| 1120 | + y_pos = pos[1] |
| 1121 | + |
| 1122 | + # Adds a shift to rows in the staggered configuration |
| 1123 | + is_row_staggered = np.mod(y_pos / y_pitch + 1, 2) == 1 |
| 1124 | + row_stagger = probe_stagger if is_row_staggered else 0 |
| 1125 | + |
| 1126 | + # Map the positions to the contacts ids |
| 1127 | + shank_id = shank_ids[i] if shank_number > 1 else 0 |
1111 | 1128 |
|
1112 | 1129 | contact_id = int(
|
1113 |
| - (pos[0] - stagger - npx_descriptions[ptype]["shank_pitch"] * shank_id) |
1114 |
| - / npx_descriptions[ptype]["x_pitch"] |
1115 |
| - + npx_descriptions[ptype]["ncols_per_shank"] * pos[1] / npx_descriptions[ptype]["y_pitch"] |
| 1130 | + (x_pos - row_stagger - shank_pitch * shank_id) / x_pitch + number_of_columns * y_pos / y_pitch |
1116 | 1131 | )
|
1117 |
| - if npx_descriptions[ptype]["shank_number"] > 1: |
| 1132 | + if shank_number > 1: |
1118 | 1133 | contact_ids.append(f"s{shank_id}e{contact_id}")
|
1119 | 1134 | else:
|
1120 | 1135 | contact_ids.append(f"e{contact_id}")
|
1121 | 1136 |
|
1122 |
| - model_name = npx_descriptions[ptype]["model_name"] if ptype is not None else "Unknown" |
| 1137 | + model_name = probe_dict["model_name"] if ptype is not None else "Unknown" |
1123 | 1138 | np_probe_dict = {
|
1124 | 1139 | "model_name": model_name,
|
1125 | 1140 | "shank_ids": shank_ids,
|
@@ -1230,10 +1245,9 @@ def read_openephys(
|
1230 | 1245 |
|
1231 | 1246 | ptype = np_probe_info["ptype"]
|
1232 | 1247 | if ptype in npx_descriptions:
|
1233 |
| - contact_width = npx_descriptions[ptype]["contact_width"] |
1234 |
| - shank_pitch = npx_descriptions[ptype]["shank_pitch"] |
1235 |
| - num_shanks = npx_descriptions[ptype]["shank_number"] |
1236 |
| - contour_description = npx_descriptions[ptype]["contour_description"] |
| 1248 | + contact_width = probe_dict["contact_width"] |
| 1249 | + num_shanks = probe_dict["shank_number"] |
| 1250 | + contour_description = probe_dict["contour_description"] |
1237 | 1251 | else:
|
1238 | 1252 | contact_width = 12
|
1239 | 1253 | shank_pitch = 250
|
@@ -1278,7 +1292,7 @@ def read_openephys(
|
1278 | 1292 | probe.set_contact_ids(contact_ids)
|
1279 | 1293 |
|
1280 | 1294 | polygon = polygon_contour_description[contour_description]
|
1281 |
| - contour_shift = np.array(npx_descriptions[ptype]["contour_shift"]) |
| 1295 | + contour_shift = np.array(probe_dict["contour_shift"]) |
1282 | 1296 | if shank_ids is None:
|
1283 | 1297 | contour = polygon
|
1284 | 1298 | else:
|
|
0 commit comments