How to use the brainrender.colors.getColor function in brainrender

To help you get started, we’ve selected a few brainrender 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 BrancoLab / BrainRender / tests / test_utils.py View on Github external
def test_colors():
    if not isinstance(get_random_colormap(), str):
        raise ValueError

    cols = get_n_shades_of("green", 40)
    if not isinstance(cols, list):
        raise ValueError
    if len(cols) != 40:
        raise ValueError

    getColor("orange")
    getColor([1, 1, 1])
    getColor("k")
    getColor("#ffffff")
    getColor(7)
    getColor(-7)

    getColorName("#ffffff")

    cols = colorMap([0, 1, 2])
    if not isinstance(cols, (list, np.ndarray)):
        raise ValueError
    if len(cols) != 3:
        raise ValueError

    c = colorMap(3, vmin=-3, vmax=4)

    check_colors(cols)
    check_colors(c)
github BrancoLab / BrainRender / tests / test_utils.py View on Github external
def test_colors():
    if not isinstance(get_random_colormap(), str):
        raise ValueError

    cols = get_n_shades_of("green", 40)
    if not isinstance(cols, list):
        raise ValueError
    if len(cols) != 40:
        raise ValueError

    getColor("orange")
    getColor([1, 1, 1])
    getColor("k")
    getColor("#ffffff")
    getColor(7)
    getColor(-7)

    getColorName("#ffffff")

    cols = colorMap([0, 1, 2])
    if not isinstance(cols, (list, np.ndarray)):
        raise ValueError
    if len(cols) != 3:
        raise ValueError

    c = colorMap(3, vmin=-3, vmax=4)

    check_colors(cols)
    check_colors(c)
github BrancoLab / BrainRender / tests / test_utils.py View on Github external
def test_colors():
    if not isinstance(get_random_colormap(), str):
        raise ValueError

    cols = get_n_shades_of("green", 40)
    if not isinstance(cols, list):
        raise ValueError
    if len(cols) != 40:
        raise ValueError

    getColor("orange")
    getColor([1, 1, 1])
    getColor("k")
    getColor("#ffffff")
    getColor(7)
    getColor(-7)

    getColorName("#ffffff")

    cols = colorMap([0, 1, 2])
    if not isinstance(cols, (list, np.ndarray)):
        raise ValueError
    if len(cols) != 3:
        raise ValueError

    c = colorMap(3, vmin=-3, vmax=4)

    check_colors(cols)
    check_colors(c)
github BrancoLab / BrainRender / tests / test_utils.py View on Github external
def test_colors():
    if not isinstance(get_random_colormap(), str):
        raise ValueError

    cols = get_n_shades_of("green", 40)
    if not isinstance(cols, list):
        raise ValueError
    if len(cols) != 40:
        raise ValueError

    getColor("orange")
    getColor([1, 1, 1])
    getColor("k")
    getColor("#ffffff")
    getColor(7)
    getColor(-7)

    getColorName("#ffffff")

    cols = colorMap([0, 1, 2])
    if not isinstance(cols, (list, np.ndarray)):
        raise ValueError
    if len(cols) != 3:
        raise ValueError

    c = colorMap(3, vmin=-3, vmax=4)

    check_colors(cols)
    check_colors(c)
github BrancoLab / BrainRender / tests / test_utils.py View on Github external
def test_colors():
    if not isinstance(get_random_colormap(), str):
        raise ValueError

    cols = get_n_shades_of("green", 40)
    if not isinstance(cols, list):
        raise ValueError
    if len(cols) != 40:
        raise ValueError

    getColor("orange")
    getColor([1, 1, 1])
    getColor("k")
    getColor("#ffffff")
    getColor(7)
    getColor(-7)

    getColorName("#ffffff")

    cols = colorMap([0, 1, 2])
    if not isinstance(cols, (list, np.ndarray)):
        raise ValueError
    if len(cols) != 3:
        raise ValueError

    c = colorMap(3, vmin=-3, vmax=4)
