Exemplo n.º 1
0
def test_text_3d(scene):
    # Text to add
    s = "BRAINRENDER"

    # Specify a color for each letter
    colors = makePalette(len(s), "salmon", "powderblue")

    x = 0  # use to specify the position of each letter
    # Add letters one at the time to color them individually
    for n, letter in enumerate("BRAINRENDER"):
        if "I" == letter or "N" == letter and n < 5:  # make the spacing right
            x += 0.6
        else:
            x += 1

        # Add letter and silhouette to the scne
        act = Text(letter,
                   depth=0.5,
                   c=colors[n],
                   pos=(x, 0, 0),
                   justify="centered")
        sil = act.silhouette().lw(3).color("k")
        scene.add_actor(act, sil)

    scene.render(interactive=False)
    scene.close()
Exemplo n.º 2
0
"""
    This tutorial shows you how to render efferent mesoscale connectivity
    data from the Allen mouse connectome project as streamlines coloring
    each injection's streamline individually. 

"""

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

# Start by creating a scene with the allen brain atlas atlas
scene = Scene(title="streamlines")

# Download streamlines data for injections in the CA1 field of the hippocampus
filepaths, data = scene.atlas.download_streamlines_for_region("CA1")

scene.add_brain_regions(["CA1"], use_original_color=True, alpha=0.2)

# you can pass either the filepaths or the data
colors = makePalette(len(data), "salmon", "lightgreen")
scene.add_streamlines(data, color=colors, show_injection_site=False)

scene.render(camera="sagittal", zoom=1)
Exemplo n.º 3
0
brainrender.SHADER_STYLE = 'cartoon'

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


# Crate a scene
scene = Scene(add_root=False, display_inset=False, use_default_key_bindings=False)


# Text to add
s = 'BRAINRENDER'

# Specify a color for each letter
colors = makePalette('salmon', 'powderblue', N=len(s))

x = 0 # use to specify the position of each letter

# Add letters one at the time to color them individually
for n, letter in enumerate('BRAINRENDER'):
    if 'I' == letter or 'N' == letter and n <5: # make the spacing right 
        x += .6
    else:
        x += 1
    
    # Add letter and silhouette to the scne
    act = Text(letter, depth=.5, c=colors[n], pos=(x, 0, 0), justify='centered')
    sil = act.silhouette().lw(3).color('k')
    scene.add_vtkactor(act, sil)
Exemplo n.º 4
0
def test_streamlines_colored(scene):

    filepaths, data = scene.atlas.download_streamlines_for_region("CA1")
    colors = makePalette(len(data), "salmon", "lightgreen")
    scene.add_streamlines(data, color=colors, show_injection_site=False)
    scene.add_streamlines(filepaths, color=None, show_injection_site=True)
Exemplo n.º 5
0
brainrender.SHADER_STYLE = 'cartoon'

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

# Crate a scene
scene = Scene(add_root=False,
              display_inset=False,
              use_default_key_bindings=False)

# Text to add
s = 'BRAINRENDER'

# Specify a color for each letter
colors = makePalette(len(s), 'salmon', 'powderblue')

x = 0  # use to specify the position of each letter

# Add letters one at the time to color them individually
for n, letter in enumerate('BRAINRENDER'):
    if 'I' == letter or 'N' == letter and n < 5:  # make the spacing right
        x += .6
    else:
        x += 1

    # Add letter and silhouette to the scne
    act = Text(letter,
               depth=.5,
               c=colors[n],
               pos=(x, 0, 0),
Exemplo n.º 6
0
    reconstructions aligned to the zebra fish atlas.
"""

# Use morphapi's API to download the neurons
api = MpinMorphologyAPI()

# the first time you use this dataset you'll have to download the data
# api.download_dataset()

# ----------------------------- Download dataset ----------------------------- #
"""
    If it's the first time using this API, you'll have to download the dataset
    with all of the neurons' data.
"""
# Select a few neurons for a specific brain region
neurons_ids = api.get_neurons_by_structure(837)
neurons = api.load_neurons(neurons_ids)

# Create meshes for each neuron

neurons = [
    neuron.create_mesh(soma_radius=1, neurite_radius=1)[1]
    for neuron in neurons
]
colors = makePalette(len(neurons), "salmon", "powderblue")

# ------------------------------- Visualisation ------------------------------ #
scene = Scene(atlas="mpin_zfish_1um", add_root=True, camera="sagittal2")
scene.add_neurons(neurons, color=colors)
scene.render()
Exemplo n.º 7
0
from brainrender.colors import makePalette

from morphapi.morphology.morphology import Neuron
from morphapi.api.mouselight import MouseLightAPI, mouselight_structures_identifiers

# ---------------------------- 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'])

# Then we can download the files and save them as a .json file
neurons = mlapi.download_neurons(
    neurons_metadata[:50])  # 50 neurons, might take a while the first time

# ----------------------------- Rendering neurons ---------------------------- #

# Create a custom colormap between 3 colors
colors = makePalette(len(neurons), 'salmon', 'lightgreen')

# Create scene
scene = Scene(add_root=True, display_inset=False)

# Add each neuron with it's color
scene.add_neurons(neurons, alpha=.8, neurite_radius=8, color=colors)

# Cut all actors to expose neurons
scene.cut_actors_with_plane('sagittal')
scene.render()
Exemplo n.º 8
0
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"])

# Then we can download the files and save them as a .json file
neurons = mlapi.download_neurons(
    neurons_metadata[:50])  # 50 neurons, might take a while the first time

# ----------------------------- Rendering neurons ---------------------------- #

# Create a custom colormap between 3 colors
colors = makePalette(len(neurons), "salmon", "lightgreen")

# Create scene
scene = Scene(add_root=True, display_inset=False, title="neurons")

# Add each neuron with it's color
scene.add_neurons(neurons, alpha=0.8, neurite_radius=8, color=colors)

# Cut all actors to expose neurons
scene.cut_actors_with_plane("sagittal")
scene.render()