Exemplo n.º 1
0
def test_mouselight():
    from brainrender.Utils.MouseLightAPI.mouselight_api import MouseLightAPI
    from brainrender.Utils.MouseLightAPI.mouselight_info import mouselight_api_info, mouselight_fetch_neurons_metadata

    # Fetch metadata for neurons with some in the secondary motor cortex
    neurons_metadata = mouselight_fetch_neurons_metadata(
        filterby='soma', filter_regions=['MOs'])

    # Then we can download the files and save them as a .json file
    ml_api = MouseLightAPI()
    neurons_files = ml_api.download_neurons(
        neurons_metadata[:2]
    )  # just saving the first couple neurons to speed things up

    # Show neurons and ZI in the same scene:
    scene = Scene()
    scene.add_neurons(
        neurons_files,
        soma_color='orangered',
        dendrites_color='orangered',
        axon_color='darkseagreen',
        neurite_radius=8
    )  # add_neurons takes a lot of arguments to specify how the neurons should look
    # make sure to check the source code to see all available optionsq

    scene.add_brain_regions(['MOs'], alpha=0.15)
    scene.render(camera='coronal')
Exemplo n.º 2
0
def test_neurons():
    scene = Scene()
    mlapi = MouseLightAPI()
    neurons_metadata = mouselight_fetch_neurons_metadata(filterby='soma', filter_regions=['MOs'])
    neurons_files =  mlapi.download_neurons(neurons_metadata[:2])

    parser = NeuronsParser(scene=scene, 
                        color_neurites=True, axon_color="antiquewhite", 
                        soma_color="darkgoldenrod", dendrites_color="firebrick")
    neurons, regions = parser.render_neurons(neurons_files)

    scene.add_neurons(neurons_files, color_neurites=False, random_color="jet", display_axon_regions=False)
Exemplo n.º 3
0
    You can also download data manually from the neuronbrowser website and render them by
    passing the downloaded files to `scene.add_neurons`.
"""
import brainrender
brainrender.USE_MORPHOLOGY_CACHE = True
from brainrender.scene import Scene
from brainrender.Utils.MouseLightAPI.mouselight_api import MouseLightAPI
from brainrender.Utils.MouseLightAPI.mouselight_info import mouselight_api_info, mouselight_fetch_neurons_metadata

# Fetch metadata for neurons with some in the secondary motor cortex
neurons_metadata = mouselight_fetch_neurons_metadata(filterby='soma',
                                                     filter_regions=['MOs'])

# Then we can download the files and save them as a .json file
ml_api = MouseLightAPI()
neurons_files = ml_api.download_neurons(
    neurons_metadata[:2]
)  # just saving the first couple neurons to speed things up

# Show neurons and ZI in the same scene:
scene = Scene()
scene.add_neurons(
    neurons_files,
    soma_color='orangered',
    dendrites_color='orangered',
    axon_color='darkseagreen',
    neurite_radius=8
)  # add_neurons takes a lot of arguments to specify how the neurons should look
# make sure to check the source code to see all available optionsq
Exemplo n.º 4
0
import brainrender
brainrender.SHADER_STYLE = 'cartoon'

from brainrender.scene import Scene
from brainrender.Utils.ABA.connectome import ABA

from brainrender.Utils.MouseLightAPI.mouselight_info import mouselight_api_info, mouselight_fetch_neurons_metadata
from brainrender.Utils.MouseLightAPI.mouselight_api import MouseLightAPI

from brainrender.Utils.parsers.streamlines import StreamlinesAPI
from brainrender.Utils.data_io import listdir
from brainrender.colors import get_n_shades_of

aba = ABA()
streamlines_api = StreamlinesAPI()
mlapi = MouseLightAPI()

# ---------------------------------------------------------------------------- #
#                   DEFINE A FUNCTION FOR EACH EXAMPLE SCENE                   #
# ---------------------------------------------------------------------------- #


def BrainRegionsScene():
    scene = Scene()
    scene.add_brain_regions(['TH', 'VP'], use_original_color=True, alpha=1)

    act = scene.actors['regions']['TH']
    scene.edit_actors([act], wireframe=True)

    scene.render()
Exemplo n.º 5
0
def test_imports():
    aba = ABA()
    streamlines_api = StreamlinesAPI()
    mlapi = MouseLightAPI()
Exemplo n.º 6
0
N_frames_for_change = 15  # every N frames which neurons 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:]))

# -------------------------------- Fetch data -------------------------------- #
# Fetch metadata for neurons with some in the secondary motor cortex
neurons_metadata = mouselight_fetch_neurons_metadata(filterby='soma',
                                                     filter_regions=['MOs'])

# Then we can download the files and save them as a .json file
ml_api = MouseLightAPI()
neurons_files = ml_api.download_neurons(neurons_metadata[:N_neurons])

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

scene.add_neurons(neurons_files, random_color=True, neurite_radius=12, alpha=0)

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

# Create new cameras