Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def download_and_write_mesh(self, acronym, obj_path):
print(f"Downloading mesh data for {acronym}")
path = self.structures.loc[
self.structures.acronym == acronym
].obj_path.values[0]
url = f"{self._url_paths['data']}/{path}"
# download and write .obj
mesh_data = request(url).content.decode("utf-8").split("\n")
with open(obj_path, "w") as f:
for md in mesh_data:
f.write(f"{md}\n")
f.close()
# return the vtk actor
return load(obj_path)
def load_mesh_from_file(filepath, *args, **kwargs):
"""
Load a a mesh or volume from files like .obj, .stl, ...
:param filepath: path to file
:param **kwargs:
"""
actor = load(str(filepath))
color = kwargs.pop("color", None)
alpha = kwargs.pop("alpha", None)
if color is not None:
actor.c(color)
if alpha is not None:
actor.alpha(alpha)
return actor
def _get_structure_mesh(self, acronym, **kwargs):
"""
Get's the mesh for a brainregion, for this atlas it's just for
getting/making the root mesh
"""
if acronym != "root":
raise ValueError(
f"The atlas {self.atlas_name} only has one structure mesh: root. Argument {acronym} is not valid"
)
objpath = os.path.join(self.data_folder, "objs_smoothed", "root2.obj")
if not os.path.isfile(objpath):
root = self._make_root(objpath)
else:
root = load(objpath)
root.c(ROOT_COLOR).alpha(ROOT_ALPHA)
return root