domains Module¶
The domains module provides functions for curvature-based segmentation of meshes into domains and subsequent domain merging and analysis.
Domain Segmentation¶
- steepest_ascent(mesh, scalars, neighbours=None)[source]¶
Create domains using steepest ascent approach.
Connects vertices based on the steepest local gradient in the scalar field.
- Parameters:
- Return type:
- Returns:
Array of domain labels with length mesh.n_points
- Raises:
RuntimeError – If scalar array has invalid dimensions
Domain Merging¶
- merge_small(mesh, domains, threshold, metric='points', mode='border', neighbours=None)[source]¶
Merge domains smaller than threshold to their largest neighbor.
- Parameters:
mesh (
PolyData) – PyVista mesh containing the domainsdomains (
ndarray[tuple[Any,...],dtype[integer[Any]]]) – Array of domain labelsthreshold (
float) – Size threshold below which domains are mergedmetric (
str, default:'points') – Size metric to use for merging (‘points’ or ‘area’)mode (
str, default:'border') – Merge strategy (‘border’ or ‘area’)neighbours (
list[ndarray[tuple[Any,...],dtype[int64]]] |None, default:None) – Optional neighbor connectivity array
- Return type:
- Returns:
Array of merged domain labels
- Raises:
RuntimeError – If domains array is invalid
- merge_angles(mesh, domains, meristem_index, threshold=20, method='center_of_mass')[source]¶
Merge domains based on angular separation from meristem.
Merges domains that are within the angular threshold when measured from the meristem center.
- Parameters:
mesh (
PolyData) – PyVista mesh containing the domainsdomains (
ndarray[tuple[Any,...],dtype[integer[Any]]]) – Array of current domain labelsmeristem_index (
int) – Index of the meristem domainthreshold (
float, default:20) – Angular threshold in degrees for merging domainsmethod (
str, default:'center_of_mass') – Method for calculating domain center coordinates
- Return type:
- Returns:
Array of merged domain labels
- merge_distance(mesh, domains, threshold, scalars=None, method='center_of_mass', metric='euclidean')[source]¶
Merge domains based on spatial distance between domain centers.
Uses KDTree to find domains within the distance threshold.
- Parameters:
mesh (
PolyData) – PyVista mesh containing the domainsdomains (
ndarray[tuple[Any,...],dtype[integer[Any]]]) – Array of current domain labelsthreshold (
float) – Distance threshold for merging domainsscalars (
ndarray[tuple[Any,...],dtype[floating[Any]]] |None, default:None) – Optional scalar array for distance calculationmethod (
str, default:'center_of_mass') – Method for calculating domain centermetric (
str, default:'euclidean') – Distance metric (‘euclidean’ or ‘geodesic’)
- Return type:
- Returns:
Array of merged domain labels
- Raises:
RuntimeError – If method or metric is invalid
- merge_engulfing(mesh, domains, threshold=0.9, neighbours=None)[source]¶
Merge domains that are mostly encircled by a neighboring domain.
Merges domains where a single neighbor borders more than the threshold fraction of the domain boundary.
- Parameters:
mesh (
PolyData) – PyVista mesh containing the domainsdomains (
ndarray[tuple[Any,...],dtype[integer[Any]]]) – Array of domain labelsthreshold (
float, default:0.9) – Fraction of boundary that must be shared for mergingneighbours (
list[ndarray[tuple[Any,...],dtype[int64]]] |None, default:None) – Optional neighbor connectivity array
- Return type:
- Returns:
Array of merged domain labels
- Raises:
RuntimeError – If domains array is invalid
- merge_disconnected(mesh, domains, meristem_index, threshold, neighbours=None)[source]¶
Merge domains disconnected from meristem to nearest connected domain.
- Parameters:
mesh (
PolyData) – PyVista mesh containing the domainsdomains (
ndarray[tuple[Any,...],dtype[integer[Any]]]) – Array of domain labelsmeristem_index (
int) – Index of the meristem domainthreshold (
float|None) – Distance threshold; if None, returns domains unchangedneighbours (
list[ndarray[tuple[Any,...],dtype[int64]]] |None, default:None) – Optional neighbor connectivity array
- Return type:
- Returns:
Array of merged domain labels
- Raises:
RuntimeError – If domains array is invalid
- merge_depth(mesh, domains, scalars, threshold=0.0, neighbours=None, exclude_boundary=False, min_points=0, mode='max')[source]¶
Merge domains based on depth similarity in scalar field.
Merges neighboring domains if their depth values differ by less than threshold.
- Parameters:
mesh (
PolyData) – PyVista mesh containing the domainsdomains (
ndarray[tuple[Any,...],dtype[integer[Any]]]) – Array of domain labelsscalars (
ndarray[tuple[Any,...],dtype[floating[Any]]]) – Scalar array representing depth or curvature valuesthreshold (
float, default:0.0) – Maximum depth difference for mergingneighbours (
list[ndarray[tuple[Any,...],dtype[int64]]] |None, default:None) – Optional neighbor connectivity arrayexclude_boundary (
bool, default:False) – Exclude boundary vertices from depth calculationmin_points (
int, default:0) – Minimum number of border points required for mergingmode (
Literal['min','max','median','mean'], default:'max') – Aggregation mode for domain depth (‘min’, ‘max’, ‘median’, ‘mean’)
- Return type:
- Returns:
Array of merged domain labels
- Raises:
RuntimeError – If domains or scalars arrays are invalid
Domain Analysis¶
- define_meristem(mesh, domains, method='center_of_mass', return_coordinates=False, neighbors=None)[source]¶
Identify which domain corresponds to the meristem.
- Parameters:
mesh (
PolyData) – PyVista mesh containing the domainsdomains (
ndarray[tuple[Any,...],dtype[integer[Any]]]) – Array of domain labelsmethod (
str, default:'center_of_mass') – Method for meristem identificationreturn_coordinates (
bool, default:False) – If True, return meristem center coordinatesneighbors (
list[ndarray[tuple[Any,...],dtype[int64]]] |None, default:None) – Optional neighbor connectivity array
- Return type:
int|tuple[int,ndarray[tuple[Any,...],dtype[floating[Any]]]]- Returns:
Meristem domain index, and optionally its center coordinates
- extract_domaindata(point_data, mesh, apex, meristem)¶
Extract geometric and spatial data for each domain.
Computes distance to boundary, distance to center of mass, angle from apex, surface area, maximum diameter, and meristem flag for each domain.
- Parameters:
- Return type:
- Returns:
DataFrame with domain measurements and properties
Scalar Filtering¶
- median(scalars, neighbors=None, iterations=1)[source]¶
Apply median filter to mesh-based scalar arrays.
- Parameters:
- Return type:
- Returns:
Filtered scalar array
- mean(scalars, neighbors, iterations=1, exclude=None)[source]¶
Apply mean filter to scalar array.
- Parameters:
scalars (
ndarray[tuple[Any,...],dtype[floating[Any]]]) – Scalar array to filterneighbors (
list[ndarray[tuple[Any,...],dtype[int64]]]) – Neighbor connectivity arrayiterations (
int, default:1) – Number of filter iterationsexclude (
list[int] |None, default:None) – Vertex indices to exclude from filtering
- Return type:
- Returns:
Filtered scalar array
- minmax(scalars, neighbors=None, iterations=1)[source]¶
Apply min-max filter to mesh-based scalar arrays.
- Parameters:
- Return type:
- Returns:
Filtered scalar array