Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _get_structure_mesh(self, acronym, **kwargs):
obj_path = self._get_from_structure(acronym, "mesh_filename")
return load_mesh_from_file(obj_path, **kwargs)
def _get_structure_mesh(self, acronym, **kwargs):
obj_path = self._get_from_structure(acronym, "mesh_filename")
return load_mesh_from_file(obj_path, **kwargs)
color="black",
verbose=False,
alpha=0,
radius=self.synapses_radius * 4,
res=24,
col_names=col_names,
),
)
)
# Get mesh points for neuron the synapses belong to
if neuron not in scene_store.keys():
neuron_file = [
f for f in self.neurons_files if neuron in f
][0]
neuron_act = load_mesh_from_file(neuron_file, c=color)
else:
neuron_act, as_skeleton = scene_store[neuron]
# Draw post synapses as dark patches
if draw_patches:
if as_skeleton:
print(
"Can't display post synapses as dark spots when neron is rendered in skeleton mode"
)
else:
# Get faces that are inside the synapses spheres and color them darker
raise NotImplementedError("This needs some fixing")
# neuron_points = neuron_act.cellCenters()
# inside_points = spheres.insidePoints(
# neuron_points, returnIds=True
"""
if self.structures is None:
print("No atlas was loaded, use self.get_brain first")
return None
if region not in list(self.structures['name']):
print(f"Acronym {region} not in available regions: {self.structures}")
return None
# Get obj file path
obj_path = os.path.join(self.meshes_folder, "{}.vtk".format(region))
# Load
if self._check_obj_file(region, obj_path):
mesh = load_mesh_from_file(obj_path, **kwargs)
return mesh
else:
mesh = self.download_and_save_mesh(region, obj_path)
return mesh
Fetches the mesh for a brain region from the atlas.
:param region: string, name of brain region
:param **kwargs:
"""
if region not in list(self.structures['acronym']):
print(f"Acronym {region} not in available regions: {self.structures}")
return None
# Get obj file path
obj_path = os.path.join(self.meshes_folder, "{}.vtk".format(region))
# Load
if self._check_obj_file(region, obj_path):
mesh = load_mesh_from_file(obj_path, **kwargs)
return mesh
else:
mesh = self.save_structure_mesh(region, obj_path)
return mesh
raise ValueError(
f"Acronym {acronym} not in available regions: {self.structures}"
)
# Get obj file path
if acronym != "root":
mesh_format = self.mesh_format
else:
mesh_format = "vtk"
obj_path = os.path.join(
self.meshes_folder, "{}.{}".format(acronym, mesh_format)
)
# Load
if self._check_obj_file(acronym, obj_path):
mesh = load_mesh_from_file(obj_path, **kwargs)
return mesh
else:
mesh = self.download_and_write_mesh(acronym, obj_path)
return None
else:
color = self.get_neuron_color(neuron, colorby=colorby)
if as_skeleton: # reconstruct skeleton from json
actor = self._parse_neuron_skeleton(neuron)
else: # load as .obj file
try:
neuron_file = [
f for f in self.neurons_files if neuron in f
][0]
except:
print(f"Could not find .obj file for neuron {neuron}")
continue
actor = load_mesh_from_file(neuron_file)
if actor is not None:
# Refine actor's look
actor.alpha(alpha).c(color)
actors.append(actor)
store[neuron] = (actor, as_skeleton)
return actors, store
def _get_structure_mesh(self, acronym, **kwargs):
obj_path = self._get_from_structure(acronym, "mesh_filename")
return load_mesh_from_file(obj_path, **kwargs)