def visualize_obj(obj_path, *args, color="lightcoral", **kwargs):
    """
        Uses brainrender to visualize a .obj file registered to the Allen CCF
        :param obj_path: str, path to a .obj file
        :param color: str, color of object being rendered
    """
    print("Visualizing : " + obj_path)
    scene = Scene(add_root=True)
    scene.add_from_file(obj_path, *args, c=color, **kwargs)

    return scene
Beispiel #2
0
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
    if file is not None:
        if file.endswith(".h5"):
            scene.add_cells_from_file(file)
        else:
            try:
                scene.add_from_file(file)
            except Exception as e:
                raise ValueError(
                    f"Failed to load data from file onto scene: {file}\n{e}"
                )

    # If debug set interactive = Off and close scene
    if not debug:
        interactive = True
    else:
        interactive = False

    # Render and close
    scene.render(interactive=interactive)

    if debug:
        scene.close()
Beispiel #3
0
    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])
skull.y(root_com[1] - skull_com[1])
skull.z(root_com[2] - skull_com[2])
skull.x(3500)
skull.rotateZ(-25)
skull.y(7800)
skull.scale([1300, 1500, 1200])