예제 #1
0
 def get_templates(cluster_ids):
     return {
         i: Bunch(
             template=artificial_waveforms(1, n_samples, 2)[0, ...],
             channel_ids=np.arange(i, i + 2),
         )
         for i in cluster_ids
     }
예제 #2
0
def test_waveform_view(qtbot, tempdir, gui):
    nc = 5
    ns = 10

    w = 10 + 100 * artificial_waveforms(ns, 20, nc)

    def get_waveforms(cluster_id):
        return Bunch(data=w,
                     masks=np.random.uniform(low=0., high=1., size=(ns, nc)),
                     channel_ids=np.arange(nc),
                     channel_labels=['%d' % (ch * 10) for ch in range(nc)],
                     channel_positions=staggered_positions(nc))

    v = WaveformView(
        waveforms={
            'waveforms': get_waveforms,
            'mean_waveforms': get_waveforms
        },
        sample_rate=10000.,
    )
    v.show()
    qtbot.waitForWindowShown(v.canvas)
    v.attach(gui)

    v.on_select(cluster_ids=[])
    v.on_select(cluster_ids=[0])
    v.on_select(cluster_ids=[0, 2, 3])
    v.on_select(cluster_ids=[0, 2])

    v.toggle_waveform_overlap(True)
    v.toggle_waveform_overlap(False)

    v.toggle_show_labels(False)
    v.toggle_show_labels(True)

    v.next_waveforms_type()
    v.previous_waveforms_type()
    v.toggle_mean_waveforms(True)
    v.toggle_mean_waveforms(False)

    # Box scaling.
    bs = v.boxed.box_size
    v.increase()
    v.decrease()
    v.reset_scaling()
    ac(v.boxed.box_size, bs)

    bs = v.boxed.box_size
    v.widen()
    v.narrow()
    ac(v.boxed.box_size, bs)

    # Probe scaling.
    bp = v.boxed.box_pos
    v.extend_horizontally()
    v.shrink_horizontally()
    ac(v.boxed.box_pos, bp)

    bp = v.boxed.box_pos
    v.extend_vertically()
    v.shrink_vertically()
    ac(v.boxed.box_pos, bp)

    a, b = v.probe_scaling
    v.probe_scaling = (a, b * 2)
    ac(v.probe_scaling, (a, b * 2))

    a, b = v.box_scaling
    v.box_scaling = (a * 2, b)
    ac(v.box_scaling, (a * 2, b))

    # Simulate channel selection.
    _clicked = []

    @connect(sender=v)
    def on_select_channel(sender, channel_id=None, button=None, key=None):
        _clicked.append((channel_id, button, key))

    key_press(qtbot, v.canvas, '2')
    mouse_click(qtbot, v.canvas, pos=(0., 0.), button='Left')
    key_release(qtbot, v.canvas, '2')

    assert _clicked == [(2, 'Left', 2)]

    v.set_state(v.state)

    _stop_and_close(qtbot, v)
예제 #3
0
 def get_template(self, template_id):
     nc = self.n_channels // 2
     return Bunch(template=artificial_waveforms(1, self.n_samples_waveforms,
                                                nc)[0, ...],
                  channel_ids=self._get_some_channels(template_id, nc))
예제 #4
0
 def get_waveforms(self, spike_ids, channel_ids):
     n_channels = len(channel_ids) if channel_ids else self.n_channels
     return artificial_waveforms(len(spike_ids), self.n_samples_waveforms,
                                 n_channels)
예제 #5
0
def waveforms(n_spikes, n_samples, n_channels):
    yield artificial_waveforms(n_spikes, n_samples, n_channels)