TPSData#

class ktch.io.TPSData(specimen_name: str, landmarks: ~numpy.ndarray = <property object>, image_path: str = None, scale: float = None, curves: list[~numpy.ndarray] = None, comments: str = None)[source]#

Data for a single specimen in TPS format.

Attributes:
specimen_namestr

Specimen name (ID field in TPS).

landmarksndarray of shape (n_landmarks, n_dim)

Landmark coordinates. n_dim is 2 or 3.

image_pathstr, optional

Path to the associated image (IMAGE field in TPS).

scalefloat, optional

Scale factor (SCALE field in TPS).

curveslist of ndarray, optional

Semilandmark curves. Each array has shape (n_points, n_dim).

commentsstr, optional

Free-text comments (COMMENTS field in TPS).

property idx: str#

Deprecated. Use specimen_name instead.

to_dataframe()[source]#

Return landmark coordinates as a DataFrame.

Returns:
dfpd.DataFrame

DataFrame with columns x, y (and z for 3D). Index is a MultiIndex (specimen_id, coord_id).

to_dataframe_with_curves()[source]#

Return landmark and optional curve DataFrames.

Returns:
df_landmarkspd.DataFrame
df_curveslist of pd.DataFrame or None
to_numpy()[source]#

Return landmark coordinates as a numpy array.

Returns:
landmarksnp.ndarray of shape (n_landmarks, n_dim)
to_numpy_with_curves()[source]#

Return landmarks and optional semilandmark curves.

Returns:
landmarksnp.ndarray of shape (n_landmarks, n_dim)
curveslist of np.ndarray or None