ktch is a Python package for model-based morphometrics with scikit-learn compatible APIs.
ktch implements the following morphometric analysis methods:
- Landmark-based methods: Generalized Procrustes Analysis (GPA) with curve/surface semilandmark sliding, thin-plate spline interpolation
- Harmonic-based methods: Elliptic Fourier Analysis (EFA) for 2D/3D closed curves, spherical harmonic analysis (SPHARM) for 3D closed surfaces
- File I/O: Support for standard morphometric file formats (TPS, CHC, SPHARM-PDM)
- Datasets: Built-in example datasets for learning and testing
- Visualization: TPS deformation grids, PCA variance plots (with optional
plotextra)
All analysis classes follow the scikit-learn API (fit, transform, fit_transform), so you can plug them into your existing pipelines.
Python >= 3.11 is required.
pip install ktchconda install -c conda-forge ktchVia PyPI:
pip install ktch[plot] # matplotlib, plotly, seaborn for visualization
pip install ktch[data] # pooch for remote dataset downloadsVia conda-forge:
conda install -c conda-forge ktch-plot # matplotlib, plotly, seaborn for visualization
conda install -c conda-forge ktch-data # pooch for remote dataset downloads
conda install -c conda-forge ktch-all # all optional dependenciesgit clone https://github.com/noshita/ktch.git
cd ktch
uv syncfrom sklearn.decomposition import PCA
from ktch.datasets import load_outline_mosquito_wings
from ktch.harmonic import EllipticFourierAnalysis
# Load outline data (126 specimens, 100 points, 2D)
data = load_outline_mosquito_wings()
coords = data.coords
# Elliptic Fourier Analysis
efa = EllipticFourierAnalysis(n_harmonics=20)
coeffs = efa.fit_transform(coords)
# PCA on EFA coefficients
pca = PCA(n_components=5)
pc_scores = pca.fit_transform(coeffs)See doc.ktch.dev for full documentation:
- Tutorials: Step-by-step guides for GPA, EFA, spherical harmonics, and more
- How-to guides: Task-oriented recipes for data loading, visualization, and pipeline integration
- Explanation: Theoretical background on morphometric methods
- API reference: Complete API documentation
Bug reports and feature requests are welcome via GitHub Issues.
See CONTRIBUTING.md for development setup and conventions.
ktch is licensed under the Apache License, Version 2.0.