Esempio n. 1
0
def NeuronsScene3():
    scene = Scene()

    neurons_metadata = mouselight_fetch_neurons_metadata(
        filterby='soma', filter_regions=['VAL'])
    neurons_files = mlapi.download_neurons(neurons_metadata[2:6])
    scene.add_neurons(neurons_files,
                      soma_color='deepskyblue',
                      force_to_hemisphere="right")

    scene.add_brain_regions(['VAL'],
                            use_original_color=False,
                            colors='palegreen',
                            alpha=.9)
    mos = scene.actors['regions']['VAL']
    scene.edit_actors([mos], wireframe=True)

    streamlines_files, data = streamlines_api.download_streamlines_for_region(
        "VAL")
    scene.add_streamlines(data[:1],
                          color="palegreen",
                          show_injection_site=False,
                          alpha=.2,
                          radius=10)

    scene.render()
Esempio n. 2
0
def test_streamlines():
    streamlines_api = StreamlinesAPI()

    streamlines_files, data = streamlines_api.download_streamlines_for_region("PAG") 

    scene = Scene()
    scene.add_streamlines(data[3], color="powderblue", show_injection_site=False, alpha=.3, radius=10)
    scene.add_brain_regions(['PAG'], use_original_color=False, colors='powderblue', alpha=.9)
    mos = scene.actors['regions']['PAG']
    scene.edit_actors([mos], wireframe=True) 
Esempio n. 3
0
def NeuronsScene2():
    scene = Scene()

    neurons_metadata = mouselight_fetch_neurons_metadata(filterby='soma', filter_regions=['MOp5'])
    neurons_files =  mlapi.download_neurons(neurons_metadata[2:6]) 
    scene.add_neurons(neurons_files, soma_color='deepskyblue', force_to_hemisphere="right")

    streamlines_files, data = streamlines_api.download_streamlines_for_region("MOp") 
    scene.add_streamlines(data[:1], color="palegreen", show_injection_site=False, alpha=.2, radius=10)

    set_camera(scene)
    scene.render()
Esempio n. 4
0
def test_streamlines():
    scene = Scene()

    filepaths, data = scene.atlas.download_streamlines_for_region("CA1")

    scene.add_brain_regions(['CA1'], use_original_color=True, alpha=.2)

    scene.add_streamlines(data,
                          color="darkseagreen",
                          show_injection_site=False)

    scene.render(camera='sagittal', zoom=1, interactive=False)
    scene.close()
Esempio n. 5
0
def test_streamlines():
    from brainrender.Utils.parsers.streamlines import StreamlinesAPI

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

    # Start by creating a scene
    scene = Scene()

    scene.add_brain_regions(['CA1'], use_original_color=True, alpha=.2)

    # you can pass either the filepaths or the data
    scene.add_streamlines(data, color="darkseagreen", show_injection_site=False)

    scene.render(interactive=False, camera='sagittal', zoom=1)
    scene.close()
Esempio n. 6
0
def StreamlinesScene2():
    scene = Scene()

    streamlines_files, data = streamlines_api.download_streamlines_for_region("VAL") 
    scene.add_streamlines(data, color="palegreen", show_injection_site=False, alpha=.3, radius=10)

    streamlines_files, data = streamlines_api.download_streamlines_for_region("VM") 
    scene.add_streamlines(data, color="palevioletred", show_injection_site=False, alpha=.3, radius=10)

    
    scene.add_brain_regions(['VAL'], use_original_color=False, colors='palegreen', alpha=.9, hemisphere='right')
    mos = scene.actors['regions']['VAL']
    scene.edit_actors([mos], wireframe=True) 

    scene.add_brain_regions(['VM'], use_original_color=False, colors='palevioletred', alpha=.9, hemisphere='right')
    mos = scene.actors['regions']['VM']
    scene.edit_actors([mos], wireframe=True) 

    set_camera(scene)
    scene.render() 
Esempio n. 7
0
N_streamlines_in_frame = 2  # number of streamlines to be highlighted in a given frame
N_frames_for_change = 15  # every N frames which streamlines are shown changes

# Variables to specify camera position at each frame
zoom = np.linspace(1, 1.5, N_FRAMES)
frac = np.zeros_like(
    zoom)  # for camera transition, interpolation value between cameras
frac[:150] = np.linspace(0, 1, 150)
frac[150:] = np.linspace(1, 0, len(frac[150:]))

# ------------------------------- Create scene ------------------------------- #
scene = Scene(display_inset=True, use_default_key_bindings=True)
root = scene.actors['root']

filepaths, data = scene.atlas.download_streamlines_for_region("TH")
scene.add_streamlines(data, color="darkseagreen", show_injection_site=False)

scene.add_brain_regions(['TH'], alpha=.2)

# Make all streamlines background
for mesh in scene.actors['tracts']:
    mesh.alpha(minalpha)
    mesh.color(darkcolor)

# Create new cameras
cam1 = buildcam(sagittal_camera)

cam2 = buildcam(top_camera)

cam3 = buildcam(
    dict(
Esempio n. 8
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)
        if cell == 'AA0271' or cell == 'AA0876' or cell.startswith(
                '17781') or cell == 'AA0649' or cell == 'AA0898':
            cfp = cell + '.json'
        else:
            cfp = cell + '_reversed.json'
        nfp = os.path.join(cells_base_dir, cfp)
        scene.add_neurons(nfp,
                          soma_color=cell_colors[cell],
                          dendrites_color='black',
                          axon_color=cell_colors[cell],
                          neurite_radius=18)

    # Add streamlines
    for streamline in fig['streamlines']:
        scene.add_streamlines(sl_filepaths[streamline],
                              color=sl_colors[streamline],
                              show_injection_site=True)

    # # angle 1
    # bespoke_camera = dict(
    #     position = [-1, -.3, .7] ,
    #     focal = [0, 0, 0],
    #     viewup = [0, -1, 0],
    #     distance = 9522.144,
    #     clipping = [5892.778, 14113.736],
    # )
    # scene.render(interactive=False,camera=bespoke_camera, zoom=1)
    # scene.take_screenshot()
    # time.sleep(1)
    # angle 2
    # bespoke_camera = dict(
Esempio n. 10
0
def test_streamlines():
    scene = Scene()
    streamlines_files = listdir("Examples/example_files/streamlines")[:2]
    scene.add_streamlines(streamlines_files, color="green")