コード例 #1
0
def test_read_bids_folder():
    # gin get NeuralEnsemble/BEP032-examples
    # cd BEP032-examples
    # gin get NeuralEnsemble/BEP032-examples

    # ~ folder_path = '/media/samuel/dataspikesorting/DataSpikeSorting/BEP032-examples/ephys_nwb_petersen/sub-MS10/ses-PeterMS10170307154746concat/ephys/'
    # ~ folder_path = '/home/samuel/Documents/BEP032-examples/ephys_nwb_petersen/sub-MS10/ses-PeterMS10170307154746concat/ephys/'

    folder_path = '/home/samuel/Documents/BEP032-examples/ephys_nix/sub-i/ses-140703/ephys/'
    recordings = read_bids_folder(folder_path)
    # ~ print(recordings)

    rec0 = recordings[0]
    rec1 = recordings[1]

    import spikeinterface.full as si
    sorting = si.run_sorter('herdingspikes', rec1)
    print(sorting)
    exit()

    # ~ print(rec0)
    # ~ print(rec1)

    import matplotlib.pyplot as plt
    from probeinterface.plotting import plot_probe, plot_probe_group
    fig, ax = plt.subplots()
    probegroup = rec1.get_probegroup()
    print(probegroup)
    plot_probe_group(
        probegroup,
        # ~ with_channel_index=True,
        with_contact_id=True,
        with_device_index=True,
        same_axes=False)
    plt.show()
コード例 #2
0
def test_plot_probe_group():
    probegroup = generate_dummy_probe_group()

    plot_probe_group(probegroup, same_axe=True, with_channel_index=True)
    plot_probe_group(probegroup, same_axe=False)

    # 3d
    probegroup_3d = ProbeGroup()
    for probe in probegroup.probes:
        probegroup_3d.add_probe(probe.to_3d())
    probegroup_3d.probes[-1].move([0, 150, -50])
    plot_probe_group(probegroup_3d, same_axe=True)
コード例 #3
0
# Generate 2 dummy `Probe` objects with the utils function:
#

probe0 = generate_dummy_probe(elec_shapes='square')
probe1 = generate_dummy_probe(elec_shapes='circle')
probe1.move([250, -90])

##############################################################################
# Let's create a `ProbeGroup` and
# add the `Probe` objects into it:

probegroup = ProbeGroup()
probegroup.add_probe(probe0)
probegroup.add_probe(probe1)

print('probe0.get_electrode_count()', probe0.get_electrode_count())
print('probe1.get_electrode_count()', probe1.get_electrode_count())
print('probegroup.get_channel_count()', probegroup.get_channel_count())

##############################################################################
#  We can now plot all probes in the same axis:

plot_probe_group(probegroup, same_axe=True)

##############################################################################
#  or in separate axes:

plot_probe_group(probegroup, same_axe=False, with_channel_index=True)

plt.show()
コード例 #4
0
# Generate 4 tetrodes:
# 

from probeinterface import generate_tetrode

probegroup = ProbeGroup()
for i in range(4):
    tetrode = generate_tetrode()
    tetrode.move([i * 50, 0])
    probegroup.add_probe(tetrode)
probegroup.set_global_device_channel_indices(np.arange(16))

df = probegroup.to_dataframe()
df

plot_probe_group(probegroup, with_channel_index=True, same_axes=True)

##############################################################################
# Generate a linear probe:
# 

from probeinterface import generate_linear_probe

linear_probe = generate_linear_probe(num_elec=16, ypitch=20)
plot_probe(linear_probe, with_channel_index=True)

##############################################################################
# Generate a multi-column probe:
# 

from probeinterface import generate_multi_columns_probe
コード例 #5
0
                                      xpitch=75, ypitch=75, y_shift_per_column=[0, -37.5, 0],
                                      electrode_shapes='circle', electrode_shape_params={'radius': 12})
probe1 = probe0.copy()

probe1.move([350, 200])
probegroup = ProbeGroup()
probegroup.add_probe(probe0)
probegroup.add_probe(probe1)

# wire probe0 0 to 31 and shuffle
channel_indices0 = np.arange(16)
np.random.shuffle(channel_indices0)
probe0.set_device_channel_indices(channel_indices0)

# wire probe0 32 to 63 and shuffle
channel_indices1 = np.arange(16, 32)
np.random.shuffle(channel_indices1)
probe1.set_device_channel_indices(channel_indices1)

print(probegroup.get_global_device_channel_indices())

##############################################################################
# The indices of the probe group can also be plotted:

fig, ax = plt.subplots()
plot_probe_group(probegroup, with_channel_index=True, same_axe=True, ax=ax)
ax.set_xlim(-100, 600)
ax.set_ylim(-100, 600)

plt.show()
コード例 #6
0
probe0 = generate_dummy_probe(elec_shapes='square')
probe1 = generate_dummy_probe(elec_shapes='circle')
probe1.move([250, -90])

probegroup = ProbeGroup()
probegroup.add_probe(probe0)
probegroup.add_probe(probe1)

##############################################################################
# With the `write_probeinterface` and `read_probeinterface` functions we can
# write to and read from the json-based probeinterface format:

write_probeinterface('my_two_probe_setup.json', probegroup)

probegroup2 = read_probeinterface('my_two_probe_setup.json')
plot_probe_group(probegroup2)

##############################################################################
# The format looks like this:

with open('my_two_probe_setup.json', mode='r') as f:
    txt = f.read()

print(txt[:600], '...')

##############################################################################
# PRB is an historical format introduced by the Klusta team and it is also
# used by SpikeInterface, Spyking-circus, and Tridesclous.
# The format is in fact a python script that describes a dictionary.
# This format handles:
#   * multiple groups (multi-shank or multi-probe)
コード例 #7
0
 def _do_plot(self):
     plot_probe_group(self._probegroup,
                      ax=self.ax,
                      same_axes=True,
                      **self._plot_probe_kwargs)