Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor neuropixel in a separate file and generate the NP library. #316

Merged
merged 20 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7ad70a6
Refactor neuropixel in a separate file and generate the library.
samuelgarcia Jan 21, 2025
97a63eb
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 21, 2025
61b3848
Read the "snsGeomMap" fields when possible for testing.
samuelgarcia Jan 21, 2025
d5364eb
Merge branch 'neuropixel' of github.com:samuelgarcia/probeinterface i…
samuelgarcia Jan 21, 2025
0061b00
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 21, 2025
8f8bdd1
more clean in neuropixel lib
samuelgarcia Jan 22, 2025
d97326d
Merge branch 'neuropixel' of github.com:samuelgarcia/probeinterface i…
samuelgarcia Jan 22, 2025
7ec57af
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 22, 2025
36e7ba2
rename
samuelgarcia Jan 22, 2025
9faa702
rename
samuelgarcia Jan 22, 2025
17f03a5
Merge branch 'neuropixel' of github.com:samuelgarcia/probeinterface i…
samuelgarcia Jan 22, 2025
9a1ce25
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 22, 2025
f7182a0
Add the shank tips
samuelgarcia Jan 22, 2025
4e35e1e
Merge branch 'neuropixel' of github.com:samuelgarcia/probeinterface i…
samuelgarcia Jan 22, 2025
d9bb7a1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 22, 2025
b236a9e
Fix open ephys contour and change contour->contour_description in npx…
alejoe91 Jan 22, 2025
9ad2629
Fix tests
alejoe91 Jan 22, 2025
27c77e2
more clean
samuelgarcia Jan 27, 2025
c34dc70
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 27, 2025
b5efca3
Update src/probeinterface/neuropixels_tools.py
alejoe91 Jan 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ dev_*
.coverage
cov.xml
.DS_Store


neuropixel_library_generated/*
106 changes: 106 additions & 0 deletions resources/generate_neuropixels_library.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import shutil
from pathlib import Path

import numpy as np
import matplotlib.pyplot as plt

from probeinterface.neuropixels_tools import npx_descriptions, probe_part_number_to_probe_type, _make_npx_probe_from_description
from probeinterface.plotting import plot_probe
from probeinterface import write_probeinterface


base_folder = Path("./neuropixels_library_generated")



def generate_all_npx():

# if not base_folder.exists():
base_folder.mkdir(exist_ok=True)


for probe_number, probe_type in probe_part_number_to_probe_type.items():

if probe_number is None:
continue

if probe_number == "1110":
# the formula by the imrow table is wrong and more complicated
continue

probe_folder = base_folder / probe_number
probe_folder.mkdir(exist_ok=True)

print(probe_number, probe_type)

probe_description = npx_descriptions[probe_type]



num_shank = probe_description["shank_number"]
contact_per_shank = probe_description["ncols_per_shank"] * probe_description["nrows_per_shank"]
if num_shank == 1:
elec_ids = np.arange(contact_per_shank)
shank_ids = None
else:
elec_ids = np.concatenate([np.arange(contact_per_shank) for i in range(num_shank)])
shank_ids = np.concatenate([np.zeros(contact_per_shank) + i for i in range(num_shank)])

probe = _make_npx_probe_from_description(probe_description, elec_ids, shank_ids)

# ploting
fig, axs = plt.subplots(ncols=2)

ax = axs[0]
plot_probe(probe, ax=ax)
ax.set_title("")

ax.xaxis.set_visible(False)
ax.spines["top"].set_visible(False)
ax.spines["right"].set_visible(False)
ax.spines["bottom"].set_visible(False)

ax = axs[1]


# plot_probe(probe, ax=ax, text_on_contact=probe._contact_ids)
plot_probe(probe, ax=ax)
ax.set_title("")

yp = probe_description["y_pitch"]
ax.set_ylim(-yp*8, yp*13)
ax.yaxis.set_visible(False)
ax.spines["top"].set_visible(False)
ax.spines["right"].set_visible(False)
ax.spines["left"].set_visible(False)

n = probe.get_contact_count()

title = probe_number
title += f"\n{probe.manufacturer} - {probe.model_name}"
title += f"\n {n}ch"
if probe.shank_ids is not None:
num_shank = probe.get_shank_count()
title += f" - {num_shank}shanks"


fig.suptitle(title)

# plt.show()

fig.savefig(probe_folder / f"{probe_number}.png")

write_probeinterface(probe_folder / f"{probe_number}.json", probe)

plt.close(fig)









if __name__ == "__main__":
generate_all_npx()
15 changes: 9 additions & 6 deletions src/probeinterface/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,23 @@
write_prb,
read_csv,
write_csv,
read_imro,
write_imro,
read_BIDS_probe,
write_BIDS_probe,
read_spikegadgets,
read_mearec,
read_nwb,
read_maxwell,
read_3brain,
)
from .neuropixels_tools import (
read_imro,
write_imro,
read_spikeglx,
parse_spikeglx_meta,
parse_spikeglx_snsGeomMap,
get_saved_channel_indices_from_spikeglx_meta,
read_openephys,
get_saved_channel_indices_from_openephys_settings,
read_mearec,
read_nwb,
read_maxwell,
read_3brain,
)
from .utils import combine_probes
from .generator import (
Expand Down
Loading
Loading