spateo.tools.utils
#
Module Contents#
Functions#
|
This function rescale the resolution of the input matrix that represents a spatial domain. For example, if you |
|
|
|
|
|
|
|
|
|
|
|
|
|
Compute and return smallest distance. A wrapper for sklearn API |
|
Create a PolyData object from the convex hull constructed with the input data points. |
|
Test if points in p are in hull |
- spateo.tools.utils.rescaling(mat: Union[numpy.ndarray, scipy.sparse.spmatrix], new_shape: Union[List, Tuple]) Union[numpy.ndarray, scipy.sparse.spmatrix] [source]#
This function rescale the resolution of the input matrix that represents a spatial domain. For example, if you want to decrease the resolution of a matrix by a factor of 2, the new_shape will be mat.shape / 2.
- Parameters
- mat
The input matrix of the spatial domain (or an image).
- new_shape
The rescaled shape of the spatial domain, each dimension must be an factorial of the original dimension.
- Returns
the spatial resolution rescaled matrix.
- Return type
res
- spateo.tools.utils.compute_smallest_distance(coords: numpy.ndarray, leaf_size: int = 40, sample_num=None, use_unique_coords=True) float [source]#
Compute and return smallest distance. A wrapper for sklearn API :param coords: NxM matrix. N is the number of data points and M is the dimension of each point’s feature. :param leaf_size: Leaf size parameter for building Kd-tree, by default 40. :type leaf_size: int, optional :param sample_num: The number of cells to be sampled. :param use_unique_coords: Whether to remove duplicate coordinates
- Returns
min_dist: float the minimum distance between points
- spateo.tools.utils.polyhull(x: numpy.ndarray, y: numpy.ndarray, z: numpy.ndarray) pyvista.PolyData [source]#
Create a PolyData object from the convex hull constructed with the input data points.
scipy’s ConvexHull to be 500X faster than using vtkDelaunay3D and vtkDataSetSurfaceFilter because you skip the expensive 3D tesselation of the volume.
- Parameters
- x
x coordinates of the data points.
- y
y coordinates of the data points.
- z
z coordinates of the data points.
- Returns
a PolyData object generated with the convex hull constructed based on the input data points.
- Return type
poly
- spateo.tools.utils.in_hull(p: numpy.ndarray, hull: Tuple[scipy.spatial.Delaunay, numpy.ndarray]) numpy.ndarray [source]#
Test if points in p are in hull
- Parameters
- p
a N x K coordinates of N points in K dimensions
- hull
either a scipy.spatial.Delaunay object or the MxK array of the coordinates of M points in K
- computed. : dimensions for which Delaunay triangulation will be
- Returns
A numpy array with boolean values indicating whether the input points is in the convex hull.
- Return type
res