EllipsoidExpander#
Expand a set of points to fit an ellipsoid using least squares fitting.
The ellipsoid equation is of the form:
where A, B, C, D, E, F, G, H, I are the coefficients of the ellipsoid equation and x, y, z are the coordinates of the points. The parameters of this equation are fitted to the input points using least squares fitting.
- napari_stress.approximation.EllipsoidExpander.fit(points: 'napari.types.PointsData')#
Fit an ellipsoid to a set of points using leaast square fitting.
- napari_stress.approximation.EllipsoidExpander.expand(points: 'napari.types.PointsData')#
Project a set of points onto their respective position on the fitted ellipsoid.
- napari_stress.approximation.EllipsoidExpander.fit_expand(points: 'napari.types.PointsData')#
Fit an ellipsoid to a set of points and then expand them.
- napari_stress.approximation.EllipsoidExpander.coefficients_#
Coefficients of the fitted ellipsoid. The coefficients are of the form (3, 2, 3); The first dimension represents the three axes of the ellipsoid (major, medial and minor). The second dimension represents the components of the ellipsoid vectors (base point and direction vector). The third dimension represents the dimension of the space (z, y, x).
- Type:
napari.types.VectorsData
- napari_stress.approximation.EllipsoidExpander.axes_#
Lengths of the axes of the ellipsoid.
- Type:
np.ndarray
- napari_stress.approximation.EllipsoidExpander.center_#
Center of the ellipsoid.
- Type:
np.ndarray
- napari_stress.approximation.EllipsoidExpander.properties#
Dictionary containing properties of the expansion with following keys: - residuals: np.ndarray
Residual euclidian distance between input points and expanded points.
- normals: napari.types.VectorsData
Normals on the ellipsoid at the input points.
- mean_curvature: np.ndarray
Calculate point-wise mean curvature \(H_i\) for an ellipsoid.
The formula for \(H_i\) is given as:
\[H(U, V) = \frac{ a_0 a_1 a_2 \Bigg( 3 \left(a_0^2 + a_1^2\right) + 2 \left(a_2^2\right) + \left(a_0^2 + a_1^2 - 2 a_2^2\right) \cos(2V) - 2 \left(a_0^2 - a_1^2\right) \cos(2U) \sin^2(V) \Bigg) }{ 8 \Bigg( \left(a_0 a_1 \cos(V)\right)^2 + \left(a_2 \sin(V)\right)^2 \Big( \left(a_1 \cos(U)\right)^2 + \left(a_0 \sin(U)\right)^2 \Big) \Bigg)^{1.5} }\]
- principal_curvatures1: np.ndarray
First principal curvature at the input points. Calculated as the maximum curvature at the input points:
- principal_curvatures2: np.ndarray
Second principal curvature at the input points. Calculated as the minimum curvature at the input points.
- h0_ellipsoid: np.ndarray
Averaged mean curvature \(H_0\) on the ellipsoid, calculated as the mean of the point-wise mean curvature \(H_i\).
- h_e123_ellipsoid: np.ndarray
Maximum, medial and minimum mean curvature of the ellipsoid.
- maximum_mean_curvature: float
Maximum mean curvature of the ellipsoid.
- minimum_mean_curvature: float
Minimum mean curvature of the ellipsoid.
The maximum and minimum curvatures \(H_{max}\) and \(H_{min}\) are calculated as follows:
\[ \begin{align}\begin{aligned}H_{max} = a / (2 * c^2) + a / (2 * b^2)\\H_{min} = c / (2 * b^2) + c / (2 * a^2)\end{aligned}\end{align} \]where a, b and c are the lengths of the ellipsoid axes along the three spatial dimensions.
- Type:
dict
Examples
# Instantiate and fit an ellipsoid expander to a set of points
expander = EllipsoidExpander()
expander.fit(points)
# Expand the points on the fitted ellipsoid
fitted_points = expander.expand(points)