brainspace.mesh.mesh_cluster.sample_points_clustering(surf, keep=0.1, mask=None, random_state=None, approach='kmeans', n_init=3, n_jobs=1)[source]

Sample equidistant points from surface based on clustering.

  • surf (vtkPolyData or BSPolyData) – Input surface.
  • keep (float or int, optional) – If float, percentage of points to sample. Must be 0 < keep < 1. If int, number of points to sample. Default is 0.1.
  • mask (1D ndarray, optional) – Mask for surface points. Points outside the mask (i.e., False) are discarded from sampling. Default is None.
  • random_state (int, RandomState instance or None, optional) – Random state. Default is None.
  • approach ({'kmeans', 'ward'}, optional) – Clustering approach: k-means or hierarchical with ward linkage. Hierarchical is faster but k-means provides better results. Default is ‘kmeans’.
  • n_init (int, optional) – Number of k-means repetitions. Only used when approach == 'kmeans'. Default is 3.
  • n_jobs (int or None, optional) – The number of parallel jobs. Only used when approach == 'kmeans'. Default is 1.

sampled (1D ndarray, shape (n_points,)) – Array with sampled points marked with 1 in their corresponding positions. The rest is 0.

See also

cluster_points, sample_points_decimation


This method first clusters the surface points and then selects the points closest to the centroids as the sampled points.