Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"INTERACTIVE_MSG",
"CAMERA",
"DEFAULT_SCREENSHOT_NAME",
"DEFAULT_SCREENSHOT_TYPE",
"DEFAULT_SCREENSHOT_SCALE",
"SCREENSHOT_TRANSPARENT_BACKGROUND",
]
# -------------------------- Set vedo shaders -------------------------- #
from vedo import settings
settings.useDepthPeeling = (
True # necessary for rendering of semitransparent actors
)
settings.useFXAA = True # necessary for rendering of semitransparent actors
# ------------------------- reset default parameters file ------------------------- #
params_file = Path(os.path.expanduser("~")) / ".brainrender" / "config.yaml"
defaults = brainrender.default_variables.__dict__
comment = (
"# Rendering options. An explanation for each parameter can be found "
+ "in the documentation or in brainrender.default_variables.py\n"
)
def reset_defaults():
# Get all variables from defaults
vs = {
key: value
for key, value in defaults.items()
"name", brainrender.DEFAULT_SCREENSHOT_NAME
)
self.screenshots_extension = screenshot_kwargs.pop(
"type", brainrender.DEFAULT_SCREENSHOT_TYPE
)
self.screenshots_scale = screenshot_kwargs.pop(
"scale", brainrender.DEFAULT_SCREENSHOT_SCALE
)
if not use_default_key_bindings:
self.plotter.keyPressFunction = self.keypress
self.verbose = False
if not brainrender.SCREENSHOT_TRANSPARENT_BACKGROUND:
vedosettings.screenshotTransparentBackground = False
vedosettings.useFXAA = True
def __init__(self, *args, **kwargs):
self.default_neuron_color = kwargs.pop(
"default_neuron_color", "darksalmon"
)
show_axes = kwargs.pop("show_axes", True)
axes_kwargs = kwargs.pop("axes_kwargs", 1)
settings.DEFAULT_NEURITE_RADIUS = ("neurite_radius", 18)
if axes_kwargs == 1:
settings.useDepthPeeling = (
False # necessary to make the axes render properly
)
settings.useFXAA = False
# Initialise scene class
Scene.__init__(
self, add_root=False, display_inset=False, *args, **kwargs
)
if show_axes:
brainrender.SHOW_AXES = True
if axes_kwargs == 1:
self.plotter.axes = self._default_axes_params
else:
self.plotter.axes = axes_kwargs
# Check we have all the params
for par in __all__:
if par in ["INTERACTIVE_MSG"]:
continue
if par not in params.keys():
params[par] = defaults[par]
save_yaml(str(params_file), params, append=False, topcomment=comment)
# ------------------------- Other vedo settings ------------------------ #
settings.screeshotScale = params[
"DEFAULT_SCREENSHOT_SCALE"
] # Improves resolution of saved screenshots
if params["SCREENSHOT_TRANSPARENT_BACKGROUND"]:
settings.screenshotTransparentBackground = True # vedo for transparent bg
settings.useFXAA = False # This needs to be false for transparent bg
warnings.warn(
"BRAINRENDER - settings: screenshots are set to have transparent background. Set the parameter 'SCREENSHOT_TRANSPARENT_BACKGROUND' to False if you'd prefer a not transparent background"
)
# Set to make it easy to import
DEFAULT_ATLAS = params["DEFAULT_ATLAS"]
BACKGROUND_COLOR = params["BACKGROUND_COLOR"]
DEFAULT_HDF_KEY = params["DEFAULT_HDF_KEY"]
DEFAULT_NEURITE_RADIUS = params["DEFAULT_NEURITE_RADIUS"]
DEFAULT_STRUCTURE_ALPHA = params["DEFAULT_STRUCTURE_ALPHA"]
DEFAULT_STRUCTURE_COLOR = params["DEFAULT_STRUCTURE_COLOR"]
DISPLAY_INSET = params["DISPLAY_INSET"]
DISPLAY_ROOT = params["DISPLAY_ROOT"]
HDF_SUFFIXES = params["HDF_SUFFIXES"]
INJECTION_DEFAULT_COLOR = params["INJECTION_DEFAULT_COLOR"]