How to use the phylib.utils.geometry._get_data_bounds function in phylib

To help you get started, we’ve selected a few phylib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cortex-lab / phy / phy / plot / visuals.py View on Github external
assert pos is not None
        pos = np.atleast_2d(pos)
        assert pos.ndim == 2
        assert pos.shape[1] == 2
        n_text = pos.shape[0]
        assert len(text) == n_text

        anchor = anchor if anchor is not None else (0., 0.)
        anchor = np.atleast_2d(anchor)
        if anchor.shape[0] == 1:
            anchor = np.repeat(anchor, n_text, axis=0)
        assert anchor.ndim == 2
        assert anchor.shape == (n_text, 2)

        data_bounds = data_bounds if data_bounds is not None else NDC
        data_bounds = _get_data_bounds(data_bounds, pos)
        assert data_bounds.shape[0] == n_text
        data_bounds = data_bounds.astype(np.float64)
        assert data_bounds.shape == (n_text, 4)

        return Bunch(
            pos=pos, text=text, anchor=anchor, data_bounds=data_bounds,
            _n_items=n_text, _n_vertices=self.vertex_count(text=text))
github cortex-lab / phy / phy / plot / visuals.py View on Github external
n_signals = len(x)

        masks = _get_array(masks, (n_signals, 1), 1., np.float32)
        # The mask is clu_idx + fractional mask
        masks *= .99999
        assert masks.shape == (n_signals, 1)

        if isinstance(data_bounds, str) and data_bounds == 'auto':
            xmin = [_min(_) for _ in x]
            ymin = [_min(_) for _ in y]
            xmax = [_max(_) for _ in x]
            ymax = [_max(_) for _ in y]
            data_bounds = np.c_[xmin, ymin, xmax, ymax]

        if data_bounds is not None:
            data_bounds = _get_data_bounds(data_bounds, length=n_signals)
            data_bounds = data_bounds.astype(np.float64)
            assert data_bounds.shape == (n_signals, 4)

        return Bunch(
            x=x, y=y, masks=masks, data_bounds=data_bounds,
            _n_items=n_signals, _n_vertices=self.vertex_count(y=y))
github cortex-lab / phy / phy / plot / visuals.py View on Github external
def validate(self, pos=None, data_bounds=None, **kwargs):
        """Validate the requested data before passing it to set_data()."""
        assert pos is not None
        pos = np.atleast_2d(pos)
        assert pos.ndim == 2
        assert pos.shape[1] == 2

        # By default, we assume that the coordinates are in NDC.
        if data_bounds is None:
            data_bounds = NDC
        data_bounds = _get_data_bounds(data_bounds)
        data_bounds = data_bounds.astype(np.float64)
        assert data_bounds.shape == (1, 4)

        return Bunch(
            pos=pos, data_bounds=data_bounds,
            _n_items=pos.shape[0], _n_vertices=self.vertex_count(pos=pos))
github cortex-lab / phy / phy / plot / visuals.py View on Github external
def validate(self, pos=None, color=None, data_bounds=None, **kwargs):
        """Validate the requested data before passing it to set_data()."""
        assert pos is not None
        pos = _as_array(pos)
        pos = np.atleast_2d(pos)
        assert pos.ndim == 2
        n_lines = pos.shape[0]
        assert pos.shape[1] == 4

        # Color.
        color = _get_array(color, (n_lines, 4), LineVisual.default_color)

        # By default, we assume that the coordinates are in NDC.
        if data_bounds is None:
            data_bounds = NDC
        data_bounds = _get_data_bounds(data_bounds, length=n_lines)
        data_bounds = data_bounds.astype(np.float64)
        assert data_bounds.shape == (n_lines, 4)

        return Bunch(
            pos=pos, color=color, data_bounds=data_bounds,
            _n_items=n_lines, _n_vertices=self.vertex_count(pos=pos))
github cortex-lab / phy / phy / plot / visuals.py View on Github external
color = _get_array(color, (n_signals, 4),
                           PlotVisual.default_color,
                           dtype=np.float32,
                           )
        assert color.shape == (n_signals, 4)

        masks = _get_array(masks, (n_signals, 1), 1., np.float32)
        # The mask is clu_idx + fractional mask
        masks *= .99999
        assert masks.shape == (n_signals, 1)

        depth = _get_array(depth, (n_signals, 1), 0)
        assert depth.shape == (n_signals, 1)

        if data_bounds is not None:
            data_bounds = _get_data_bounds(data_bounds, length=n_signals)
            data_bounds = data_bounds.astype(np.float64)
            assert data_bounds.shape == (n_signals, 4)

        return Bunch(
            x=x, y=y, color=color, depth=depth, data_bounds=data_bounds, masks=masks,
            _n_items=n_signals, _n_vertices=self.vertex_count(y=y))
github cortex-lab / phy / phy / plot / visuals.py View on Github external
self, x=None, y=None, pos=None, color=None, depth=None,
            data_bounds=None, **kwargs):
        """Validate the requested data before passing it to set_data()."""
        if pos is None:
            x, y = _get_pos(x, y)
            pos = np.c_[x, y]
        pos = np.asarray(pos)
        assert pos.ndim == 2
        assert pos.shape[1] == 2
        n = pos.shape[0]

        # Validate the data.
        color = _get_array(color, (n, 4), ScatterVisual.default_color, dtype=np.float32)
        depth = _get_array(depth, (n, 1), 0)
        if data_bounds is not None:
            data_bounds = _get_data_bounds(data_bounds, pos)
            assert data_bounds.shape[0] == n

        return Bunch(
            pos=pos, color=color, depth=depth, data_bounds=data_bounds,
            _n_items=n, _n_vertices=n)
github cortex-lab / phy / phy / plot / visuals.py View on Github external
x, y = _get_pos(x, y)
            pos = np.c_[x, y]
        pos = np.asarray(pos)
        assert pos.ndim == 2
        assert pos.shape[1] == 2
        n = pos.shape[0]

        masks = _get_array(masks, (n, 1), 1., np.float32)
        assert masks.shape == (n, 1)

        # The mask is clu_idx + fractional mask
        masks *= .99999

        # Validate the data.
        if data_bounds is not None:
            data_bounds = _get_data_bounds(data_bounds, pos)
            assert data_bounds.shape[0] == n

        return Bunch(pos=pos, masks=masks, data_bounds=data_bounds, _n_items=n, _n_vertices=n)