Skip to content

Commit b3f3542

Browse files
authored
Merge pull request #349 from chrishalcrow/use-mux-tables
Use ProbeTable to generate NP probes information
2 parents cbb8653 + 9bf8f15 commit b3f3542

File tree

7 files changed

+2484
-643
lines changed

7 files changed

+2484
-643
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Sync neuropixels_probe_features from ProbeTable
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * 1' # Every Monday at 00:00 UTC
6+
workflow_dispatch:
7+
8+
jobs:
9+
copy-file:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout current repository
14+
uses: actions/checkout@v4
15+
16+
- name: Copy file from external repo
17+
run: |
18+
# Download the file directly
19+
curl -o src/probeinterface/resources/neuropixels_probe_features.json \
20+
https://raw.githubusercontent.com/billkarsh/ProbeTable/refs/heads/main/Tables/probe_features.json
21+
22+
- name: Commit changes if any
23+
run: |
24+
git config --local user.email "[email protected]"
25+
git config --local user.name "GitHub Action"
26+
27+
git add src/probeinterface/resources/neuropixels_probe_features.json
28+
29+
# Only commit if there are changes
30+
git diff --staged --quiet || git commit -m "Update neuropixels_probe_features from ProbeTable"
31+
git push

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ tests/*.prb
44
tests/*.json
55
tests/*/*.prb
66

7-
*.json
87
*.prb
98
tests/*/*.json
109
tests/*/*.tsv

resources/generate_neuropixels_library.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import shutil
22
from pathlib import Path
33

4+
import json
5+
46
import numpy as np
57
import 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
810
from probeinterface.plotting import plot_probe
911
from 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-
105104
if __name__ == "__main__":
106105
generate_all_npx()

0 commit comments

Comments
 (0)