@@ -723,10 +723,10 @@ def write_csv(file, probe):
723
723
],
724
724
}
725
725
726
- # A map from probe type to geometry_parameters
727
726
# A map from probe type to geometry_parameters
728
727
npx_probe = {
729
728
# Neuropixels 1.0
729
+ # This probably should be None or something else because NOT ONLY the neuropixels 1.0 have that imDatPrb_type
730
730
0 : {
731
731
"probe_name" : "Neuropixels 1.0" ,
732
732
"x_pitch" : 32 ,
@@ -808,7 +808,7 @@ def write_csv(file, probe):
808
808
},
809
809
# Neuropixels 1.0-NHP Short (10mm)
810
810
1015 : {
811
- "probe_name" : "Neuropixels 1.0-NHP - medium " ,
811
+ "probe_name" : "Neuropixels 1.0-NHP - short " ,
812
812
"x_pitch" : 32 ,
813
813
"y_pitch" : 20 ,
814
814
"contact_width" : 12 ,
@@ -908,7 +908,19 @@ def write_csv(file, probe):
908
908
},
909
909
}
910
910
911
- def read_imro (file ):
911
+ # Map imDatPrb_pn to imDatPrb_type when the latter is missing
912
+ probe_number_to_probe_type = {
913
+ "PRB_1_4_0480_1" : 0 ,
914
+ "PRB_1_4_0480_1_C" : 0 ,
915
+ "NP1015" : 1015 ,
916
+ "NP1022" : 1022 ,
917
+ "NP1030" : 1030 ,
918
+ "NP1031" : 1031 ,
919
+ "NP1032" : 1032 ,
920
+ }
921
+
922
+
923
+ def read_imro (file : Union [str , Path ]) -> Probe :
912
924
"""
913
925
Read probe position from the imro file used in input of SpikeGlx and Open-Ephys for neuropixels probes.
914
926
@@ -930,7 +942,7 @@ def read_imro(file):
930
942
return _read_imro_string (imro_str )
931
943
932
944
933
- def _read_imro_string (imro_str : str ) -> Probe :
945
+ def _read_imro_string (imro_str : str , imDatPrb_pn : str = None ) -> Probe :
934
946
"""
935
947
Low-level function to parse the imro table when presented as a string
936
948
@@ -949,6 +961,9 @@ def _read_imro_string(imro_str: str) -> Probe:
949
961
else :
950
962
raise RuntimeError (f'read_imro error, the header has a strange length: { len (header )} ' )
951
963
964
+ if imDatPrb_type in [0 , None ]:
965
+ imDatPrb_type = probe_number_to_probe_type [imDatPrb_pn ]
966
+
952
967
fields = npx_probe [imDatPrb_type ]["fields_in_imro_table" ]
953
968
contact_info = {k : [] for k in fields }
954
969
for i , part in enumerate (parts ):
@@ -966,8 +981,7 @@ def _read_imro_string(imro_str: str) -> Probe:
966
981
elec_ids = banks * 384 + channel_ids
967
982
968
983
# compute position
969
- x_idx = elec_ids % npx_probe [imDatPrb_type ]["ncol" ]
970
- y_idx = elec_ids // npx_probe [imDatPrb_type ]["ncol" ]
984
+ y_idx , x_idx = np .divmod (elec_ids , npx_probe [imDatPrb_type ]["ncol" ])
971
985
x_pitch = npx_probe [imDatPrb_type ]["x_pitch" ]
972
986
y_pitch = npx_probe [imDatPrb_type ]["y_pitch" ]
973
987
@@ -1000,7 +1014,7 @@ def _read_imro_string(imro_str: str) -> Probe:
1000
1014
for shank_id in range (npx_probe [imDatPrb_type ]["shank_number" ]):
1001
1015
shift = [npx_probe [imDatPrb_type ]["shank_pitch" ] * shank_id , 0 ]
1002
1016
contour += list (polygon + shift )
1003
-
1017
+
1004
1018
# shift
1005
1019
contour = np .array (contour ) - [11 , 11 ]
1006
1020
probe .set_planar_contour (contour )
@@ -1094,8 +1108,9 @@ def read_spikeglx(file: Union[str, Path]) -> Probe:
1094
1108
1095
1109
assert "imroTbl" in meta , "Could not find imroTbl field in meta file!"
1096
1110
imro_table = meta ['imroTbl' ]
1111
+ imDatPrb_pn = meta .get ("imDatPrb_pn" , None )
1097
1112
1098
- probe = _read_imro_string (imro_table )
1113
+ probe = _read_imro_string (imro_str = imro_table , imDatPrb_pn = imDatPrb_pn )
1099
1114
1100
1115
# sometimes we need to slice the probe when not all channels are saved
1101
1116
saved_chans = get_saved_channel_indices_from_spikeglx_meta (meta_file )
0 commit comments