Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
filterby="soma", filter_regions=["MOs"]
)
neurons_files = ml_api.download_neurons(neurons_metadata[:N_neurons])
# ------------------------------- Create scene ------------------------------- #
scene = Scene(display_inset=False, use_default_key_bindings=True)
neurons_actors = scene.add_neurons(
neurons_files, neurite_radius=12, alpha=0
)
# Create new cameras
cam1 = buildcam(sagittal_camera)
cam2 = buildcam(
dict(
position=[-16624.081, -33431.408, 33527.412],
focal=[6587.835, 3849.085, 5688.164],
viewup=[0.634, -0.676, -0.376],
distance=51996.653,
clipping=[34765.671, 73812.327],
)
)
cam3 = buildcam(
dict(
position=[1862.135, -4020.792, -36292.348],
focal=[6587.835, 3849.085, 5688.164],
viewup=[0.185, -0.97, 0.161],
distance=42972.44,
clipping=[29629.503, 59872.10],
)
# Create new cameras
cam1 = buildcam(sagittal_camera)
cam2 = buildcam(
dict(
position=[-16624.081, -33431.408, 33527.412],
focal=[6587.835, 3849.085, 5688.164],
viewup=[0.634, -0.676, -0.376],
distance=51996.653,
clipping=[34765.671, 73812.327],
)
)
cam3 = buildcam(
dict(
position=[1862.135, -4020.792, -36292.348],
focal=[6587.835, 3849.085, 5688.164],
viewup=[0.185, -0.97, 0.161],
distance=42972.44,
clipping=[29629.503, 59872.10],
)
)
# ------------------------------- Create frames ------------------------------ #
# Create frames
prev_neurons = []
for step in track(
np.arange(N_FRAMES), total=N_FRAMES, description="Generating frames..."
):
if step % N_frames_for_change == 0: # change neurons every N framse
zoom = np.linspace(1, 1.35, N_FRAMES)
frac = np.zeros_like(
zoom
) # for camera transition, interpolation value between cameras
frac[:10] = np.linspace(0, 1, 10)
frac[10:] = np.linspace(1, 0, len(frac[10:]))
# ------------------------------- Create scene ------------------------------- #
scene = Scene(display_inset=True, use_default_key_bindings=True)
filepaths, data = scene.atlas.download_streamlines_for_region("TH")
scene.add_brain_regions(["TH"], alpha=0.2)
# Create new cameras
cam1 = buildcam(sagittal_camera)
cam2 = buildcam(top_camera)
cam3 = buildcam(
dict(
position=[1862.135, -4020.792, -36292.348],
focal=[6587.835, 3849.085, 5688.164],
viewup=[0.185, -0.97, 0.161],
distance=42972.44,
clipping=[29629.503, 59872.10],
)
)
# Iniziale camera position
scene.plotter.moveCamera(cam1, cam2, frac[0])
# ------------------------------- Create frames ------------------------------ #
def frame_maker(scene=None, video=None, videomaker=None):
for step in track(
frac = np.zeros_like(
zoom
) # for camera transition, interpolation value between cameras
frac[:10] = np.linspace(0, 1, 10)
frac[10:] = np.linspace(1, 0, len(frac[10:]))
# ------------------------------- Create scene ------------------------------- #
scene = Scene(display_inset=True, use_default_key_bindings=True)
filepaths, data = scene.atlas.download_streamlines_for_region("TH")
scene.add_brain_regions(["TH"], alpha=0.2)
# Create new cameras
cam1 = buildcam(sagittal_camera)
cam2 = buildcam(top_camera)
cam3 = buildcam(
dict(
position=[1862.135, -4020.792, -36292.348],
focal=[6587.835, 3849.085, 5688.164],
viewup=[0.185, -0.97, 0.161],
distance=42972.44,
clipping=[29629.503, 59872.10],
)
)
# Iniziale camera position
scene.plotter.moveCamera(cam1, cam2, frac[0])
# ------------------------------- Create frames ------------------------------ #
def frame_maker(scene=None, video=None, videomaker=None):
for step in track(
np.arange(N_FRAMES),
scene.add_brain_regions(["TH"], alpha=0.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(
position=[1862.135, -4020.792, -36292.348],
focal=[6587.835, 3849.085, 5688.164],
viewup=[0.185, -0.97, 0.161],
distance=42972.44,
clipping=[29629.503, 59872.10],
)
)
# Iniziale camera position
startcam = scene.plotter.moveCamera(cam1, cam2, frac[0])
# ------------------------------- Create frames ------------------------------ #
# Create frames
prev_streamlines = []
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=0.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(
position=[1862.135, -4020.792, -36292.348],
focal=[6587.835, 3849.085, 5688.164],
viewup=[0.185, -0.97, 0.161],
distance=42972.44,
clipping=[29629.503, 59872.10],
)
)
# Iniziale camera position
startcam = scene.plotter.moveCamera(cam1, cam2, frac[0])
# ------------------------------- Create frames ------------------------------ #
def frame_maker(scene=None, video=None, videomaker=None):
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=0.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(
position=[1862.135, -4020.792, -36292.348],
focal=[6587.835, 3849.085, 5688.164],
viewup=[0.185, -0.97, 0.161],
distance=42972.44,
clipping=[29629.503, 59872.10],
)
)
# Iniziale camera position
startcam = scene.plotter.moveCamera(cam1, cam2, frac[0])
# ------------------------------- Create scene ------------------------------- #
scene = Scene(display_inset=False, use_default_key_bindings=True)
root = scene.actors["root"]
scene.add_neurons(neurons_files, 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
cam1 = buildcam(sagittal_camera)
cam2 = buildcam(
dict(
position=[-16624.081, -33431.408, 33527.412],
focal=[6587.835, 3849.085, 5688.164],
viewup=[0.634, -0.676, -0.376],
distance=51996.653,
clipping=[34765.671, 73812.327],
)
)
cam3 = buildcam(
dict(
position=[1862.135, -4020.792, -36292.348],
focal=[6587.835, 3849.085, 5688.164],
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=0.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(
position=[1862.135, -4020.792, -36292.348],
focal=[6587.835, 3849.085, 5688.164],
viewup=[0.185, -0.97, 0.161],
distance=42972.44,
clipping=[29629.503, 59872.10],
)
)
# Iniziale camera position
startcam = scene.plotter.moveCamera(cam1, cam2, frac[0])
# ------------------------------- Create frames ------------------------------ #
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=0.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(
position=[1862.135, -4020.792, -36292.348],
focal=[6587.835, 3849.085, 5688.164],
viewup=[0.185, -0.97, 0.161],
distance=42972.44,
clipping=[29629.503, 59872.10],
)
)
# Iniziale camera position
startcam = scene.plotter.moveCamera(cam1, cam2, frac[0])
# ------------------------------- Create frames ------------------------------ #