How to use the brainrender.DEFAULT_STRUCTURE_COLOR 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_scene.py View on Github external
def test_default():
    brainrender.DISPLAY_INSET
    brainrender.DISPLAY_ROOT
    brainrender.WHOLE_SCREEN
    brainrender.BACKGROUND_COLOR
    brainrender.SHOW_AXES
    brainrender.WINDOW_POS
    brainrender.CAMERA
    brainrender.DEFAULT_SCREENSHOT_NAME
    brainrender.DEFAULT_SCREENSHOT_TYPE
    brainrender.DEFAULT_SCREENSHOT_SCALE
    brainrender.SCREENSHOT_TRANSPARENT_BACKGROUND
    brainrender.ROOT_COLOR
    brainrender.ROOT_ALPHA
    brainrender.DEFAULT_STRUCTURE_COLOR
    brainrender.DEFAULT_STRUCTURE_ALPHA
    brainrender.INJECTION_VOLUME_SIZE
    brainrender.TRACTO_RADIUS
    brainrender.TRACTO_ALPHA
    brainrender.TRACTO_RES
    brainrender.TRACT_DEFAULT_COLOR
    brainrender.INJECTION_DEFAULT_COLOR
    brainrender.STREAMLINES_RESOLUTION
    brainrender.INJECTION_VOLUME_SIZE
    brainrender.TRACTO_RADIUS
    brainrender.TRACTO_ALPHA
    brainrender.TRACTO_RES
    brainrender.TRACT_DEFAULT_COLOR
    brainrender.INJECTION_DEFAULT_COLOR
    brainrender.STREAMLINES_RESOLUTION
    brainrender.SHADER_STYLE
github BrancoLab / BrainRender / brainrender / Utils / parsers / rat.py View on Github external
if not os.path.isfile(meshname):
                raise FileExistsError(meshname)

            if use_original_color:
                c = entry["rgb"].values[0]
                if isinstance(c, str):
                    c = c.replace("[", "")
                    c = c.replace("]", "")
                    cols = c.split(",")
                    color = [int(c) for c in cols]
                else:
                    color = c
            else:
                if "color" in list(kwargs.keys()):
                    color = kwargs.pop("color", DEFAULT_STRUCTURE_COLOR)
                elif "c" in list(kwargs.keys()):
                    color = kwargs.pop("c", DEFAULT_STRUCTURE_COLOR)

            if "color" in list(kwargs.keys()): del kwargs["color"]
            elif "c" in list(kwargs.keys()): del kwargs["c"]

            mesh = load(meshname, c=color, **kwargs) 
            mesh = mesh.smoothLaplacian().subdivide(2)
            meshes.append(mesh)
        except:
            print("Could not load rat region: {}".format(entry["Name"].values[0]))
            return None
    
    if not check:
        return meshes[0]
    else:
github BrancoLab / BrainRender / brainrender / Utils / parsers / rat.py View on Github external
raise FileExistsError(meshname)

            if use_original_color:
                c = entry["rgb"].values[0]
                if isinstance(c, str):
                    c = c.replace("[", "")
                    c = c.replace("]", "")
                    cols = c.split(",")
                    color = [int(c) for c in cols]
                else:
                    color = c
            else:
                if "color" in list(kwargs.keys()):
                    color = kwargs.pop("color", DEFAULT_STRUCTURE_COLOR)
                elif "c" in list(kwargs.keys()):
                    color = kwargs.pop("c", DEFAULT_STRUCTURE_COLOR)

            if "color" in list(kwargs.keys()): del kwargs["color"]
            elif "c" in list(kwargs.keys()): del kwargs["c"]

            mesh = load(meshname, c=color, **kwargs) 
            mesh = mesh.smoothLaplacian().subdivide(2)
            meshes.append(mesh)
        except:
            print("Could not load rat region: {}".format(entry["Name"].values[0]))
            return None
    
    if not check:
        return meshes[0]
    else:
        return meshes
github BrancoLab / BrainRender / brainrender / Utils / parsers / drosophila.py View on Github external
"""

    :param region: 
    :param paths: 
    :param **kwargs: 

    """
    if not isinstance(region, (tuple, list)):
        region = [region]
        check = False
    else: check = True

    metadata = get_drosophila_regions_metadata(paths.metadata)

    if "color" in list(kwargs.keys()):
        color = kwargs.pop("color", DEFAULT_STRUCTURE_COLOR)
    elif "c" in list(kwargs.keys()):
        color = kwargs.pop("c", DEFAULT_STRUCTURE_COLOR)

    if "color" in list(kwargs.keys()): del kwargs["color"]
    elif "c" in list(kwargs.keys()): del kwargs["c"]


    meshes = []
    for reg in region:
        if reg.lower() == "root":
            meshname = drosophila_root  ## UNDEFINED!!??
            mesh = load(meshname, c=color, **kwargs) 
            mesh = mesh.smoothLaplacian().subdivide(2)
            meshes.append(mesh)
        else:
            if isinstance(reg, int):
