############################################################################## # `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()
positions *= 20 positions[8:16, 1] -= 10 probe_2d = Probe(ndim=2, si_units='um') probe_2d.set_contacts(positions=positions, shapes='circle', shape_params={'radius': 5}) probe_2d.create_auto_shape(probe_type='tip') ############################################################################## # Let's transform it into a 3d probe. # # Here the axes are 'xz' so y will be 0 for all contacts. # The shape of probe_3d.contact_positions is now (n_elec, 3) probe_3d = probe_2d.to_3d(axes='xz') print(probe_2d.contact_positions.shape) print(probe_3d.contact_positions.shape) ############################################################################## # Note that all **"y"** coordinates are 0 df = probe_3d.to_dataframe() df[['x', 'y', 'z']].head() ############################################################################## # The plotting function autiomatically displays the `Probe` in 3d: plot_probe(probe_3d) ##############################################################################
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)
############################################################################## # `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: 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 `plane` # on which electrodes will lie (Here the 'y' coordinate will be 0 for all electrodes): probe_3d = probe.to_3d(plane='xz') plot_probe(probe_3d) plt.show()
positions *= 20 positions[8:16, 1] -= 10 probe_2d = Probe(ndim=2, si_units='um') probe_2d.set_electrodes(positions=positions, shapes='circle', shape_params={'radius': 5}) probe_2d.create_auto_shape(probe_type='tip') ############################################################################## # Let's transform it into a 3d probe. # # Here the plane is 'xz' so y will be 0 for all electrodes. # The shape of probe_3d.electrode_positions is now (n_elec, 3) probe_3d = probe_2d.to_3d(plane='xz') print(probe_2d.electrode_positions.shape) print(probe_3d.electrode_positions.shape) ############################################################################## # Note that all **"y"** coordinates are 0 df = probe_3d.to_dataframe() df[['x', 'y', 'z']].head() ############################################################################## # The plotting function autiomatically displays the `Probe` in 3d: plot_probe(probe_3d) ##############################################################################