def _make_root(self, rootpath): """ Creates a root mesh by merging the mesh corresponding to each neuron, then saves it as an obj file at rootpath """ raise NotImplementedError(f"Create root method not supported yet, sorry") print(f"Creating root mesh for atlas {self.atlas_name}") temp_scene = Scene(atlas=Celegans, add_root=False, display_inset=False, atlas_kwargs=dict(data_folder=self.data_folder)) temp_scene.add_neurons(self.neurons_names) temp_scene.render(interactive=False) temp_scene.close() root = merge(*temp_scene.actors['neurons']).clean().cap() # root = mesh2Volume(root, spacing=(0.02, 0.02, 0.02)).isosurface() points = Points(root.points()).smoothMLS2D(f=0.8).clean(tol=0.005) root = recoSurface(points, dims=100, radius=0.2) # Save write(root, rootpath) del temp_scene return root
def save_pts_to_vtk(pts, save_path="./test.vtk"): """ 将牙龈点pts格式转为vtk格式 @pts: 点集 [[x, y, z], [x, y, z], ...] @save_path: 保存路径 return: None """ import vtkplotter as vtkp vtk_point = vtkp.Points(pts.reshape(-1, 3)) vtkp.write(vtk_point, save_path, binary=False)
def make_root_mesh(self): if self.structures is None: return obj_path = os.path.join(self.meshes_folder, "root.vtk") if os.path.isfile(obj_path): return # Get the mesh for each brain region to create root meshes = [ self._get_structure_mesh(reg) for reg in self.region_acronyms ] root = merge(meshes) write(root, obj_path)
def pts_to_vtk(self): """ 将牙龈点pts格式转为vtk格式 @pts: 点集 [[x, y, z], [x, y, z], ...] @save_path: 保存路径 return: None """ import vtkplotter as vtkp save_path = os.path.join(self.show_path, os.path.basename(self.obj_path)[:-4]) if not os.path.isdir(save_path): os.makedirs(save_path) save_path = os.path.join(save_path, "test.vtk") vtk_point = vtkp.Points(self.gum_line_pts.reshape(-1, 3)) vtkp.write(vtk_point, save_path, binary=False)