brainspace.mesh.mesh_cluster.cluster_points

brainspace.mesh.mesh_cluster.cluster_points(surf, n_clusters=100, is_size=False, mask=None, with_centers=True, random_state=None, approach='kmeans', n_init=3, n_jobs=1)[source]

Clustering of surface points.

Parameters:
  • surf (vtkPolyData or BSPolyData) – Input surface.
  • n_clusters (int, optional) – Number of clusters. Default is 100.
  • is_size (bool, optional) – If True, interpret n_clusters as cluster size. Default is False.
  • mask (1D ndarray, optional) – Mask for surface points. Points outside the mask (i.e., False) are discarded from clustering. Default is None.
  • with_centers (bool, optional) – If True, an array of labels with the closest points to the centroid of each cluster is returned. Default is True.
  • random_state (int, RandomState instance or None, optional) – Random state. Default is None.
  • approach ({'kmeans', 'ward'}, optional) – Clustering method: k-means or hierarchical with ward linkage. Hierarchical clustering 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.
Returns:

  • cluster_labels (1D ndarray, shape (n_points,)) – Array of cluster labels. If mask is provided, points out of the mask are assigned label 0.
  • center_labels (1D ndarray, shape (n_points,)) – Array with centers labeled with their corresponding cluster label. The rest of points is assigned label 0. Returned only if with_centers=True.

Notes

Valid cluster labels start from 1. If the mask is provided, zeros are assigned to the points outside the mask.