Пример #1
0
def _get_box_bounds(bunchs, channel_ids):
    cp = {}
    for d in bunchs:
        cp.update({cid: pos
                   for cid, pos in zip(d.channel_ids,
                                       d.channel_positions)})
    box_pos = np.stack([cp[cid] for cid in channel_ids])
    return _get_boxes(box_pos, margin=.1)
Пример #2
0
def _get_box_bounds(bunchs, channel_ids):
    cp = {}
    for d in bunchs:
        cp.update({cid: pos
                   for cid, pos in zip(d.channel_ids,
                                       d.channel_positions)})
    box_pos = np.stack([cp[cid] for cid in channel_ids])
    return _get_boxes(box_pos, margin=.1)
Пример #3
0
def _iter_channel(positions):
    size = 100
    margin = 5
    boxes = _get_boxes(positions, keep_aspect_ratio=False)
    xmin, ymin = boxes[:, :2].min(axis=0)
    xmax, ymax = boxes[:, 2:].max(axis=0)
    x = boxes[:, [0, 2]].mean(axis=1)
    y = - boxes[:, [1, 3]].mean(axis=1)
    positions = np.c_[x, y]
    tr = [margin, margin, size - margin, size - margin]
    positions = Range(NDC, tr).apply(positions)
    for x, y in positions:
        yield x, y
Пример #4
0
def _iter_channel(positions):
    size = 100
    margin = 5
    boxes = _get_boxes(positions, keep_aspect_ratio=False)
    xmin, ymin = boxes[:, :2].min(axis=0)
    xmax, ymax = boxes[:, 2:].max(axis=0)
    x = boxes[:, [0, 2]].mean(axis=1)
    y = - boxes[:, [1, 3]].mean(axis=1)
    positions = np.c_[x, y]
    tr = [margin, margin, size - margin, size - margin]
    positions = Range(NDC, tr).apply(positions)
    for x, y in positions:
        yield x, y
Пример #5
0
    def __init__(self,
                 waveforms=None,
                 channel_positions=None,
                 channel_order=None,
                 best_channels=None,
                 **kwargs):
        self._key_pressed = None
        self._overlap = False
        self.do_zoom_on_channels = True
        self.do_show_labels = False
        self.filtered_tags = ()

        self.best_channels = best_channels or (lambda clusters: [])

        # Channel positions and n_channels.
        assert channel_positions is not None
        self.channel_positions = np.asarray(channel_positions)
        self.n_channels = self.channel_positions.shape[0]

        # Initialize the view.
        box_bounds = _get_boxes(channel_positions, margin=.1)
        super(WaveformView, self).__init__(layout='boxed',
                                           box_bounds=box_bounds,
                                           **kwargs)

        self.events.add(channel_click=ChannelClick)

        # Box and probe scaling.
        self._box_scaling = np.ones(2)
        self._probe_scaling = np.ones(2)

        # Make a copy of the initial box pos and size. We'll apply the scaling
        # to these quantities.
        self.box_pos = np.array(self.boxed.box_pos)
        self.box_size = np.array(self.boxed.box_size)
        self._update_boxes()

        # Data: functions cluster_id => waveforms.
        self.waveforms = waveforms

        # Channel positions.
        assert channel_positions.shape == (self.n_channels, 2)
        self.channel_positions = channel_positions

        channel_order = (channel_order if channel_order is not None
                         else np.arange(self.n_channels))
        assert channel_order.shape == (self.n_channels,)
        self.channel_order = channel_order
Пример #6
0
    def __init__(self,
                 waveforms=None,
                 channel_positions=None,
                 waveform_lims=None,
                 best_channels=None,
                 **kwargs):
        self._key_pressed = None
        self._overlap = False
        self.do_zoom_on_channels = True
        self.data_index = 0

        self.best_channels = best_channels or (lambda clusters: [])

        # Channel positions and n_channels.
        assert channel_positions is not None
        self.channel_positions = np.asarray(channel_positions)
        self.n_channels = self.channel_positions.shape[0]

        # Initialize the view.
        box_bounds = _get_boxes(channel_positions)
        super(WaveformView, self).__init__(layout='boxed',
                                           box_bounds=box_bounds,
                                           **kwargs)

        self.events.add(channel_click=ChannelClick)

        # Box and probe scaling.
        self._box_scaling = np.ones(2)
        self._probe_scaling = np.ones(2)

        # Make a copy of the initial box pos and size. We'll apply the scaling
        # to these quantities.
        self.box_pos = np.array(self.boxed.box_pos)
        self.box_size = np.array(self.boxed.box_size)
        self._update_boxes()

        # Data: functions cluster_id => waveforms.
        self.waveforms = waveforms

        # Waveform normalization.
        assert len(waveform_lims) == 2
        self.data_bounds = [-1, waveform_lims[0], +1, waveform_lims[1]]

        # Channel positions.
        assert channel_positions.shape == (self.n_channels, 2)
        self.channel_positions = channel_positions