How to use the brainrender.SHADER_STYLE 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
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
    brainrender.VERBOSE
    brainrender.HDF_SUFFIXES
    brainrender.DEFAULT_HDF_KEY

    brainrender.reset_defaults()
github BrancoLab / BrainRender / Examples / basic / cut_with_plane2.py View on Github external
"""
    This example shows how to cut selected actors in the scene using a 
    custom plane 
"""

import brainrender

brainrender.SHADER_STYLE = "cartoon"
from brainrender.scene import Scene


scene = Scene(use_default_key_bindings=True)

# Add some actors
th = scene.add_brain_regions(["STR", "TH"], alpha=0.5)

# Specify position, size and orientation of the plane
pos = scene.atlas._root_midpoint
sx, sy = 15000, 15000
norm = [0, 1, 1]
plane = scene.atlas.get_plane_at_point(
    pos, norm=norm, sx=sx, sy=sy, color="lightblue"
)
github BrancoLab / BrainRender / Examples / basic / add_text_3d.py View on Github external
"""
    This example shows how to add 3D text to your scenes
"""

import brainrender

brainrender.SHADER_STYLE = "cartoon"

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


camera = dict(
    {
        "position": (4.58173814842751, 1.3170832519052862, 28.807539941401348),
        "focal": (5.63320729136467, 0.0, 0.13752250373363495),
        "viewup": (
            0.008857944291024357,
            0.9989221022772287,
            -0.04556501294830602,
        ),
        "distance": 28.719508970857582,
github BrancoLab / BrainRender / Examples / mouse / tractography.py View on Github external
""" 
    This tutorial shows how download and rendered afferent mesoscale projection data
    using the AllenBrainAtlas (ABA) and Scene classes
"""
import brainrender

brainrender.SHADER_STYLE = "cartoon"
from brainrender.scene import Scene
from brainrender.atlases.mouse import ABA


# Create a scene
scene = Scene(title="tractography")

# Get the center of mass of the region of interest
p0 = scene.atlas.get_region_CenterOfMass("ZI")

# Get projections to that point
analyzer = ABA()
tract = analyzer.get_projection_tracts_to_target(p0=p0)

# Add the brain regions and the projections to it
scene.add_brain_regions(["ZI"], alpha=0.4, use_original_color=True)
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,
)
github BrancoLab / BrainRender / Examples / basic / cartoon_look.py View on Github external
"""
    This example shows how to create a scene that has a cartoony look 
    (good for schematics and illustrations)
"""

import brainrender

brainrender.SHADER_STYLE = "cartoon"  # gives actors a flat shading
from brainrender.scene import Scene

scene = Scene()
th = scene.add_brain_regions("TH", alpha=0.5)

# Create a black line around each actor
scene.add_silhouette(scene.root)
scene.add_silhouette(th, lw=3)

scene.render()
github BrancoLab / BrainRender / Examples / export / basic_video_maker.py View on Github external
import brainrender

brainrender.WHOLE_SCREEN = True
brainrender.SHADER_STYLE = "cartoon"
from brainrender.scene import Scene


from brainrender.animation.video import BasicVideoMaker


scene = Scene(display_inset=False, camera="sagittal")

scene.add_brain_regions(["MOs"])
scene.add_neurons("Examples/example_files/neuron1.swc", color="black")

vmkr = BasicVideoMaker(scene)

vmkr.make_video(azimuth=1, niters=36, duration=30, save_name="test")
github BrancoLab / BrainRender / Examples / custom_atlases / insects_brains.py View on Github external
import brainrender

brainrender.SHADER_STYLE = "cartoon"
brainrender.ROOT_ALPHA = 0.2
from brainrender.scene import Scene

from brainrender.atlases.ccustom_atlases.insects_brains_db import (
    IBDB,
)  # ! this class is the atlas for insects brains

"""
    In this tutorial you can see how to use brainrender to fetch
    and render 3D rendering of brain regions from a number of insects brains.

    All data is hosted by: https://insectbraindb.org/app/
    Please read their terms of use (https://insectbraindb.org/app/terms)
    Also please refer to the website to find the original source of these datasets

    You can also visualize these data interactively at: https://insectbraindb.org/app/three;controls=true;mode=species
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"]
github BrancoLab / BrainRender / brainrender / cli.py View on Github external
def main(regions, atlas=None, cartoon=False, debug=False, file=None):
    # Set look
    if cartoon:
        brainrender.SHADER_STYLE = "cartoon"

    # Create scene
    scene = Scene(atlas=atlas)

    # Add brain regions
    if regions is not None and len(regions) > 0:
        acts = scene.add_brain_regions(list(regions))

        # Add silhouettes
        if cartoon:
            if isinstance(acts, list):
                scene.add_silhouette(*acts)
            else:
                scene.add_silhouette(acts)

    # Add data from file