phenotypic.measure.MeasureGridSpatial#

class phenotypic.measure.MeasureGridSpatial(*args, **kwargs)[source]

Bases: GridMeasureFeatures

Measure 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 NaN for 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.

  • NaN where 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:
See Also:

Tutorial 7: Measuring and Exporting for a walkthrough of grid-level measurements.

Category: GRID_SPATIAL#

Name

Description

LeftNeighborObjLabel

The object label of the left neighbor colony

LeftDistance

The distance of the left neighbor colony calculated using euclidean distance between bounding boxes

RightNeighborObjLabel

The object label of the right neighbor colony

RightDistance

The distance of the right neighbor colony calculated using euclidean distance between bounding boxes

AboveNeighborObjLabel

The object label of the above neighbor colony

AboveDistance

The distance of the above neighbor colony calculated using euclidean distance between bounding boxes

UnderNeighborObjLabel

The object label of the under neighbor colony

UnderDistance

The distance of the under neighbor colony calculated using euclidean distance between bounding boxes

Methods

__init__

measure

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).