Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Deal with neuron as instance of Neuron from morphapi
elif isinstance(neuron, Neuron):
neuron_actors, _ = get_neuron_actors_with_morphapi(
neuron=neuron
)
# Deal with other inputs
else:
raise ValueError(
f"Passed neuron {neuron} is not a valid input"
)
# Check that we don't have anything weird in neuron_actors
for key, act in neuron_actors.items():
if act is not None:
if not isinstance(act, Actor):
raise ValueError(
f"Neuron actor {key} is {act.__type__} but should be a vedo Mesh. Not: {act}"
)
if not display_axon:
neuron_actors["axon"] = None
if not display_dendrites:
neuron_actors["dendrites"] = None
_neurons_actors.append(neuron_actors)
# Color actors
for n, neuron in enumerate(_neurons_actors):
if neuron["axon"] is not None:
neuron["axon"].c(colors["axon"][n])
neuron["soma"].c(colors["soma"][n])
if neuron["dendrites"] is not None:
if os.path.isfile(neuron):
if neuron.endswith(".swc"):
neuron_actors, _ = get_neuron_actors_with_morphapi(
swcfile=neuron, neurite_radius=neurite_radius
)
else:
raise NotImplementedError(
"Currently we can only parse morphological reconstructions from swc files"
)
else:
raise ValueError(
f"Passed neruon {neuron} is not a valid input. Maybe the file doesn't exist?"
)
# Deal with neuron as single actor
elif isinstance(neuron, Actor):
# A single actor was passed, maybe it's the entire neuron
neuron_actors["soma"] = neuron # store it as soma anyway
pass
# Deal with neuron as dictionary of actor
elif isinstance(neuron, dict):
neuron_actors["soma"] = neuron.pop("soma", None)
neuron_actors["axon"] = neuron.pop("axon", None)
# Get dendrites actors
if (
"apical_dendrites" in neuron.keys()
or "basal_dendrites" in neuron.keys()
):
if "apical_dendrites" not in neuron.keys():
neuron_actors["dendrites"] = neuron["basal_dendrites"]