github BrancoLab / BrainRender / brainrender / atlases / brainglobe.py View on Github external
f"The region {region} doesn't seem to belong to the atlas being used: {self.atlas_name}. Skipping"
                )
                continue

            # Get path to .obj file
            obj_file = str(self.meshfile_from_structure(region))

            # check which color to assign to the brain region
            if use_original_color:
                color = [
                    x / 255
                    for x in self._get_from_structure(region, "rgb_triplet")
                ]
            else:
                if colors is None:
                    color = brainrender.DEFAULT_STRUCTURE_COLOR
                elif isinstance(colors, list):
                    color = colors[i]
                else:
                    color = colors

            # Load the object file as a mesh and store the actor
            if hemisphere is not None:
                if (
                    hemisphere.lower() == "left"
                    or hemisphere.lower() == "right"
                ):
                    obj = self.get_region_unilateral(
                        region, hemisphere=hemisphere, color=color, alpha=alpha
                    )
                else:
                    raise ValueError(
github BrancoLab / BrainRender / brainrender / atlases / atlas.py View on Github external
f"The region {region} doesn't seem to belong to the atlas being used: {self.atlas_name}. Skipping"
                )
                continue

            # Get path to .obj file
            obj_file = str(self.meshfile_from_structure(region))

            # check which color to assign to the brain region
            if use_original_color:
                color = [
                    x / 255
                    for x in self._get_from_structure(region, "rgb_triplet")
                ]
            else:
                if colors is None:
                    color = brainrender.DEFAULT_STRUCTURE_COLOR
                elif isinstance(colors, list):
                    color = colors[i]
                else:
                    color = colors

            # Load the object file as a mesh and store the actor
            if hemisphere is not None:
                if (
                    hemisphere.lower() == "left"
                    or hemisphere.lower() == "right"
                ):
                    obj = self.get_region_unilateral(
                        region, hemisphere=hemisphere, color=color, alpha=alpha
                    )
                else:
                    raise ValueError(
github BrancoLab / BrainRender / brainrender / atlases / custom_atlases / insects_brains_db.py View on Github external
alpha=None,
        colors=None,
        use_original_color=True,
        **kwargs,
    ):
        if alpha is None:
            alpha = brainrender.DEFAULT_STRUCTURE_ALPHA

        if not isinstance(brain_regions, (list, tuple)):
            brain_regions = [brain_regions]

        # check the colors input is correct
        if not use_original_color:
            if colors is None:
                colors = [
                    brainrender.DEFAULT_STRUCTURE_COLOR
                    for reg in brain_regions
                ]
            else:
                if isinstance(colors, (list, tuple)):
                    if len(colors) != len(brain_regions):
                        raise ValueError("Wrong number of colors")
                else:
                    colors = [colors for reg in brain_regions]
        else:
            colors = [self.get_region_color(reg) for reg in brain_regions]

        actors = {}
        for region, color in zip(brain_regions, colors):
            actors[region] = self._get_structure_mesh(region, c=color)

        return actors
github BrancoLab / BrainRender / brainrender / atlases / base.py View on Github external
f"The region {region} doesn't seem to belong to the atlas being used: {self.atlas_name}. Skipping"
                )
                continue

            # Get path to .obj file
            obj_file = str(self.meshfile_from_structure(region))

            # check which color to assign to the brain region
            if use_original_color:
                color = [
                    x / 255
                    for x in self._get_from_structure(region, "rgb_triplet")
                ]
            else:
                if colors is None:
                    color = brainrender.DEFAULT_STRUCTURE_COLOR
                elif isinstance(colors, list):
                    color = colors[i]
                else:
                    color = colors

            # Load the object file as a mesh and store the actor
            if hemisphere is not None:
                if (
                    hemisphere.lower() == "left"
                    or hemisphere.lower() == "right"
                ):
                    obj = self.get_region_unilateral(
                        region, hemisphere=hemisphere, color=color, alpha=alpha
                    )
                else:
                    raise ValueError(
github BrancoLab / BrainRender / brainrender / Utils / parsers / drosophila.py View on Github external
:param region: 
    :param paths: 
    :param **kwargs: 

    """
    if not isinstance(region, (tuple, list)):
        region = [region]
        check = False
    else: check = True

    metadata = get_drosophila_regions_metadata(paths.metadata)

    if "color" in list(kwargs.keys()):
        color = kwargs.pop("color", DEFAULT_STRUCTURE_COLOR)
    elif "c" in list(kwargs.keys()):
        color = kwargs.pop("c", DEFAULT_STRUCTURE_COLOR)

    if "color" in list(kwargs.keys()): del kwargs["color"]
    elif "c" in list(kwargs.keys()): del kwargs["c"]


    meshes = []
    for reg in region:
        if reg.lower() == "root":
            meshname = drosophila_root  ## UNDEFINED!!??
            mesh = load(meshname, c=color, **kwargs) 
            mesh = mesh.smoothLaplacian().subdivide(2)
            meshes.append(mesh)
        else:
            if isinstance(reg, int):
                entry = metadata.loc[metadata.Id == reg]
            elif isinstance(reg, str):