# and make some alien probes
probe3 = Probe()
positions = [[0, 0], [0, 50], [25, 77], [45, 27]]
shapes = ['circle', 'square', 'rect', 'circle']
params = [{
    'radius': 10
}, {
    'width': 30
}, {
    'width': 20,
    'height': 12
}, {
    'radius': 13
}]
probe3.set_electrodes(positions=positions, shapes=shapes, shape_params=params)
probe3.create_auto_shape(probe_type='rect')
probe3.rotate(theta=25)
probe3.move([600, 0])
plot_probe(probe3, ax=ax, electrode_colors=['b', 'c', 'g', 'y'])

ax.set_xlim(-100, 700)
ax.set_ylim(-200, 350)

ax.set_aspect('equal')

##############################################################################
# Some example in 3d for romantic who like flowers...

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, projection='3d')
Beispiel #2
0
    positions[i] = x, y
positions *= 20
positions[8:16, 1] -= 10

##############################################################################
# Now we can create a `Probe` object
#  and set the position and shape of each electrode
#
# The `ndim` argument indicates that the electrode is 2d, so the positions have a (n_elec, 2) shape.
#  We can also define 3d probe with `ndim=3` and positions will have a (n_elec, 3) shape.
#
# Note: `shapes` and `shape_params` could be arrays as well, indicating the shape for each electrode separately.

probe = Probe(ndim=2, si_units='um')
probe.set_electrodes(positions=positions,
                     shapes='circle',
                     shape_params={'radius': 5})

##############################################################################
#  `Probe` objects have fancy prints!

print(probe)

##############################################################################
# In addition to electrodes, we can crate the planar contour (polygon) of the probe

polygon = [(-20, -30), (20, -110), (60, -30), (60, 190), (-20, 190)]
probe.set_planar_contour(polygon)

##############################################################################
#  If `pandas` is installed, the `Probe` object can be exported as a dataframe for a simpler view:
Beispiel #3
0
##############################################################################
#  The `plane_axes` argument handles the axis for each electrode.
#  It can be used for electrode-wise rotations.
#  `plane_axes` has a shape of (num_elec, 2, ndim)

plane_axes = [[[1 / np.sqrt(2), 1 / np.sqrt(2)],
               [-1 / np.sqrt(2), 1 / np.sqrt(2)]]] * n
plane_axes = np.array(plane_axes)

##############################################################################
#  Create the probe

probe = Probe(ndim=2, si_units='um')
probe.set_electrodes(positions=positions,
                     plane_axes=plane_axes,
                     shapes=shapes,
                     shape_params=shape_params)
probe.create_auto_shape()

##############################################################################

plot_probe(probe)

##############################################################################
#  We can also use the `rotate_electrodes` to make electrode-wise rotations:

from probeinterface import generate_multi_columns_probe

probe = generate_multi_columns_probe(num_columns=3,
                                     num_elec_per_column=8,
                                     xpitch=20,
Beispiel #4
0
def test_probe():
    positions = _dummy_posistion()

    probe = Probe(ndim=2, si_units='um')
    probe.set_electrodes(positions=positions,
                         shapes='circle',
                         shape_params={'radius': 5})
    probe.set_electrodes(positions=positions,
                         shapes='square',
                         shape_params={'width': 5})
    probe.set_electrodes(positions=positions,
                         shapes='rect',
                         shape_params={
                             'width': 8,
                             'height': 5
                         })

    assert probe.get_electrode_count() == 24

    # shape of the probe
    vertices = [(-20, -30), (20, -110), (60, -30), (60, 190), (-20, 190)]
    probe.set_planar_contour(vertices)

    # auto shape
    probe.create_auto_shape()

    # device channel
    chans = np.arange(0, 24, dtype='int')
    np.random.shuffle(chans)
    probe.set_device_channel_indices(chans)

    # electrode_ids int or str
    elec_ids = np.arange(24)
    probe.set_electrode_ids(elec_ids)
    elec_ids = [f'elec #{e}' for e in range(24)]
    probe.set_electrode_ids(elec_ids)

    # copy
    probe2 = probe.copy()

    # move rotate
    probe.move([20, 50])
    probe.rotate(theta=40, center=[0, 0], axis=None)

    # make annimage
    values = np.random.randn(24)
    image, xlims, ylims = probe.to_image(values, method='cubic')

    image2, xlims, ylims = probe.to_image(values, method='cubic', num_pixel=16)

    #~ from probeinterface.plotting import plot_probe_group, plot_probe
    #~ import matplotlib.pyplot as plt
    #~ fig, ax = plt.subplots()
    #~ plot_probe(probe, ax=ax)
    #~ ax.imshow(image, extent=xlims+ylims, origin='lower')
    #~ ax.imshow(image2, extent=xlims+ylims, origin='lower')
    #~ plt.show()

    # 3d
    probe_3d = probe.to_3d()
    probe_3d.rotate(theta=60, center=[0, 0, 0], axis=[0, 1, 0])

    #~ from probeinterface.plotting import plot_probe_group, plot_probe
    #~ import matplotlib.pyplot as plt
    #~ plot_probe(probe_3d)
    #~ plt.show()

    # get shanks
    for shank in probe.get_shanks():
        print(shank)
        print(shank.electrode_positions)

    # get dict and df
    d = probe.to_dict()
    #~ print(d)
    df = probe.to_dataframe()
    print(df)