Functions
multicut_ward
Computes labels from Ward hierarchical clustering at multiple distance thresholds without recomputing the tree at each threshold.Feature matrix of shape (n_samples, n_features)
Connectivity matrix defining the structure of the data. Neighbors along this structure are merged during clustering.
List of distance thresholds at which to cut the dendrogram
np.ndarray - Array of shape (n_samples, n_thresholds) containing cluster labels for each threshold
agglomerate_mesh
Performs hierarchical clustering on mesh vertices using their features, handling NaN values appropriately.Mesh tuple of (vertices, faces)
Feature array of shape (n_vertices, n_features)
Distance threshold(s) for cutting the dendrogram. If None, returns identity labels.
np.ndarray - Cluster labels array of shape (n_vertices, n_thresholds), or None if all features are NaN
Example:
agglomerate_split_mesh
Agglomerates features on a split mesh using a MeshStitcher.MeshStitcher object that handles mesh splitting and stitching
Feature array for the mesh vertices
Distance threshold(s) for clustering
np.ndarray - Cluster labels, either 1D (single threshold) or 2D (multiple thresholds)
aggregate_features
Aggregates features according to cluster labels using various aggregation functions.Feature matrix to aggregate
Cluster labels for each row. If None, returns features unchanged.
Weights for weighted averaging (only used when func=“mean”)
Aggregation function to apply (e.g., “mean”, “sum”, “max”)
pd.DataFrame - Aggregated features indexed by cluster label
Example:
blow_up_features
Expands aggregated features back to per-vertex features using cluster labels.Aggregated features indexed by cluster label
Cluster labels indicating which aggregated feature each vertex should receive
pd.DataFrame - Expanded features with one row per vertex
Example:
fix_split_labels
Fixes cluster labels across split meshes by creating unique labels for each submesh-label combination.Array of cluster labels, potentially with multiple columns for different thresholds
Array mapping each vertex to its submesh index
np.ndarray - Fixed cluster labels with globally unique values
fix_split_labels_and_features
Fixes both labels and features for split meshes, ensuring consistency between them.1D array of cluster labels
Array mapping vertices to submesh indices
List of feature DataFrames, one per submesh
tuple - (fixed_labels, concatenated_features_df)