Skip to content

Commit 1d98765

Browse files
committed
merge
2 parents 1f7dd02 + 7708184 commit 1d98765

File tree

3 files changed

+146
-11
lines changed

3 files changed

+146
-11
lines changed

probeinterface/io.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,7 @@ def write_csv(file, probe):
726726
# A map from probe type to geometry_parameters
727727
npx_probe = {
728728
# Neuropixels 1.0
729+
# This probably should be None or something else because NOT ONLY the neuropixels 1.0 have that imDatPrb_type
729730
0: {
730731
"probe_name": "Neuropixels 1.0",
731732
"x_pitch": 32,
@@ -798,7 +799,7 @@ def write_csv(file, probe):
798799
},
799800
# Neuropixels 1.0-NHP Short (10mm)
800801
1015: {
801-
"probe_name": "Neuropixels 1.0-NHP - medium",
802+
"probe_name": "Neuropixels 1.0-NHP - short",
802803
"x_pitch": 32,
803804
"y_pitch": 20,
804805
"contact_width": 12,
@@ -918,7 +919,19 @@ def write_csv(file, probe):
918919
},
919920
}
920921

921-
def read_imro(file):
922+
# Map imDatPrb_pn to imDatPrb_type when the latter is missing
923+
probe_number_to_probe_type = {
924+
"PRB_1_4_0480_1": 0,
925+
"PRB_1_4_0480_1_C": 0,
926+
"NP1015": 1015,
927+
"NP1022": 1022,
928+
"NP1030": 1030,
929+
"NP1031": 1031,
930+
"NP1032": 1032,
931+
}
932+
933+
934+
def read_imro(file: Union[str, Path]) -> Probe:
922935
"""
923936
Read probe position from the imro file used in input of SpikeGlx and Open-Ephys for neuropixels probes.
924937
@@ -940,7 +953,7 @@ def read_imro(file):
940953
return _read_imro_string(imro_str)
941954

942955

943-
def _read_imro_string(imro_str: str) -> Probe:
956+
def _read_imro_string(imro_str: str, imDatPrb_pn: str = None) -> Probe:
944957
"""
945958
Low-level function to parse the imro table when presented as a string
946959
@@ -959,6 +972,9 @@ def _read_imro_string(imro_str: str) -> Probe:
959972
else:
960973
raise RuntimeError(f'read_imro error, the header has a strange length: {len(header)}')
961974

975+
if imDatPrb_type in [0, None]:
976+
imDatPrb_type = probe_number_to_probe_type[imDatPrb_pn]
977+
962978
probe_information = npx_probe[imDatPrb_type]
963979
fields = probe_information["fields_in_imro_table"]
964980
contact_info = {k: [] for k in fields}
@@ -977,10 +993,9 @@ def _read_imro_string(imro_str: str) -> Probe:
977993

978994

979995
# compute position
980-
x_idx = elec_ids % probe_information["ncol"]
981-
y_idx = elec_ids // probe_information["ncol"]
982-
x_pitch = probe_information["x_pitch"]
983-
y_pitch = probe_information["y_pitch"]
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"]
984999

9851000
stagger = np.mod(y_idx + 1, 2) * probe_information["stagger"]
9861001
x_pos = x_idx * x_pitch + stagger
@@ -1106,8 +1121,9 @@ def read_spikeglx(file: Union[str, Path]) -> Probe:
11061121

11071122
assert "imroTbl" in meta, "Could not find imroTbl field in meta file!"
11081123
imro_table = meta['imroTbl']
1124+
imDatPrb_pn = meta.get("imDatPrb_pn", None)
11091125

1110-
probe = _read_imro_string(imro_table)
1126+
probe = _read_imro_string(imro_str=imro_table, imDatPrb_pn=imDatPrb_pn)
11111127

11121128
# sometimes we need to slice the probe when not all channels are saved
11131129
saved_chans = get_saved_channel_indices_from_spikeglx_meta(meta_file)

0 commit comments

Comments
 (0)