API Reference¶
Welcome to the Histolytics API Reference. Here you'll find an overview of all public objects, functions and methods implemented in Histolytics.
Modules¶
Data¶
Sample datasets
- cervix_nuclei: A GeoDataframe of segmented nuclei of a cervical biopsy.
- cervix_tissue: A GeoDataframe of segmented tissue regions of a cervical biopsy.
- cervix_nuclei_crop: A GeoDataframe of segmented nuclei of a cervical biopsy (cropped).
- cervix_tissue_crop: A GeoDataframe of segmented tissue regions of a cervical biopsy (cropped).
- hgsc_nuclei_wsi: A GeoDataframe of segmented nuclei of a HGSC whole slide image.
- hgsc_tissue_wsi: A GeoDataframe of segmented tissue regions of a HGSC whole slide image.
- hgsc_cancer_nuclei: A GeoDataframe of segmented nuclei of a HGSC tumor nest.
- hgsc_cancer_he: A 1500x1500 H&E image of HGSC containing a tumor nest.
- hgsc_stroma_nuclei: A GeoDataframe of segmented nuclei of a HGSC stroma.
- hgsc_stroma_he: A 1500x1500 H&E image of HGSC containing stroma.
Losses¶
Loss functions for panoptic segmentation
- BCELoss: Binary Cross Entropy Loss.
- CELoss: Cross Entropy Loss.
- DiceLoss: Dice Loss.
- FocalLoss: Focal Loss.
- JointLoss: Joint Loss. Combines arbitrary number of losses into one.
- MSE: Mean Squared Error Loss.
- MAE: Mean Absolute Error Loss.
- MultiTaskLoss: Multi-task loss for panoptic segmentation. Combines multiple losses for multi prediction tasks like panoptic segmentation.
- SSIM: Structural Similarity Index Loss.
- TverskyLoss: Tversky Loss.
Metrics¶
Metrics for panoptic segmentation
- accuracy_multiclass: Accuracy metric for multiclass segmentation.
- aggregated_jaccard_index: Aggregated Jaccard Index for multiclass segmentation.
- average_precision: Average Precision metric for multiclass segmentation.
- dice_multiclass: Dice metric for multiclass segmentation.
- dice2: Alternative Dice metric for multiclass segmentation.
- f1score_multiclass: F1 score metric for multiclass segmentation.
- iou_multiclass: Intersection over Union (IoU) metric for multiclass segmentation.
- pairwise_object_stats: Pairwise object statistics (TP, FP, TN, FN) for instance segmentation.
- pairwise_pixel_stats: Pairwise pixel-level statistics (TP, FP, TN, FN) for instance segmentation.
- panoptic_quality: Panoptic Quality metric for panoptic segmentation.
- sensitivity_multiclass: Sensitivity metric for multiclass segmentation.
- specificity_multiclass: Specificity metric for multiclass segmentation.
Models¶
Panoptic segmentation models
- CellposePanoptic: Panoptic segmentation model based on Cellpose.
- CellVitPanoptic: Panoptic segmentation model based on CellVit.
- CPPNetPanoptic: Panoptic segmentation model based on CPPNet.
- HoverNetPanoptic: Panoptic segmentation model based on HoverNet.
- StarDistPanoptic: Panoptic segmentation model based on StarDist.
Nuclei Features¶
Extracting features from nuclei
- chromatin_clumps: Extract chromatin clumps from a nuclei segmentation.
- grayscale_intensity: Extract grayscale intensity features from a nuclei segmentation.
- rgb_intensity: Extract RGB intensity features from a nuclei segmentation.
Spatial Aggregation¶
Neighborhood statistics and grid aggregation
- local_character: Get summary metrics of neighboring nuclei features.
- local_diversity: Get diversity indices of neighboring nuclei features.
- local_distances: Get distances to neighboring nuclei.
- local_vals: Get local values of neighboring nuclei.
- local_type_counts: Get counts of neighboring nuclei types.
- grid_agg: Aggregate spatial data within grid cells.
Spatial Clustering¶
Clustering and cluster metrics
- density_clustering: Perform density-based clustering on spatial data.
- lisa_clustering: Perform Local Indicators of Spatial Association (LISA) clustering.
- cluster_feats: Extract features from spatial clusters.
- cluster_tendency: Calculate cluster tendency (centroid).
- local_autocorr: Calculate local Moran's I for each object in a GeoDataFrame.
- global_autocorr: Calculate global Moran's I for a GeoDataFrame.
- ripley_test: Perform Ripley's alphabet analysis for GeoDataFrames.
Spatial Geometry¶
Morphometrics and shapes
- shape_metric: Calculate shape moprhometrics for polygon geometries.
- line_metric: Calculate shape moprhometrics for line geometries.
- medial_lines: Create medial lines of input polygons.
- hull: Create various hull types around point sets.
Spatial Graph¶
Graph fitting
- fit_graph: Fit a graph to a GeoDataFrame of segmented objects.
- get_connected_components: Get connected components of a spatial graph.
- weights2gdf: Convert spatial weights to a GeoDataFrame.
Spatial Operations¶
Spatial querying and partitioning
- get_objs: Query segmented objects from specified regions.
- get_interfaces: Get interfaces of two segmented tissues.
- rect_grid: Partition a GeoDataFrame into a rectangular grid.
- h3_grid: Partition a GeoDataFrame into an H3 hexagonal spatial index (grid).
- quadbin_grid: Partition a GeoDataFrame into a Quadbin spatial index (grid).
Stroma Features¶
Extracting features from stroma
- extract_collagen_fibers: Extract collagen fibers from a H&E images.
- stromal_intensity_features: Compute intensity features from a H&E image representing stroma.
- get_hematoxylin_mask: Get hematoxylin mask from a H&E image.
- get_eosin_mask: Get eosin mask from a H&E image.
- tissue_components: Extract background, foreground, and nuclear components from a H&E image.
- kmeans_img: Perform KMeans clustering on an image.
- hed_decompose: Transform an image to HED space.
Transforms¶
Image and instance label transforms for model training
- AlbuStrongAugment: Apply StrongAugment augmentation algorithm.
- ApplyEach: Apply a functions to label masks and return each output separately.
- BinarizeTransform: Binarize label masks.
- CellposeTransform: Transform label masks to Cellpose flow maps.
- ContourTransform: Transform label masks to contour maps.
- DistTransform: Transform label masks to distance maps.
- EdgeWeightTransform: Transform label masks to edge weight maps.
- HoverNetTransform: Transform label masks to HoverNet horizontal and vertical gradient maps.
- MinMaxNormalization: Apply Min-Max normalization to input image.
- Normalization: Normalize/Standardize input image.
- PercentileNormalization: Normalize input image using percentiles.
- SmoothDistTransform: Transform label masks to smooth distance maps.
- StarDistTransform: Transform label masks to StarDist star-distance maps.
Utils¶
Utility functions and classes
gdf¶
- gdf_apply: Apply a function to a GeoDataFrame in parallel.
- gdf_to_polars: Convert a GeoDataFrame to a Polars DataFrame.
- get_centroid_numpy: Get the centroids of a GeoDataFrame as a NumPy array.
- set_uid: Set a unique identifier (UID) for each object in a GeoDataFrame.
- set_geom_precision: Set the precision of geometries in a GeoDataFrame.
raster¶
- inst2gdf: Convert an instance segmentation mask to a GeoDataFrame.
- sem2gdf: Convert a semantic tissue segmentation mask to a GeoDataFrame.
- gdf2inst: Convert a GeoDataFrame to an instance segmentation mask.
- gdf2sem: Convert a GeoDataFrame to a semantic tissue segmentation mask.
plot¶
- draw_thing_contours: Draw contours of segmented nuclei and overlay them on an image.
- legendgram: Create a histogram legend for a specified column in a GeoDataFrame.
WSI (Whole Slide Images)¶
WSI handling and WSI-level segmentation
- SlideReader: Functions for reading whole slide images
- WsiPanopticSegmenter: Class handling the panoptic segmentation of whole slide images
- get_sub_grids: Get sub-grids from a whole slide image.