Skip to main content

ktch is a python package for model-based morphometrics.

Project description

ktch - A Python package for model-based morphometrics

PyPI version Anaconda-Server Badge codecov License Python

ktch is a Python package for model-based morphometrics with scikit-learn compatible APIs.

Overview

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) and disk harmonic analysis (DHA) for surfaces
  • Theoretical morphological models of coiling: Raup's model and the growing tube model
  • 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 plot extra)

All analysis classes follow the scikit-learn API (fit, transform, fit_transform), so you can plug them into your existing pipelines.

Installation

Python >= 3.11 is required.

From PyPI

pip install ktch

From conda-forge

conda install -c conda-forge ktch

Optional dependencies

Via PyPI:

pip install ktch[plot]  # matplotlib, plotly, seaborn for visualization
pip install ktch[data]  # pooch for remote dataset downloads

Via 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 dependencies

Development installation

git clone https://github.com/noshita/ktch.git
cd ktch
uv sync

Quick start

Elliptic Fourier Analysis on 2D outlines

from 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)

Documentation

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

Contributing

Bug reports and feature requests are welcome via GitHub Issues.

See CONTRIBUTING.md for development setup and conventions.

License

ktch is licensed under the Apache License, Version 2.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ktch-0.10.1.tar.gz (756.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ktch-0.10.1-py3-none-any.whl (757.9 kB view details)

Uploaded Python 3

File details

Details for the file ktch-0.10.1.tar.gz.

File metadata

  • Download URL: ktch-0.10.1.tar.gz
  • Upload date:
  • Size: 756.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ktch-0.10.1.tar.gz
Algorithm Hash digest
SHA256 34f901ce3d496f6c729b5d5e90b4f0bc51376f7175ce3bd33a4ae2298fe858bf
MD5 ffd7949bd56366b30397a0a3eac22287
BLAKE2b-256 4ee689b29dfe3e5b00f840910472e07357ebda4804745dbbc004b7849cdd505f

See more details on using hashes here.

File details

Details for the file ktch-0.10.1-py3-none-any.whl.

File metadata

  • Download URL: ktch-0.10.1-py3-none-any.whl
  • Upload date:
  • Size: 757.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ktch-0.10.1-py3-none-any.whl
Algorithm Hash digest
SHA256 62c559e42f1ea9dc4544668c5f985584e3c21db62980a179aa39b821a7d2e679
MD5 30ff689fa6dc690b941c8e241517e56b
BLAKE2b-256 67e78813752772ba6ab4c0a43e9b75f30b7b4c4c48b30eb293a5d5a377cf52c1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page