API Reference

This section provides detailed API documentation for all MedTDA modules and classes.

Overview

MedTDA is organized into several key modules:

  • featureextractor - Main interface for TDA feature extraction

  • preprocessor - Image preprocessing utilities

  • ph_computer - Persistent homology computation

  • barcodeextractor - Raw barcode extraction

  • vectorizers - Methods to convert barcodes to feature vectors

  • loaders - Image and mask loading/saving

  • utils - General utility functions

  • cli - Command-line interface

Quick Navigation

Module

Description

FeatureExtractor

Main FeatureExtractor class for end-to-end feature extraction

Preprocessor

Preprocessor class for image normalization and preparation

PH Computer

Functions for computing persistent homology

BarcodeExtractor

BarcodeExtractor class for raw barcode computation

Vectorizers

All 8 vectorization methods (functions)

Loaders

Image and mask loading/saving functions

Utils

General utility functions for image processing

CLI

Command-line interface functions and argument parsing

Typical Usage Pattern

The typical workflow uses the FeatureExtractor class as the main interface:

from medtda import FeatureExtractor

# Initialize with configuration
extractor = FeatureExtractor(
    vectorization_method='PersImage',
    normalize=True
)

# Extract features
features = extractor.execute('image.nii.gz', mask='mask.nii.gz')

For more control, you can use individual components:

from medtda import Preprocessor, BarcodeExtractor
from medtda.vectorizers import persistence_image

# Step-by-step processing
preprocessor = Preprocessor(normalize=True)
processed_image, _ = preprocessor.preprocess(image, mask)

extractor = BarcodeExtractor()
barcodes = extractor.execute(processed_image)

features = persistence_image(barcodes['H1'])

Module Documentation

Core Classes

FeatureExtractor

The main interface for TDA feature extraction. See FeatureExtractor for details.

Key methods:

  • execute(image, mask=None) - Extract features from an image

  • set_vectorization_method(method, **params) - Change vectorization method

  • enable_vectorization_methods(methods) - Enable multiple methods

Preprocessor

Handles image preprocessing operations. See Preprocessor for details.

Key methods:

  • preprocess(image, mask=None) - Apply all preprocessing steps

  • Individual methods for normalization, resampling, windowing, etc.

BarcodeExtractor

Extracts raw persistence barcodes. See BarcodeExtractor for details.

Key methods:

  • extract(image) - Compute persistence barcodes

  • set_filtration_type(filtration_type) - Change filtration type

  • set_construction(construction) - Change construction method

Vectorization Functions

MedTDA provides 8 different vectorization methods as standalone functions:

Function

Description

persistence_stats(barcode)

Statistical summaries (mean, std, min, max, etc.)

betti_curve(barcode, resolution)

Betti numbers as function of filtration value

persistence_image(barcode, bandwidth, resolution)

2D histogram weighted by persistence

persistence_landscape(barcode, resolution, num_landscapes)

Functional representation using landscapes

persistence_silhouette(barcode, resolution, weight)

Average persistence landscape

entropy_summary(barcode, resolution)

Information-theoretic features

persistence_lifespan(barcode, resolution)

Distribution of feature lifespans

persistence_tropical_coordinates(barcode, r)

Tropical algebra representation

See Vectorizers for detailed documentation of each method.

Utility Functions

The utils module provides various helper functions:

  • resample_image() - Image resampling

  • normalize_image() - Intensity normalization

  • apply_mask() - Apply binary mask

  • crop_to_roi() - Crop to region of interest

  • extract_label_from_mask() - Extract single label from multi-label mask

See Utils for complete documentation.

Image Loading and Saving

The loaders module handles I/O operations:

  • load_image(path) - Load 2D or 3D images (NIFTI, PNG, TIFF, etc.)

  • load_mask(path) - Load binary or multi-label masks

  • save_image(array, path) - Save images to disk

  • Validation functions for images and masks

See Loaders for complete documentation.

Command-Line Interface

The cli module provides the command-line interface:

  • create_parser() - Create argument parser

  • process_single_file(args) - Process single image

  • process_batch(args) - Process batch of images

  • main() - Main entry point

See CLI for complete documentation.

Indices and Tables