Skip to content

Commit b770303

Browse files
authored
Auto build cambridge library - add dependencies and new probes (#39)
* debug * Add dependencies * Add dependencies 2 * Fix args * Fix script * Unify check_for_new_probes and add to generate CN action * Fix check new probes script
1 parent b430ccf commit b770303

File tree

5 files changed

+53
-24
lines changed

5 files changed

+53
-24
lines changed

.github/workflows/check_for_new_NP_probes.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,14 @@ jobs:
3232
- name: Install probeinterface and matplotlib
3333
run: pip install ./probeinterface matplotlib
3434

35-
- name: Generate full NP library
35+
- name: Generate full NP library and check for new probes
3636
run: |
3737
cd scripts/
3838
python ../probeinterface/resources/generate_neuropixels_library.py
39+
# check for new probes
40+
python check_for_new_probes.py ../imec/ ./neuropixels_library_generated/
3941
40-
# Check for any new probes
41-
- name: Run local script
42-
run: |
43-
cd scripts/
44-
python check_for_new_NP_probes.py
42+
# clean up
4543
rm -r neuropixels_library_generated/
4644
cd ..
4745
rm -r ./probeinterface

.github/workflows/generate_cambridge_neurotech_library.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,19 @@ jobs:
3333
# cambridge neurotech probe maps
3434
git clone https://github.com/cambridge-neurotech/probe_maps.git ./probe_maps
3535
36-
- name: Install probeinterface and matplotlib
37-
run: pip install ./probeinterface matplotlib
36+
- name: Install probeinterface and dependencies
37+
run: pip install ./probeinterface matplotlib pandas shapely openpyxl tqdm
3838

3939
- name: Generate full cambridge library and check for changes
4040
run: |
4141
cd scripts/
42-
python ../probeinterface/resources/generate_cambridgeneurotech_library.py ../probe_maps/ ./cambridge_library_generated/
42+
python ../probeinterface/resources/generate_cambridgeneurotech_library.py ../probe_maps/ --output-folder ./cambridge_library_generated/
43+
44+
# check for new probes
45+
python check_for_new_probes.py ../cambridgeneurotech/ ./cambridge_library_generated/
4346
4447
# check for json changes (except probeinterface version)
45-
python check_for_json_changes_in_probes.py ../cambridgeneurotech/ ./cambridge_library_generated/
48+
python check_for_json_changes_in_probes.py ../cambridgeneurotech/ ./cambridge_library_generated/ --copy-figures
4649
# clean up
4750
rm -r cambridge_library_generated/
4851
cd ..
@@ -61,7 +64,7 @@ jobs:
6164
echo "No changes to commit"
6265
echo "changes=false" >> $GITHUB_OUTPUT
6366
else
64-
git commit -m "Update json files for NP probes"
67+
git commit -m "Update json files for cambridge neurotech probes"
6568
echo "changes=true" >> $GITHUB_OUTPUT
6669
fi
6770
@@ -70,6 +73,6 @@ jobs:
7073
uses: peter-evans/create-pull-request@v7
7174
with:
7275
title: "Update Cambridge Neurotech json files"
73-
body: "This PR updates the Neuropixel probes in probeinterace library, based on new data from the ProbeTable repository or because of a new ProbeInterface release."
76+
body: "This PR updates the Cambridge Neurotech probes in probeinterace library, based on new data from the cambridge-neurotech/probe_maps repository or because of a new ProbeInterface release."
7477
branch-suffix: short-commit-hash
7578
base: "main"

scripts/check_for_json_changes_in_probes.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
help="Path to the new probes directory",
1818
)
1919

20+
parser.add_argument(
21+
"--copy-figures",
22+
action="store_true",
23+
help="If set, copies figures as well when JSON files are different.",
24+
)
25+
2026

2127
if __name__ == "__main__":
2228
args = parser.parse_args()
@@ -40,5 +46,11 @@
4046
if lines1[3:] == lines2[3:]:
4147
continue
4248
else:
43-
shutil.copy(f"{temp_probe_json_path}", f"../imec/{probe_name}")
49+
shutil.copy(f"{temp_probe_json_path}", old_dir / probe_name)
50+
if args.copy_figures:
51+
temp_figure_path = temp_probe_directory / (probe_name + '.png')
52+
shutil.copy(f"{temp_figure_path}", old_dir / probe_name)
53+
54+
55+
4456

scripts/check_for_new_NP_probes.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

scripts/check_for_new_probes.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from argparse import ArgumentParser
2+
from pathlib import Path
3+
import shutil
4+
5+
6+
parser = ArgumentParser(description="Check for new probes from manufacturer")
7+
parser.add_argument(
8+
"old_dir",
9+
type=str,
10+
help="Path to the old probes directory",
11+
)
12+
parser.add_argument(
13+
"new_dir",
14+
type=str,
15+
help="Path to the new probes directory",
16+
)
17+
18+
if __name__ == "__main__":
19+
args = parser.parse_args()
20+
old_dir = Path(args.old_dir)
21+
new_dir = Path(args.new_dir)
22+
23+
existing_probes = list(probe_path.name for probe_path in old_dir.iterdir())
24+
25+
for temp_probe_path in new_dir.iterdir():
26+
if temp_probe_path.name not in existing_probes:
27+
shutil.copytree(temp_probe_path, old_dir / temp_probe_path.name)

0 commit comments

Comments
 (0)