Ellipsoid: Shape Statistics in Python
What is the Use Case?
ellipsoid_pca use case demonstrates the functionality of shape statistics tools of ShapeWorks python API. These APIs include reading particle files and computing eigenvectors, eigenvalues, and PCA loadings. This use case reads the correspondence model of the ellipsoid segmentation images use case.
Analyzing Shape Model Using Python APIs
ShapeWorks python API analyzes the optimized particle-based shape model by calculating the principal components of the shape model, eigenvalues, eigenvectors, and PCA loadings. This tool also estimates the variance explained by each mode and generates plots for PCA metrics similar to
# Read the particle files from a pre-trained shape model particle_data = sw.ParticleSystem(<list of local point files>)
To perform PCA:
shape_statistics = sw.ParticleShapeStatistics() shape_statistics.PCA(particleSystem = particle_data,domainsPerShape=1)
shape_statistics object, you can now extract the following entities:
Calculate principal components :
Extract the loadings:
- Eigen Values:
- Eigen Vectors:
- Number of shapes in the model:
- Dimension of each shape:
- Variance explained by each mode:
Details about shape statistics functions can be found in the API Reference
When the use case is run, plots similar to those below will be generated.