@@ -726,6 +726,7 @@ def write_csv(file, probe):
726
726
# A map from probe type to geometry_parameters
727
727
npx_probe = {
728
728
# Neuropixels 1.0
729
+ # This probably should be None or something else because NOT ONLY the neuropixels 1.0 have that imDatPrb_type
729
730
0 : {
730
731
"probe_name" : "Neuropixels 1.0" ,
731
732
"x_pitch" : 32 ,
@@ -798,7 +799,7 @@ def write_csv(file, probe):
798
799
},
799
800
# Neuropixels 1.0-NHP Short (10mm)
800
801
1015 : {
801
- "probe_name" : "Neuropixels 1.0-NHP - medium " ,
802
+ "probe_name" : "Neuropixels 1.0-NHP - short " ,
802
803
"x_pitch" : 32 ,
803
804
"y_pitch" : 20 ,
804
805
"contact_width" : 12 ,
@@ -918,7 +919,19 @@ def write_csv(file, probe):
918
919
},
919
920
}
920
921
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 :
922
935
"""
923
936
Read probe position from the imro file used in input of SpikeGlx and Open-Ephys for neuropixels probes.
924
937
@@ -940,7 +953,7 @@ def read_imro(file):
940
953
return _read_imro_string (imro_str )
941
954
942
955
943
- def _read_imro_string (imro_str : str ) -> Probe :
956
+ def _read_imro_string (imro_str : str , imDatPrb_pn : str = None ) -> Probe :
944
957
"""
945
958
Low-level function to parse the imro table when presented as a string
946
959
@@ -959,6 +972,9 @@ def _read_imro_string(imro_str: str) -> Probe:
959
972
else :
960
973
raise RuntimeError (f'read_imro error, the header has a strange length: { len (header )} ' )
961
974
975
+ if imDatPrb_type in [0 , None ]:
976
+ imDatPrb_type = probe_number_to_probe_type [imDatPrb_pn ]
977
+
962
978
probe_information = npx_probe [imDatPrb_type ]
963
979
fields = probe_information ["fields_in_imro_table" ]
964
980
contact_info = {k : [] for k in fields }
@@ -977,10 +993,9 @@ def _read_imro_string(imro_str: str) -> Probe:
977
993
978
994
979
995
# 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" ]
984
999
985
1000
stagger = np .mod (y_idx + 1 , 2 ) * probe_information ["stagger" ]
986
1001
x_pos = x_idx * x_pitch + stagger
@@ -1106,8 +1121,9 @@ def read_spikeglx(file: Union[str, Path]) -> Probe:
1106
1121
1107
1122
assert "imroTbl" in meta , "Could not find imroTbl field in meta file!"
1108
1123
imro_table = meta ['imroTbl' ]
1124
+ imDatPrb_pn = meta .get ("imDatPrb_pn" , None )
1109
1125
1110
- probe = _read_imro_string (imro_table )
1126
+ probe = _read_imro_string (imro_str = imro_table , imDatPrb_pn = imDatPrb_pn )
1111
1127
1112
1128
# sometimes we need to slice the probe when not all channels are saved
1113
1129
saved_chans = get_saved_channel_indices_from_spikeglx_meta (meta_file )
0 commit comments