GeneralizedProcrustesAnalysis#

class ktch.landmark.GeneralizedProcrustesAnalysis(tol=1e-07, scaling=True, n_dim=2, curves: TypeAliasForwardRef('npt.ArrayLike') | None = None, surfaces: TypeAliasForwardRef('npt.ArrayLike') | None = None, sliding_criterion: str = 'bending_energy', n_jobs: int | None = None, debug=False)[source]#

Generalized Procrustes Analysis (GPA)

Parameters:
tol: float, default=10^-7

Tolerance for convergence of Procrustes analysis.

scaling: bool, default=True

If True, scale configurations to unit centroid size (shape analysis). If False, only translate and rotate (size-and-shape analysis).

n_dim: int, default=2

Dimensions of the configurations (2 or 3).

curves: array-like, shape (n_sliders, 3), default=None

Curve semilandmark topology matrix. Each row specifies [before_index, slider_index, after_index] defining the sliding direction along the curve tangent.

surfaces: array-like, shape (n_surface, 3), default=None

Surface semilandmark topology matrix. Each row specifies [patch_id, landmark_index, normal_anchor_index] where patch_id identifies the surface patch, landmark_index is the semilandmark to slide, and normal_anchor_index is a nearby fixed landmark used to orient the local tangent plane.

Currently not implemented; will raise NotImplementedError if provided.

sliding_criterion: str, default=’bending_energy’
  • ‘bending_energy’: Minimize thin-plate spline bending energy

  • ‘procrustes_distance’: Minimize Procrustes distance to reference

n_jobs: int, default=None

The number of parallel jobs to run for Procrustes analysis.

Attributes:
mu_: ndarray, shape (n_landmarks, n_dim)

The mean shape of the aligned shapes.

n_dim_: int, 2 or 3

Dimensions of the configurations.

Notes

GPA for shape involves translating, rotating, and scaling the configurations to each other to minimize the sum of the squared distances with respect to positional, rotational, and size parameters, subject to a size constraint [Gower_1975], [Goodall_1991].

When semilandmarks are specified via the curves parameter, they are slid along their tangent directions to minimize the chosen criterion (bending energy or Procrustes distance) during each GPA iteration [Bookstein_1997], [Gunz_2013].

References

[Gower_1975]

Gower, J.C., 1975. Generalized procrustes analysis. Psychometrika 40, 33-51.

[Goodall_1991]

Goodall, C., 1991. Procrustes Methods in the Statistical Analysis of Shape. J Royal Stat Soc B 53, 285-321.

[Bookstein_1997]

Bookstein, F.L., 1997. Landmark methods for forms without landmarks. Medical Image Analysis 1, 225-243.

[Gunz_2013]

Gunz, P., Mitteroecker, P., 2013. Semilandmarks: a method for quantifying curves and surfaces. Hystrix 24, 103-109.

fit(X: npt.ArrayLike) GeneralizedProcrustesAnalysis[source]#

Fit GPA.

Parameters:
Xarray-like, shape (n_specimens, n_landmarks, n_dim)

or DataFrame, shape (n_specimens, n_landmarks * n_dim) Configurations to be aligned.

Returns:
selfobject

Returns the instance itself.

fit_transform(X)[source]#

GPA for shapes/size-and-shapes.

Parameters:
Xarray-like, shape (n_specimens, n_landmarks * n_dim)

/DataFrame, shape (n_specimens, n_landmarks * n_dim) Configurations to be aligned.

Returns:
X_ndarray, shape (n_specimens, n_landmarks, n_dim)

Shapes/Size-and-Shape

get_feature_names_out(input_features=None)#

Get output feature names for transformation.

Parameters:
input_featuresarray-like of str or None, default=None

Input features.

  • If input_features is None, then feature_names_in_ is used as feature names in. If feature_names_in_ is not defined, then the following input feature names are generated: [“x0”, “x1”, …, “x(n_features_in_ - 1)”].

  • If input_features is an array-like, then input_features must match feature_names_in_ if feature_names_in_ is defined.

Returns:
feature_names_outndarray of str objects

Same as input features.

get_metadata_routing()#

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Returns:
routingMetadataRequest

A MetadataRequest encapsulating routing information.

get_params(deep=True)#

Get parameters for this estimator.

Parameters:
deepbool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:
paramsdict

Parameter names mapped to their values.

set_output(*, transform=None)#

Set output container.

See Introducing the set_output API for an example on how to use the API.

Parameters:
transform{“default”, “pandas”, “polars”}, default=None

Configure output of transform and fit_transform.

  • “default”: Default output format of a transformer

  • “pandas”: DataFrame output

  • “polars”: Polars output

  • None: Transform configuration is unchanged

Added in version 1.4: “polars” option was added.

Returns:
selfestimator instance

Estimator instance.

set_params(**params)#

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters:
**paramsdict

Estimator parameters.

Returns:
selfestimator instance

Estimator instance.

transform(X: npt.ArrayLike) npt.ArrayLike[source]#

GPA for shapes/size-and-shapes.

Parameters:
Xarray-like, shape (n_specimens, n_landmarks*n_dim)

Configurations to be aligned.

Returns:
X_ndarray, shape (n_specimens, n_landmarks, n_dim)

Shapes/Size-and-Shape