This is a simple library for reading and writing .tps files as created and used by the tpsDig landmarking tool created by F. James Rohlf. https://life.bio.sunysb.edu/morph/
Project description
This is a simple library for reading and writing .tps files as created and used by the tpsDig landmarking tool created by F. James Rohlf. https://life.bio.sunysb.edu/morph/
Installation
The primary way to install is from pip:
pip install py_tps
Installation from source is managed via poetry. https://pypi.org/project/poetry/ Source can be obtained from https://gitlab.com/ryan-feather/py_tps
To install, first install poetry.
Note for conda users
In order to use a conda environment with poetry, you must first configure poetry to use your conda environment and not create a new virtualenv environment. Example:
poetry config settings.virtualenvs.path $CONDA_ENV_PATH poetry config settings.virtualenvs.create 0
Then run:
poetry install poetry build cd dist pip install *.whl
Usage
from py_tps import TPSFile, TPSImage, TPSCurve, TPSPoints import numpy as np # construct and write # numpy is used for numeric data points = TPSPoints(np.asarray([[33,44], [44,45]])) curve = TPSCurve(points) image = TPSImage('T1.JPG', curves=[curve], id_number=0, comment="This is a test", scale=0.0045) tps_file = TPSFile([image]) # can have many images, but here we do just one tps_file.write_to_file('TestFile.TPS')
Creates a file with the contents:
LM=0 CURVES=1 POINTS=2 33 44 44 45 IMAGE=T1.JPG ID=0 COMMENT=This is a test SCALE=0.0045
Now to read:
tps_file_in =TPSFile.read_file('TestFile.TPS') # now can access images list, and so on. Attributes have the same names as they do in the objects above. print(tps_file.images[0].image) # T1.JPG print(tps_file.images[0].curves[0].tps_points.points) # [[33,44],[44,45]]
Landmarks can be set instead of or with curves. If we instead do:
image = TPSImage('T1.JPG', landmarks=points, id_number=0, comment="This is a test", scale=0.0045)
It creates the file with contents:
LM=2 33 44 44 45 IMAGE=T1.JPG ID=0 COMMENT=This is a test SCALE=0.0045
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
Built Distribution
File details
Details for the file py_tps-0.1.7.tar.gz
.
File metadata
- Download URL: py_tps-0.1.7.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.16 CPython/3.6.8 Linux/4.4.0-139-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e12059b60608181b0efb83841b3717f2ffeb5edfefc519bce201bb1e76c5348c |
|
MD5 | 2f61dc6dc40b9630116d32073d2980f9 |
|
BLAKE2b-256 | 6d7b6566b8e8a61e8608ada456f75efa8ce55d93aa41a17b13419e8af2833da5 |
File details
Details for the file py_tps-0.1.7-py3-none-any.whl
.
File metadata
- Download URL: py_tps-0.1.7-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.16 CPython/3.6.8 Linux/4.4.0-139-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 716dd74310f6130f18cba29862214927327c75a2032eb38e7c2a8fea44ef3a08 |
|
MD5 | a4b7d7d6d944b89aad57e3d07617838b |
|
BLAKE2b-256 | 12524863140d697e8b97c3b664d99676f18229e0d152696b4fe605f4da8268d1 |