|
10 | 10 |
|
11 | 11 | import numpy as np |
12 | 12 |
|
13 | | -from probeinterface import generate_multi_columns_probe |
| 13 | +from probeinterface import generate_multi_columns_probe, get_probe, generate_tetrode |
14 | 14 |
|
15 | 15 | from spikeinterface import Templates |
16 | 16 | from spikeinterface.core import ms_to_samples |
|
24 | 24 | from .drift_tools import DriftingTemplates, make_linear_displacement, InjectDriftingTemplatesRecording |
25 | 25 | from .noise_tools import generate_noise |
26 | 26 |
|
27 | | -# this should be moved in probeinterface but later |
28 | | -_toy_probes = { |
29 | | - "Neuropixels1-384": dict( |
30 | | - num_columns=4, |
31 | | - num_contact_per_column=[96] * 4, |
32 | | - xpitch=16, |
33 | | - ypitch=40, |
34 | | - y_shift_per_column=[20, 0, 20, 0], |
35 | | - contact_shapes="square", |
36 | | - contact_shape_params={"width": 12}, |
37 | | - ), |
38 | | - "Neuropixels2-384": dict( |
39 | | - num_columns=2, |
40 | | - num_contact_per_column=[192] * 2, |
41 | | - xpitch=32, |
42 | | - ypitch=15, |
43 | | - contact_shapes="square", |
44 | | - contact_shape_params={"width": 12}, |
45 | | - ), |
46 | | - "Neuropixels2-128": dict( |
47 | | - num_columns=2, |
48 | | - num_contact_per_column=[64] * 2, |
49 | | - xpitch=32, |
50 | | - ypitch=15, |
51 | | - contact_shapes="square", |
52 | | - contact_shape_params={"width": 12}, |
53 | | - ), |
54 | | - "Neuropixels1-128": dict( |
55 | | - num_columns=4, |
56 | | - num_contact_per_column=[32] * 4, |
57 | | - xpitch=16, |
58 | | - ypitch=40, |
59 | | - y_shift_per_column=[20, 0, 20, 0], |
60 | | - contact_shapes="square", |
61 | | - contact_shape_params={"width": 12}, |
62 | | - ), |
63 | | - "Neuronexus-32": dict( |
64 | | - num_columns=3, |
65 | | - num_contact_per_column=[10, 12, 10], |
66 | | - xpitch=30, |
67 | | - ypitch=30, |
68 | | - y_shift_per_column=[0, -15, 0], |
69 | | - contact_shapes="circle", |
70 | | - contact_shape_params={"radius": 8}, |
71 | | - ), |
72 | | -} |
| 27 | + |
| 28 | +def _make_probe_by_name(probe_name: str): |
| 29 | + """ |
| 30 | + Generates a probe from probeinterface library, using the manufacturer name combined with the probe name, e.g. |
| 31 | + - 'cambridgeneurotech/ASSY-37-H7b' |
| 32 | + - 'cambridgeneurotech#ASSY-37-H7b' |
| 33 | + - 'imec#NP1000" |
| 34 | +
|
| 35 | + This function replace the old `_toy_probes` dict that generate probe using `generate_multi_columns_probe()` |
| 36 | + """ |
| 37 | + if probe_name == "Neuropixels1-384": |
| 38 | + probe = get_probe("imec", "NP1000") |
| 39 | + probe = probe.get_slice(np.arange(384)) |
| 40 | + elif probe_name == "Neuropixels1-128": |
| 41 | + probe = get_probe("imec", "NP1000") |
| 42 | + probe = probe.get_slice(np.arange(128)) |
| 43 | + elif probe_name == "Neuropixels2-384": |
| 44 | + probe = get_probe("imec", "NP2000") |
| 45 | + probe = probe.get_slice(np.arange(384)) |
| 46 | + elif probe_name == "Neuropixels2-128": |
| 47 | + probe = get_probe("imec", "NP2000") |
| 48 | + probe = probe.get_slice(np.arange(128)) |
| 49 | + elif probe_name == "Neuronexus-32": |
| 50 | + # this probe was not existing really, it was a 'generic' 32 channels |
| 51 | + # lets keep as before |
| 52 | + probe = generate_multi_columns_probe( |
| 53 | + num_columns=3, |
| 54 | + num_contact_per_column=[10, 12, 10], |
| 55 | + xpitch=30, |
| 56 | + ypitch=30, |
| 57 | + y_shift_per_column=[0, -15, 0], |
| 58 | + contact_shapes="circle", |
| 59 | + contact_shape_params={"radius": 8}, |
| 60 | + ) |
| 61 | + elif probe_name == "tetrode": |
| 62 | + probe = generate_tetrode() |
| 63 | + elif probe_name == "sinaps-128": |
| 64 | + probe = get_probe("sinaps-research-platform", "p1024s1NHP") |
| 65 | + order = np.argsort(probe.contact_ids.astype("int64")) |
| 66 | + probe = probe.get_slice(order[:128]) |
| 67 | + elif "/" in probe_name: |
| 68 | + manufacturer, probe_name_ = probe_name.split("/") |
| 69 | + probe = get_probe(manufacturer, probe_name_) |
| 70 | + elif "#" in probe_name: |
| 71 | + manufacturer, probe_name_ = probe_name.split("#") |
| 72 | + probe = get_probe(manufacturer, probe_name_) |
| 73 | + else: |
| 74 | + raise ValueError("wring probe_name") |
| 75 | + |
| 76 | + return probe |
73 | 77 |
|
74 | 78 |
|
75 | 79 | def make_one_displacement_vector( |
@@ -449,10 +453,11 @@ def generate_drifting_recording( |
449 | 453 |
|
450 | 454 | # probe |
451 | 455 | if probe is None: |
452 | | - if generate_probe_kwargs is None: |
453 | | - generate_probe_kwargs = _toy_probes[probe_name] |
454 | | - |
455 | | - probe = generate_multi_columns_probe(**generate_probe_kwargs) |
| 456 | + if generate_probe_kwargs is not None: |
| 457 | + probe = generate_multi_columns_probe(**generate_probe_kwargs) |
| 458 | + else: |
| 459 | + probe = _make_probe_by_name(probe_name) |
| 460 | + # the wiring do not matter because the traces are generated after using the channel locations |
456 | 461 | num_channels = probe.get_contact_count() |
457 | 462 | probe.set_device_channel_indices(np.arange(num_channels)) |
458 | 463 |
|
|
0 commit comments