How to use the brainrender.ROOT_ALPHA 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
github BrancoLab / BrainRender / brainrender / atlases / atlas.py View on Github external
self, region, hemisphere="both", color=None, alpha=None
    ):
        """
        Regions meshes are loaded with both hemispheres' meshes by default.
        This function splits them in two.

        :param region: str, actors of brain region
        :param hemisphere: str, which hemisphere to return ['left', 'right' or 'both'] (Default value = "both")
        :param color: color of each side's mesh. (Default value = None)
        :param alpha: transparency of each side's mesh.  (Default value = None)

        """
        if color is None:
            color = brainrender.ROOT_COLOR
        if alpha is None:
            alpha = brainrender.ROOT_ALPHA
        bilateralmesh = self._get_structure_mesh(region, c=color, alpha=alpha)

        if bilateralmesh is None:
            print(f"Failed to get mesh for {region}, returning None")
            return None

        com = (
            bilateralmesh.centerOfMass()
        )  # this will always give a point that is on the midline
        right = bilateralmesh.cutWithPlane(origin=com, normal=(0, 0, 1))

        # left is the mirror right # WIP
        com = self.get_region_CenterOfMass("root", unilateral=False)[2]
        left = actors_funcs.mirror_actor_at_point(right.clone(), com, axis="x")

        if hemisphere == "both":
github BrancoLab / BrainRender / Examples / advanced / animated_scene2.py View on Github external
"""
This example shows how to crate an animate scene where
over a number of frames:
    - Different sets of streamlines data from the mouse connectome project
    - The camera moves around 
"""


import brainrender

brainrender.WHOLE_SCREEN = False
brainrender.SHADER_STYLE = "cartoon"
brainrender.ROOT_ALPHA = 0.1


from brainrender.scene import Scene
import time
import numpy as np
from random import choices
from rich.progress import track


from brainrender.Utils.camera import (
    top_camera,
    buildcam,
    sagittal_camera,
)

# --------------------------------- Variables -------------------------------- #
github BrancoLab / BrainRender / brainrender / atlases / base.py View on Github external
self, region, hemisphere="both", color=None, alpha=None
    ):
        """
        Regions meshes are loaded with both hemispheres' meshes by default.
        This function splits them in two.

        :param region: str, actors of brain region
        :param hemisphere: str, which hemisphere to return ['left', 'right' or 'both'] (Default value = "both")
        :param color: color of each side's mesh. (Default value = None)
        :param alpha: transparency of each side's mesh.  (Default value = None)

        """
        if color is None:
            color = brainrender.ROOT_COLOR
        if alpha is None:
            alpha = brainrender.ROOT_ALPHA
        bilateralmesh = self._get_structure_mesh(region, c=color, alpha=alpha)

        if bilateralmesh is None:
            print(f"Failed to get mesh for {region}, returning None")
            return None

        com = (
            bilateralmesh.centerOfMass()
        )  # this will always give a point that is on the midline
        right = bilateralmesh.cutWithPlane(origin=com, normal=(0, 0, 1))

        # left is the mirror right # WIP
        com = self.get_region_CenterOfMass("root", unilateral=False)[2]
        left = actors_funcs.mirror_actor_at_point(right.clone(), com, axis="x")

        if hemisphere == "both":
github BrancoLab / BrainRender / Examples / advanced / custom_videomaker.py View on Github external
This example shows how to crate an animate scene where
over a number of frames:
    - Different sets of neurons from the mouselight database are shown
    - The camera moves around 

Note that creating videos requires opencv which is not installed
with brainrender by default, please install with "pip install opencv-python"

"""


import brainrender

brainrender.WHOLE_SCREEN = False
brainrender.SHADER_STYLE = "cartoon"
brainrender.ROOT_ALPHA = 0.1


from brainrender.scene import Scene
import numpy as np
from random import choices
from tqdm import tqdm


from brainrender.Utils.camera import (
    top_camera,
    buildcam,
    sagittal_camera,
)
from brainrender.animation.video import CustomVideoMaker

github BrancoLab / BrainRender / Examples / user_data / add_object_to_scene.py View on Github external
"""
    This example shows how to add a 3d object to the scene by loading
    it from file and moving/scaling it to be aligned correctly.
    In this case the object is a .stl file of the mouse skull, 
    but it could be anything, including experimental and recording devices.

    Note that the mouse skull and brain meshes come from different sources
    so that's why they don't match perfectly.
"""


import brainrender

brainrender.SHADER_STYLE = "cartoon"
brainrender.ROOT_ALPHA = 1

from brainrender.scene import Scene

scene = Scene()

# Load skull from file
skull = scene.add_from_file("Examples/example_files/skull.stl")
skull.c("ivory").alpha(1)

# Align skull and brain (scene.root)
skull_com = skull.centerOfMass()
root_com = scene.root.centerOfMass()

skull.origin(skull.centerOfMass())
skull.rotateY(90).rotateX(180)
skull.x(root_com[0] - skull_com[0])
github BrancoLab / BrainRender / Examples / advanced / animated_scene.py View on Github external
"""
This example shows how to crate an animate scene where
over a number of frames:
    - Different sets of neurons from the mouselight database are shown
    - The camera moves around 
"""


import brainrender

brainrender.WHOLE_SCREEN = False
brainrender.SHADER_STYLE = "cartoon"
brainrender.ROOT_ALPHA = 0.1


from brainrender.scene import Scene
import time
import numpy as np
from random import choices
from rich.progress import track
from morphapi.api.mouselight import MouseLightAPI


from brainrender.Utils.camera import (
    buildcam,
    sagittal_camera,
)
from brainrender.colors import colorMap
github BrancoLab / BrainRender / Examples / mouse / colored_neurons.py View on Github external
"""
    This example shows how download neurons from the 
    mouselight datase with morphapi and render 
    them with a custom colors palette
"""

import brainrender

brainrender.SHADER_STYLE = "cartoon"
brainrender.ROOT_ALPHA = 0.3
brainrender.BACKGROUND_COLOR = "blackboard"


from brainrender.scene import Scene
from brainrender.colors import makePalette

from morphapi.api.mouselight import MouseLightAPI


# ---------------------------- Downloading neurons --------------------------- #
mlapi = MouseLightAPI()

# Fetch metadata for neurons with some in the secondary motor cortex
neurons_metadata = mlapi.fetch_neurons_metadata(
    filterby="soma", filter_regions=["MOs"]
)