Morphology Features API
pictologics.features.morphology
Morphology Feature Extraction Module
This module provides functions for calculating Morphological (Shape and Size) features from medical images. It implements the Image Biomarker Standardisation Initiative (IBSI) compliant algorithms.
Key Features:
- Voxel-based: Volume (voxel counting).
- Mesh-based: Surface Area, Volume (mesh), Compactness, Sphericity.
- PCA-based: Major/Minor/Least Axis Length, Elongation, Flatness.
- Convex Hull: Volume, Area, Max 3D Diameter.
- Bounding Box: Oriented (OMBB) and Axis-Aligned (AABB) Bounding Boxes.
- Minimum Volume Enclosing Ellipsoid (MVEE): Volume, Area.
- Intensity-Weighted: Center of Mass Shift, Integrated Intensity.
Optimization:
Uses numba for optimizing the Khachiyan algorithm for MVEE calculation.
Example
Calculate morphology features from a mask:
import numpy as np
from pictologics.loader import Image
from pictologics.features.morphology import calculate_morphology_features
# Create dummy mask
mask_arr = np.zeros((50, 50, 50), dtype=np.uint8)
mask_arr[10:40, 10:40, 10:40] = 1
mask = Image(mask_arr, spacing=(1.0, 1.0, 1.0), origin=(0,0,0))
# Calculate features
features = calculate_morphology_features(mask)
print(features["volume_voxel_counting_YEKZ"])
calculate_morphology_features(mask, image=None, intensity_mask=None)
Calculate morphological features from the ROI mask. Includes both voxel-based and mesh-based features (IBSI compliant).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mask
|
Image
|
Image object containing the binary mask (Morphological Mask). |
required |
image
|
Optional[Image]
|
Optional Image object containing intensity data (required for some features). |
None
|
intensity_mask
|
Optional[Image]
|
Optional Image object containing the intensity mask (e.g. after outlier filtering).
If provided, used for intensity-weighted features (99N0, KLMA).
If None, defaults to |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, float]
|
Dictionary of calculated features. |