Example #1
0
def test_probegroup():
    probegroup = ProbeGroup()

    nchan = 0
    for i in range(3):
        probe = generate_dummy_probe()
        probe.move([i * 100, i * 80])
        n = probe.get_contact_count()
        probe.set_device_channel_indices(np.arange(n)[::-1] + nchan)
        shank_ids = np.ones(n)
        shank_ids[:n // 2] *= i * 2
        shank_ids[n // 2:] *= i * 2 + 1
        probe.set_shank_ids(shank_ids)
        probegroup.add_probe(probe)

        nchan += n

    indices = probegroup.get_global_device_channel_indices()

    ids = probegroup.get_global_contact_ids()

    df = probegroup.to_dataframe()
    #~ print(df['global_contact_ids'])

    arr = probegroup.to_numpy(complete=False)
    other = ProbeGroup.from_numpy(arr)
    arr = probegroup.to_numpy(complete=True)
    other = ProbeGroup.from_numpy(arr)

    d = probegroup.to_dict()
    other = ProbeGroup.from_dict(d)

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

    # checking automatic generation of ids with new dummy probes
    probegroup.probes = []
    for i in range(3):
        probegroup.add_probe(generate_dummy_probe())
    probegroup.auto_generate_contact_ids()
    probegroup.auto_generate_probe_ids()

    for p in probegroup.probes:
        assert p.contact_ids is not None
        assert 'probe_id' in p.annotations
Example #2
0
 def get_probegroup(self):
     arr = self.get_property('contact_vector')
     if arr is None:
         positions = self.get_property('location')
         if positions is None:
             raise ValueError(
                 'There is not Probe attached to recording. use set_probe(...)'
             )
         else:
             warn(
                 'There is no Probe attached to this recording. Creating a dummy one with contact positions'
             )
             ndim = positions.shape[1]
             probe = Probe(ndim=ndim)
             probe.set_contacts(positions=positions,
                                shapes='circle',
                                shape_params={'radius': 5})
             probe.set_device_channel_indices(
                 np.arange(self.get_num_channels(), dtype='int64'))
             #  probe.create_auto_shape()
             probegroup = ProbeGroup()
             probegroup.add_probe(probe)
     else:
         probegroup = ProbeGroup.from_numpy(arr)
         for probe_index, probe in enumerate(probegroup.probes):
             contour = self.get_annotation(
                 f'probe_{probe_index}_planar_contour')
             if contour is not None:
                 probe.set_planar_contour(contour)
     return probegroup