phenotypic.measure.MeasureGridSpatial#
- class phenotypic.measure.MeasureGridSpatial(*args, **kwargs)[source]
Bases:
GridMeasureFeaturesMeasure edge-to-edge distances to neighbors in adjacent grid cells.
For each detected colony, identify the nearest object in the left, right, above, and below grid cells and compute the minimum bounding-box edge-to-edge distance. Edge and corner colonies report
NaNfor directions beyond the plate boundary.- Returns:
pd.DataFrame: Object-level neighbor measurements with columns:
Label: unique object identifier.
LeftNeighborObjLabel, LeftDistance.
RightNeighborObjLabel, RightDistance.
AboveNeighborObjLabel, AboveDistance.
UnderNeighborObjLabel, UnderDistance.
NaNwhere no neighbor exists in a given direction.
- Best For:
Quantifying colony spacing and crowding to assess nutrient competition risk on arrayed plates.
Flagging closely spaced colonies that may cross-contaminate.
Enabling neighbor-aware paired statistical comparisons for competition or cooperation studies.
- Consider Also:
MeasureGridLinRegStatsfor regression-based positional quality metrics.MeasureGridSpreadfor within-well colony dispersion rather than between-well distances.MeasureBoundsfor raw bounding boxes and centroids without neighbor lookups.
- See Also:
Tutorial 7: Measuring and Exporting for a walkthrough of grid-level measurements.
Category: GRID_SPATIAL# Name
Description
LeftNeighborObjLabelThe object label of the left neighbor colony
LeftDistanceThe distance of the left neighbor colony calculated using euclidean distance between bounding boxes
RightNeighborObjLabelThe object label of the right neighbor colony
RightDistanceThe distance of the right neighbor colony calculated using euclidean distance between bounding boxes
AboveNeighborObjLabelThe object label of the above neighbor colony
AboveDistanceThe distance of the above neighbor colony calculated using euclidean distance between bounding boxes
UnderNeighborObjLabelThe object label of the under neighbor colony
UnderDistanceThe distance of the under neighbor colony calculated using euclidean distance between bounding boxes
Methods
__init__Compute grid edges and assign each detected object to a grid cell.
- __del__()
Automatically stop tracemalloc when the object is deleted.
- measure(image)
Compute grid edges and assign each detected object to a grid cell.
- Parameters:
image – Image with detected objects.
- Returns:
DataFrame with grid assignments (ROW_NUM, COL_NUM, ROW_MAJOR_IDX).