Skip to main content

Geometric Morphometrics operations in Python

Project description

https://travis-ci.com/vaipatel/morphops.svg?branch=master

Welcome to Morphops!

Morphops implements common operations and algorithms for Geometric Morphometrics, in Python 3.

Features

Some high-level operations in the current version are

  • Centering, rescaling data:

  • Rigid Rotation, Ordinary and Generalized Procrustes alignment:

  • Thin-plate spline warping:

  • Reading from and writing to *.dta files:

Dependencies

  • numpy

Installation

pip install morphops

Usage Examples

import morphops as mops

# Create 3 landmark sets, each having 5 landmarks in 2 dimensions.
A = [[0,0],[2,0],[2,2],[1,3],[0,2]]
B = [[0.1,-0.1],[2,0],[2.3,1.8],[1,3],[0.4,2]]
C = [[-0.1,-0.1],[2.1,0],[2,1.8],[0.9,3.1],[-0.4,2.1]]

# Perform Generalized Procrustes alignment to align A, B, C.
res = mops.gpa([A, B, C])
# res['aligned'] contains the aligned A, B, C. res['mean'] is their mean.

# Create a Thin-plate Spline warp from A to B and warp C.
warped_C = mops.tps_warp(A, B, C)
# warped_C contains the image of the pts in C under the TPS warp.

What is Geometric Morphometrics?

Geometric Morphometrics is a statistical toolkit for quantifying and studying shapes of forms that are represented by homologous landmark sets.

“Shape” has a specific notion here. For a given landmark set, its shape refers to the spatial information that survives after discarding its absolute position, scale and rotation. So two landmark sets have the same shape if they can be brought in perfect alignment by only changing their positions, scales and rotations.

Common Operations and Algorithms in Studies

Geometric Morphometrics is often used when pursuing statistical questions involving the morphology of biological forms, like do corvid species that frequently probe have longer bills and more to-the-side orbits than corvid species that frequently peck. It helps inform the Data Collection, Preprocessing and Analysis steps of such statistical studies with sound theoretical or practical justifications.

Data Collection

The most prevalent form of Data Collection involves picking homologous landmarks on each form. For curving forms with few homologous points but well-understood homologous regions, there is a notion of semilandmarks which can “slide” to minimize equidistant sampling artifacts.

A common file format for saving landmarks for a set of specimens is the *.dta format used by the IDAV Landmark Editor software.

Preprocessing

As discussed before, a central idea in Geometric Morphometrics is extracting the “shapes” of the landmark sets. One way to achieve this is to use the Generalized Procrustes Alignment algorithm or GPA. GPA aligns all the landmark sets by modifying their locations, orientations and sizes so as to minimize their collective interlandmark distances.

After this step, the aligned shapes all lie in a high-dimensional non-linear manifold. For example, if the orignal landmark sets were a set of triangles, the aligned shapes lie on a sphere. Moreover, for naturally arising datasets, the shapes likely lie very close to each other and are distributed around a mean shape. This usually makes it permissible to project all the shapes into the tangent space at the mean shape, and this way the final shape vectors lie in a linear space.

Analysis

With the shapes lying in a high-dimensional linear space after preprocessing, they can now be submitted to various commonly used statistical procedures like Principal Components Analysis and various kinds of regression for further analysis.

(This file was autogenerated from README_for_docs.rst by running `make README_for_gh html` in the docs directory)

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

morphops-0.1.12.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

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

morphops-0.1.12-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file morphops-0.1.12.tar.gz.

File metadata

  • Download URL: morphops-0.1.12.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/51.1.2.post20210110 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.12

File hashes

Hashes for morphops-0.1.12.tar.gz
Algorithm Hash digest
SHA256 f3b4df0742e7dd43636280804273f9529f4256edc5c65bb452e964cd685e26fe
MD5 5e7563246ffc84f277302020da6f6b35
BLAKE2b-256 d9facf18de808289f6a0d85cabe7182b449bab17849560ea9ac4daa405287d52

See more details on using hashes here.

File details

Details for the file morphops-0.1.12-py3-none-any.whl.

File metadata

  • Download URL: morphops-0.1.12-py3-none-any.whl
  • Upload date:
  • Size: 17.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/51.1.2.post20210110 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.12

File hashes

Hashes for morphops-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 d273c6a2ae87e78028f6cd14eb1cc05e00a6c5020ea4b0fa90b194fd11354ded
MD5 fda6245b72a614b43c06e324a4593da8
BLAKE2b-256 36c1081de5141c033fa96289f31beeab62a66012796056fa70a3da57aa6e7ee7

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