Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_custom_video():
from brainrender.animation.video import CustomVideoMaker
# --------------------------------- Variables -------------------------------- #
N_FRAMES = 20
# Variables to specify camera position at each frame
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],
)
)
brainrender.DEFAULT_STRUCTURE_ALPHA
brainrender.INJECTION_VOLUME_SIZE
brainrender.TRACTO_RADIUS
brainrender.TRACTO_ALPHA
brainrender.TRACTO_RES
brainrender.TRACT_DEFAULT_COLOR
brainrender.INJECTION_DEFAULT_COLOR
brainrender.STREAMLINES_RESOLUTION
brainrender.INJECTION_VOLUME_SIZE
brainrender.TRACTO_RADIUS
brainrender.TRACTO_ALPHA
brainrender.TRACTO_RES
brainrender.TRACT_DEFAULT_COLOR
brainrender.INJECTION_DEFAULT_COLOR
brainrender.STREAMLINES_RESOLUTION
brainrender.SHADER_STYLE
brainrender.VERBOSE
brainrender.HDF_SUFFIXES
brainrender.DEFAULT_HDF_KEY
brainrender.reset_defaults()
getColor("#ffffff")
getColor(7)
getColor(-7)
getColorName("#ffffff")
cols = colorMap([0, 1, 2])
if not isinstance(cols, (list, np.ndarray)):
raise ValueError
if len(cols) != 3:
raise ValueError
c = colorMap(3, vmin=-3, vmax=4)
check_colors(cols)
check_colors(c)
getColor("k")
getColor("#ffffff")
getColor(7)
getColor(-7)
getColorName("#ffffff")
cols = colorMap([0, 1, 2])
if not isinstance(cols, (list, np.ndarray)):
raise ValueError
if len(cols) != 3:
raise ValueError
c = colorMap(3, vmin=-3, vmax=4)
check_colors(cols)
check_colors(c)
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),
def test_default():
brainrender.DISPLAY_INSET
brainrender.DISPLAY_ROOT
brainrender.WHOLE_SCREEN
brainrender.BACKGROUND_COLOR
brainrender.SHOW_AXES
brainrender.WINDOW_POS
brainrender.CAMERA
brainrender.DEFAULT_SCREENSHOT_NAME
brainrender.DEFAULT_SCREENSHOT_TYPE
brainrender.DEFAULT_SCREENSHOT_SCALE
brainrender.SCREENSHOT_TRANSPARENT_BACKGROUND
brainrender.ROOT_COLOR
brainrender.ROOT_ALPHA
brainrender.DEFAULT_STRUCTURE_COLOR
brainrender.DEFAULT_STRUCTURE_ALPHA
brainrender.INJECTION_VOLUME_SIZE
brainrender.TRACTO_RADIUS
brainrender.TRACTO_ALPHA
brainrender.TRACTO_RES
brainrender.TRACT_DEFAULT_COLOR
brainrender.INJECTION_DEFAULT_COLOR
brainrender.STREAMLINES_RESOLUTION
brainrender.INJECTION_VOLUME_SIZE
brainrender.TRACTO_RADIUS
brainrender.TRACTO_ALPHA
brainrender.TRACTO_RES
brainrender.TRACT_DEFAULT_COLOR
brainrender.INJECTION_DEFAULT_COLOR
brainrender.STREAMLINES_RESOLUTION
def test_io():
fld = os.getcwd()
if not isinstance(listdir(fld), list):
raise ValueError(f"listdir returned: {listdir(fld)}")
if not isinstance(get_subdirs(fld), list):
raise ValueError(f"get_subdirs returned: {get_subdirs(fld)}")