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

print(probe)

##############################################################################
# In addition to contacts, 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:

df = probe.to_dataframe()
df

##############################################################################
# If `matplotlib` is installed, the `Probe` can also be easily plotted:

plot_probe(probe)

##############################################################################
# A 2d `Probe` can be transformed to a 3d `Probe` by indicating the `axes`
# on which contacts will lie (Here the 'y' coordinate will be 0 for all contacts):

probe_3d = probe.to_3d(axes='xz')
plot_probe(probe_3d)

plt.show()
Beispiel #2
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)