spateo.tdr.models.models_individual.mesh ======================================== .. py:module:: spateo.tdr.models.models_individual.mesh Functions --------- .. autoapisummary:: spateo.tdr.models.models_individual.mesh.construct_cells spateo.tdr.models.models_individual.mesh.construct_surface Module Contents --------------- .. py:function:: construct_cells(pc: pyvista.PolyData, cell_size: numpy.ndarray, geometry: Literal['cube', 'sphere', 'ellipsoid'] = 'cube', xyz_scale: tuple = (1, 1, 1), n_scale: tuple = (1, 1), factor: float = 0.5) Reconstructing cells from point clouds. :param pc: A point cloud object, including ``pc.point_data["obs_index"]``. :param geometry: The geometry of generating cells. Available ``geometry`` are: * geometry = ``'cube'`` * geometry = ``'sphere'`` * geometry = ``'ellipsoid'`` :param cell_size: A numpy.ndarray object including the relative radius/length size of each cell. :param xyz_scale: The scale factor for the x-axis, y-axis and z-axis. :param n_scale: The ``squareness`` parameter in the x-y plane adn z axis. Only works if ``geometry = 'ellipsoid'``. :param factor: Scale factor applied to scaling array. :returns: A cells mesh including `ds_glyph.point_data["cell_size"]`, `ds_glyph.point_data["cell_centroid"]` and the data contained in the pc. :rtype: ds_glyph .. py:function:: construct_surface(pc: pyvista.PolyData, key_added: str = 'groups', label: str = 'surface', color: Optional[str] = 'gainsboro', alpha: Union[float, int] = 1.0, uniform_pc: bool = False, uniform_pc_alpha: Union[float, int] = 0, cs_method: Literal['pyvista', 'alpha_shape', 'ball_pivoting', 'poisson', 'marching_cube'] = 'marching_cube', cs_args: Optional[dict] = None, nsub: Optional[int] = 3, nclus: int = 20000, smooth: Optional[int] = 3000, scale_distance: Union[float, int, list, tuple] = None, scale_factor: Union[float, int, list, tuple] = None) -> Tuple[Union[pyvista.PolyData, pyvista.UnstructuredGrid, None], pyvista.PolyData, Optional[str]] Surface mesh reconstruction based on 3D point cloud model. :param pc: A point cloud model. :param key_added: The key under which to add the labels. :param label: The label of reconstructed surface mesh model. :param color: Color to use for plotting mesh. The default ``color`` is ``'gainsboro'``. :param alpha: The opacity of the color to use for plotting mesh. The default ``alpha`` is ``0.8``. :param uniform_pc: Generates a uniform point cloud with a larger number of points. :param uniform_pc_alpha: Specify alpha (or distance) value to control output of this filter. :param cs_method: The methods of generating a surface mesh. Available ``cs_method`` are: * ``'pyvista'``: Generate a 3D tetrahedral mesh based on pyvista. * ``'alpha_shape'``: Computes a triangle mesh on the alpha shape algorithm. * ``'ball_pivoting'``: Computes a triangle mesh based on the Ball Pivoting algorithm. * ``'poisson'``: Computes a triangle mesh based on thee Screened Poisson Reconstruction. * ``'marching_cube'``: Computes a triangle mesh based on the marching cube algorithm. :param cs_args: Parameters for various surface reconstruction methods. Available ``cs_args`` are: * ``'pyvista'``: {'alpha': 0} * ``'alpha_shape'``: {'alpha': 2.0} * ``'ball_pivoting'``: {'radii': [1]} * ``'poisson'``: {'depth': 8, 'width'=0, 'scale'=1.1, 'linear_fit': False, 'density_threshold': 0.01} * ``'marching_cube'``: {'levelset': 0, 'mc_scale_factor': 1, 'dist_sample_num': 100} :param nsub: Number of subdivisions. Each subdivision creates 4 new triangles, so the number of resulting triangles is nface*4**nsub where nface is the current number of faces. :param nclus: Number of voronoi clustering. :param smooth: Number of iterations for Laplacian smoothing. :param scale_distance: The distance by which the model is scaled. If ``scale_distance`` is float, the model is scaled same distance along the xyz axis; when the ``scale factor`` is list, the model is scaled along the xyz axis at different distance. If ``scale_distance`` is None, there will be no scaling based on distance. :param scale_factor: The scale by which the model is scaled. If ``scale factor`` is float, the model is scaled along the xyz axis at the same scale; when the ``scale factor`` is list, the model is scaled along the xyz axis at different scales. If ``scale_factor`` is None, there will be no scaling based on scale factor. :returns: A reconstructed surface mesh, which contains the following properties: ``uniform_surf.cell_data[key_added]``, the ``label`` array; ``uniform_surf.cell_data[f'{key_added}_rgba']``, the rgba colors of the ``label`` array. inside_pc: A point cloud, which contains the following properties: ``inside_pc.point_data['obs_index']``, the obs_index of each coordinate in the original adata. ``inside_pc.point_data[key_added]``, the ``groupby`` information. ``inside_pc.point_data[f'{key_added}_rgba']``, the rgba colors of the ``groupby`` information. plot_cmap: Recommended colormap parameter values for plotting. :rtype: uniform_surf