github BrancoLab / BrainRender / brainrender / raytracing_scene.py View on Github external
def render(
        self, *args, show=True, **kwargs,
    ):
        """
            Renders the content of the scene as a RayTracing interactive rendering 
            with plotoptix.TkOptiX. It tries as much as possible to replicate the 
            content and look of standard brainrender scenes
        """
        # render Scene first
        super().render(*args, interactive=False, **kwargs)
        self.close()

        # General scene setting
        self.optix.set_background(getColor(self.plotter.backgrcol))
        self.optix.set_ambient(self.ambient_light)

        # add meshes
        for mesh in self.get_actors():
            self.add_actor_as_mesh(mesh)

        # Set up camera
        camera_params = get_camera_params(self)
        self.optix.setup_camera(
            "cam1", eye=camera_params["position"], up=[0, -1, 0]
        )
        self.optix.camera_fit()
        self.optix.camera_move_by_local(shift=[0, 0, 1000])

        # Set up lights
        d = np.linalg.norm(
github BrancoLab / BrainRender / brainrender / morphology / visualise.py View on Github external
if isinstance(color, str):
                # Deal with a a cmap being passed
                if color in _mapscales_cmaps:
                    cols = [
                        colorMap(n, name=color, vmin=-2, vmax=N + 2)
                        for n in np.arange(N)
                    ]
                    colors = dict(
                        soma=cols.copy(),
                        axon=cols.copy(),
                        dendrites=cols.copy(),
                    )

                else:
                    # Deal with a single color being passed
                    cols = [getColor(color) for n in np.arange(N)]
                    colors = dict(
                        soma=cols.copy(),
                        axon=cols.copy(),
                        dendrites=cols.copy(),
                    )
            elif isinstance(color, dict):
                # Deal with a dictionary with color for each component
                if "soma" not in color.keys():
                    raise ValueError(
                        f"When passing a dictionary as color argument, \
                                                soma should be one fo the keys: {color}"
                    )
                dendrites_color = color.pop("dendrites", color["soma"])
                axon_color = color.pop("axon", color["soma"])

                colors = dict(
github BrancoLab / BrainRender / brainrender / raytracing_scene.py View on Github external
def add_actor_as_mesh(self, actor, actor_name=None):
        if actor is None:
            return

        if actor_name is None:
            actor_name = str(int(np.random.uniform(0, 10000)))

        if actor.alpha() < 1:
            mat = "glass"
            color = np.array([c * 25 for c in getColor(actor.color())])
        else:
            mat = "diffuse"
            color = actor.color()

        self.optix.set_mesh(
            actor_name, actor.points(), actor.faces(), c=color, mat=mat
        )
github BrancoLab / BrainRender / brainrender / ABA / aba_utils.py View on Github external
colors = dict(soma=cols, axon=cols, dendrites=cols,)
    else:
        if isinstance(color, str):
            # Deal with a a cmap being passed
            if color in _mapscales_cmaps:
                cols = [
                    colorMap(n, name=color, vmin=-2, vmax=N + 2)
                    for n in np.arange(N)
                ]
                colors = dict(
                    soma=cols.copy(), axon=cols.copy(), dendrites=cols.copy(),
                )

            else:
                # Deal with a single color being passed
                cols = [getColor(color) for n in np.arange(N)]
                colors = dict(
                    soma=cols.copy(), axon=cols.copy(), dendrites=cols.copy(),
                )
        elif isinstance(color, dict):
            # Deal with a dictionary with color for each component
            if "soma" not in color.keys():
                raise ValueError(
                    f"When passing a dictionary as color argument, \
                                            soma should be one fo the keys: {color}"
                )
            dendrites_color = color.pop("dendrites", color["soma"])
            axon_color = color.pop("axon", color["soma"])

            colors = dict(
                soma=[color["soma"] for n in np.arange(N)],
                axon=[axon_color for n in np.arange(N)],