.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/ex_04_multi_shank_probe.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_ex_04_multi_shank_probe.py: Multi shank probes ------------------ This example shows how to deal with multi-shank probes. In `probeinterface` this can be done with a `Probe` object, but internally each probe handles a `shank_ids` vector to carry information about which contacts belong to which shanks. Optionally, a :py:class:`Probe` object can be rendered split into :py:class:`Shank`. .. GENERATED FROM PYTHON SOURCE LINES 14-15 Import .. GENERATED FROM PYTHON SOURCE LINES 15-24 .. code-block:: Python import numpy as np import matplotlib.pyplot as plt from probeinterface import Probe, ProbeGroup from probeinterface import generate_linear_probe, generate_multi_shank from probeinterface import combine_probes from probeinterface.plotting import plot_probe .. GENERATED FROM PYTHON SOURCE LINES 25-26 Let's use a generator to create a multi-shank probe: .. GENERATED FROM PYTHON SOURCE LINES 26-31 .. code-block:: Python multi_shank = generate_multi_shank(num_shank=3, num_columns=2, num_contact_per_column=6) plot_probe(multi_shank) .. image-sg:: /examples/images/sphx_glr_ex_04_multi_shank_probe_001.png :alt: Probe - 36ch - 3shanks :srcset: /examples/images/sphx_glr_ex_04_multi_shank_probe_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none (, ) .. GENERATED FROM PYTHON SOURCE LINES 32-33 `multi_shank` is one `probe` object, but internally the `Probe.shank_ids` vector handles the shank ids. .. GENERATED FROM PYTHON SOURCE LINES 33-36 .. code-block:: Python print(multi_shank.shank_ids) .. rst-class:: sphx-glr-script-out .. code-block:: none ['0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '1' '1' '1' '1' '1' '1' '1' '1' '1' '1' '1' '1' '2' '2' '2' '2' '2' '2' '2' '2' '2' '2' '2' '2'] .. GENERATED FROM PYTHON SOURCE LINES 37-38 The dataframe displays the `shank_ids` column: .. GENERATED FROM PYTHON SOURCE LINES 38-42 .. code-block:: Python df = multi_shank.to_dataframe() df .. raw:: html
x y contact_shapes radius shank_ids contact_ids
0 0.0 0.0 circle 6.0 0
1 0.0 20.0 circle 6.0 0
2 0.0 40.0 circle 6.0 0
3 0.0 60.0 circle 6.0 0
4 0.0 80.0 circle 6.0 0
5 0.0 100.0 circle 6.0 0
6 20.0 0.0 circle 6.0 0
7 20.0 20.0 circle 6.0 0
8 20.0 40.0 circle 6.0 0
9 20.0 60.0 circle 6.0 0
10 20.0 80.0 circle 6.0 0
11 20.0 100.0 circle 6.0 0
12 150.0 0.0 circle 6.0 1
13 150.0 20.0 circle 6.0 1
14 150.0 40.0 circle 6.0 1
15 150.0 60.0 circle 6.0 1
16 150.0 80.0 circle 6.0 1
17 150.0 100.0 circle 6.0 1
18 170.0 0.0 circle 6.0 1
19 170.0 20.0 circle 6.0 1
20 170.0 40.0 circle 6.0 1
21 170.0 60.0 circle 6.0 1
22 170.0 80.0 circle 6.0 1
23 170.0 100.0 circle 6.0 1
24 300.0 0.0 circle 6.0 2
25 300.0 20.0 circle 6.0 2
26 300.0 40.0 circle 6.0 2
27 300.0 60.0 circle 6.0 2
28 300.0 80.0 circle 6.0 2
29 300.0 100.0 circle 6.0 2
30 320.0 0.0 circle 6.0 2
31 320.0 20.0 circle 6.0 2
32 320.0 40.0 circle 6.0 2
33 320.0 60.0 circle 6.0 2
34 320.0 80.0 circle 6.0 2
35 320.0 100.0 circle 6.0 2


.. GENERATED FROM PYTHON SOURCE LINES 43-46 We can iterate over a multi-shank probe and get :py:class:`Shank` objects. A `Shank` is linked to a `Probe` object and can also retrieve positions, contact shapes, etc.: .. GENERATED FROM PYTHON SOURCE LINES 46-53 .. code-block:: Python for i, shank in enumerate(multi_shank.get_shanks()): print('shank', i) print(shank.__class__) print(shank.get_contact_count()) print(shank.contact_positions.shape) .. rst-class:: sphx-glr-script-out .. code-block:: none shank 0 12 (12, 2) shank 1 12 (12, 2) shank 2 12 (12, 2) .. GENERATED FROM PYTHON SOURCE LINES 54-56 Another option to create multi-shank probes is to create several `Shank` objects as separate probes and then combine them into a single `Probe` object .. GENERATED FROM PYTHON SOURCE LINES 56-66 .. code-block:: Python # generate a 2 shanks linear probe0 = generate_linear_probe(num_elec=16, ypitch=20, contact_shapes='square', contact_shape_params={'width': 12}) probe1 = probe0.copy() probe1.move([100, 0]) multi_shank = combine_probes([probe0, probe1]) .. GENERATED FROM PYTHON SOURCE LINES 67-70 .. code-block:: Python print(multi_shank.shank_ids) .. rst-class:: sphx-glr-script-out .. code-block:: none ['0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '1' '1' '1' '1' '1' '1' '1' '1' '1' '1' '1' '1' '1' '1' '1' '1'] .. GENERATED FROM PYTHON SOURCE LINES 71-75 .. code-block:: Python plot_probe(multi_shank) plt.show() .. image-sg:: /examples/images/sphx_glr_ex_04_multi_shank_probe_002.png :alt: Probe - 32ch - 2shanks :srcset: /examples/images/sphx_glr_ex_04_multi_shank_probe_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.151 seconds) .. _sphx_glr_download_examples_ex_04_multi_shank_probe.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: ex_04_multi_shank_probe.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: ex_04_multi_shank_probe.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: ex_04_multi_shank_probe.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_