phenotypic.measure.MeasureGridSpread#
- class phenotypic.measure.MeasureGridSpread[source]#
Bases:
GridMeasureFeaturesQuantify spatial distribution of colonies within grid sections of arrayed assays.
This class measures colony clustering and spread within each grid cell (well) of a high-throughput microbial phenotyping plate. It computes the sum of squared pairwise distances between all colony pairs in each section, revealing whether multiple colonies are dispersed within a well or tightly clustered near the center.
Intuition: In ideal arrayed assays, each well contains a single localized colony at the expected position. High ObjectSpread values indicate multiple colonies, fragmented growth, or spread beyond the well boundary. This metric helps identify sections with detection ambiguity or atypical growth patterns that may compromise phenotypic measurements.
Use cases (agar plates): - Detect over-segmentation: Multiple detected objects in a single well instead of one cohesive colony. - Identify spreading or invasive growth: Colonies extending far beyond their designated grid position
into adjacent areas.
Flag wells with questionable data quality for manual review or exclusion from downstream analysis.
Assess plate quality: Systematic high spread values across the plate suggest uneven agar surface, condensation issues, or poor inoculation technique.
Prioritize sections for refinement operations (e.g., object merging or filtering).
Caveats: - ObjectSpread depends on colony density and size; small plates with tight spacing have inherently
different baselines than larger assays.
Spread values are not normalized by well area; compare only within the same plate type and grid.
Touching or overlapping colonies may register as a single large object (low spread) or two smaller objects (high spread) depending on detection algorithm performance. Use in conjunction with object count and boundary metrics for robust quality assessment.
The metric is sensitive to very small or very large colonies; outliers in position or size can disproportionately inflate spread values.
- Returns:
- pd.DataFrame: Section-level statistics with columns:
Section numbers (index from grid).
Count: Number of colonies detected in each section.
- ObjectSpread: Sum of squared pairwise Euclidean distances between colonies.
Sorted in descending order by ObjectSpread.
- Examples:
Measure colony spread across a plate
from phenotypic import GridImage from phenotypic.detect import OtsuDetector from phenotypic.measure import MeasureGridSpread # Load a plate with grid grid_image = GridImage.from_image_path("plate_384well.jpg", grid_shape=(16, 24)) # Detect colonies detector = OtsuDetector() grid_image = detector.operate(grid_image) # Measure spread per well spreader = MeasureGridSpread() spread_results = spreader.operate(grid_image) # Find wells with high spread (potential over-segmentation) high_spread = spread_results.nlargest(10, 'GridSpread_ObjectSpread') print(f"Top 10 problematic wells:") print(high_spread)
Identify over-segmented wells
# Flag wells with both multiple detections AND high spread multi_obj = spread_results[spread_results['count'] > 1] high_spread_multi = multi_obj[ multi_obj['GridSpread_ObjectSpread'] > spread_results['GridSpread_ObjectSpread'].quantile(0.75) ] print(f"Wells needing refinement: {list(high_spread_multi.index)}")
Category: GRID_SPREAD# Name
Description
ObjectSpreadSum of squared pairwise Euclidean distances between all unique colony pairs within a grid section. Quantifies spatial dispersion of colonies in a grid cell. Higher values indicate greater spread from the section center, suggesting over-segmentation, multi-detections, or colonies growing beyond expected boundaries. Used to identify problematic grid sections requiring refinement or quality review.
Methods
__init__Processes an arr image to calculate and organize grid-based boundaries and centroids using coordinates.
- __del__()#
Automatically stop tracemalloc when the object is deleted.
- measure(image)#
Processes an arr image to calculate and organize grid-based boundaries and centroids using coordinates. This function implements a two-pass approach to refine row and column boundaries with exact precision, ensuring accurate grid labeling and indexing. The function dynamically computes boundary intervals and optimally segments the arr space into grids based on specified nrows and columns.
- Parameters:
image (Image) – The arr image to be analyzed and processed.
- Returns:
A DataFrame containing the grid results including boundary intervals, grid indices, and section numbers corresponding to the segmented arr image.
- Return type:
pd.DataFrame