11import shutil
22from pathlib import Path
33
4+ import json
5+
46import numpy as np
57import matplotlib .pyplot as plt
68
7- from probeinterface .neuropixels_tools import npx_descriptions , probe_part_number_to_probe_type , _make_npx_probe_from_description
9+ from probeinterface .neuropixels_tools import _make_npx_probe_from_description , get_probe_metadata_from_probe_features
810from probeinterface .plotting import plot_probe
911from probeinterface import write_probeinterface
1012
@@ -18,35 +20,35 @@ def generate_all_npx():
1820 # if not base_folder.exists():
1921 base_folder .mkdir (exist_ok = True )
2022
23+ probe_features_filepath = Path (__file__ ).absolute ().parent / Path ("../src/probeinterface/resources/neuropixels_probe_features.json" )
24+ probe_features = json .load (open (probe_features_filepath , "r" ))
25+ probe_part_numbers = probe_features ['neuropixels_probes' ].keys ()
26+
2127
22- for probe_number , probe_type in probe_part_number_to_probe_type . items () :
28+ for probe_number in probe_part_numbers :
2329
2430 if probe_number is None :
2531 continue
2632
27- if probe_number == "1110 " :
33+ if probe_number == "NP1110 " :
2834 # the formula by the imrow table is wrong and more complicated
2935 continue
3036
3137 probe_folder = base_folder / probe_number
3238 probe_folder .mkdir (exist_ok = True )
3339
34- print (probe_number , probe_type )
35-
36- probe_description = npx_descriptions [probe_type ]
37-
40+ pt_metadata , _ , _ = get_probe_metadata_from_probe_features (probe_features , probe_number )
3841
39-
40- num_shank = probe_description ["shank_number" ]
41- contact_per_shank = probe_description ["ncols_per_shank" ] * probe_description ["nrows_per_shank" ]
42+ num_shank = pt_metadata ["num_shanks" ]
43+ contact_per_shank = pt_metadata ["cols_per_shank" ] * pt_metadata ["rows_per_shank" ]
4244 if num_shank == 1 :
4345 elec_ids = np .arange (contact_per_shank )
4446 shank_ids = None
4547 else :
4648 elec_ids = np .concatenate ([np .arange (contact_per_shank ) for i in range (num_shank )])
4749 shank_ids = np .concatenate ([np .zeros (contact_per_shank ) + i for i in range (num_shank )])
4850
49- probe = _make_npx_probe_from_description (probe_description , elec_ids , shank_ids )
51+ probe = _make_npx_probe_from_description (pt_metadata , elec_ids , shank_ids )
5052
5153 # ploting
5254 fig , axs = plt .subplots (ncols = 2 )
@@ -67,7 +69,7 @@ def generate_all_npx():
6769 plot_probe (probe , ax = ax )
6870 ax .set_title ("" )
6971
70- yp = probe_description [ "y_pitch " ]
72+ yp = pt_metadata [ "electrode_pitch_vert_um " ]
7173 ax .set_ylim (- yp * 8 , yp * 13 )
7274 ax .yaxis .set_visible (False )
7375 ax .spines ["top" ].set_visible (False )
@@ -99,8 +101,5 @@ def generate_all_npx():
99101
100102
101103
102-
103-
104-
105104if __name__ == "__main__" :
106105 generate_all_npx ()
0 commit comments