Skip to content

Commit a32ed31

Browse files
committed
tests geometry
1 parent 1d98765 commit a32ed31

File tree

2 files changed

+27
-15
lines changed

2 files changed

+27
-15
lines changed

probeinterface/io.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -975,8 +975,8 @@ def _read_imro_string(imro_str: str, imDatPrb_pn: str = None) -> Probe:
975975
if imDatPrb_type in [0, None]:
976976
imDatPrb_type = probe_number_to_probe_type[imDatPrb_pn]
977977

978-
probe_information = npx_probe[imDatPrb_type]
979-
fields = probe_information["fields_in_imro_table"]
978+
probe_description = npx_probe[imDatPrb_type]
979+
fields = probe_description["fields_in_imro_table"]
980980
contact_info = {k: [] for k in fields}
981981
for i, part in enumerate(parts):
982982
values = tuple(map(int, part[1:].split(' ')))
@@ -991,13 +991,12 @@ def _read_imro_string(imro_str: str, imDatPrb_pn: str = None) -> Probe:
991991
else:
992992
elec_ids = np.array(contact_info['elec_ids'])
993993

994-
995994
# compute position
996-
y_idx, x_idx = np.divmod(elec_ids, npx_probe[imDatPrb_type]["ncol"])
997-
x_pitch = npx_probe[imDatPrb_type ]["x_pitch"]
998-
y_pitch = npx_probe[imDatPrb_type ]["y_pitch"]
995+
y_idx, x_idx = np.divmod(elec_ids, probe_description["ncol"])
996+
x_pitch = probe_description["x_pitch"]
997+
y_pitch = probe_description["y_pitch"]
999998

1000-
stagger = np.mod(y_idx + 1, 2) * probe_information["stagger"]
999+
stagger = np.mod(y_idx + 1, 2) * probe_description["stagger"]
10011000
x_pos = x_idx * x_pitch + stagger
10021001
y_pos = y_idx * y_pitch
10031002
positions = np.stack((x_pos, y_pos), axis=1)
@@ -1015,16 +1014,16 @@ def _read_imro_string(imro_str: str, imDatPrb_pn: str = None) -> Probe:
10151014
positions=positions,
10161015
shapes="square",
10171016
shank_ids=shank_ids,
1018-
shape_params={"width": probe_information["contact_width"]},
1017+
shape_params={"width": probe_description["contact_width"]},
10191018
)
10201019

10211020
probe.set_contact_ids(contact_ids)
10221021

10231022
# Add planar contour
1024-
polygon = np.array(probe_information["polygon"])
1023+
polygon = np.array(probe_description["polygon"])
10251024
contour = []
1026-
shank_pitch = probe_information["shank_pitch"]
1027-
for shank_id in range(probe_information["shank_number"]):
1025+
shank_pitch = probe_description["shank_pitch"]
1026+
for shank_id in range(probe_description["shank_number"]):
10281027
shift = [shank_pitch * shank_id, 0]
10291028
contour += list(polygon + shift)
10301029

@@ -1033,7 +1032,7 @@ def _read_imro_string(imro_str: str, imDatPrb_pn: str = None) -> Probe:
10331032
probe.set_planar_contour(contour)
10341033

10351034
# this is scalar annotations
1036-
probe_name = probe_information["probe_name"]
1035+
probe_name = probe_description["probe_name"]
10371036
probe.annotate(
10381037
name=probe_name,
10391038
manufacturer="IMEC",

tests/test_io/test_spikeglx.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,23 @@ def test_ultra_probe():
208208
assert probe.annotations["probe_type"] == 1100
209209

210210
# Test contact geometry
211-
x_pitch = 6.0
212-
y_pitch = 6.0
213211
contact_width = 5.0
214212
contact_shape = "square"
215213

216214
assert np.all(probe.contact_shape_params == {"width": contact_width})
217-
assert np.all(probe.contact_shapes == contact_shape)
215+
assert np.all(probe.contact_shapes == contact_shape)
216+
217+
contact_positions = probe.contact_positions
218+
x = contact_positions[:, 0]
219+
y = contact_positions[:, 1]
220+
221+
expected_electrode_columns = 8
222+
unique_x_values = np.unique(x)
223+
assert unique_x_values.size == expected_electrode_columns
224+
225+
expected_electode_rows = 48
226+
unique_y_values = np.unique(y)
227+
assert unique_y_values.size == expected_electode_rows
228+
229+
230+

0 commit comments

Comments
 (0)