phenotypic.measure.MeasureGridLinRegStats#

class phenotypic.measure.MeasureGridLinRegStats(section_num: int | None = None)[source]

Bases: GridMeasureFeatures

Evaluate grid alignment quality using row-wise and column-wise linear regression.

Fit linear regressions to colony centroid positions along each row and column of the grid, then compute per-colony residual error (Euclidean distance between observed and predicted centroid). High residual errors flag off-grid growth, misdetections, or plate warping.

Args:
section_num: Grid section index to restrict measurements to.

None measures across the entire grid. Default: None.

Returns:

pd.DataFrame: Per-object metrics indexed by object label:

  • RowM, RowB: row regression slope and intercept.

  • ColM, ColB: column regression slope and intercept.

  • PredRR, PredCC: predicted centroid from regression.

  • ResidualError: Euclidean distance between actual and predicted centroid.

Best For:
  • Identifying colonies that grew outside their designated grid position on arrayed plates.

  • Detecting systematic rotation or shear across the plate to validate grid detection quality.

  • Filtering or weighting colonies by positional confidence before downstream phenotypic analysis.

Consider Also:
See Also:

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

Category: GRID_LINREG_STATS#

Name

Description

RowM

Slope of row-wise linear regression fit across column positions. Measures systematic drift in row alignment. Values near 0 indicate horizontal rows; non-zero values suggest rotational misalignment or systematic row curvature across the plate.

RowB

Intercept of row-wise linear regression fit. Represents the expected row coordinate when column position is 0. Combined with slope, defines the expected row trend line for quality assessment and position prediction.

ColM

Slope of column-wise linear regression fit across row positions. Measures systematic drift in column alignment. Values near 0 indicate vertical columns; non-zero values suggest rotational misalignment or systematic column curvature across the plate.

ColB

Intercept of column-wise linear regression fit. Represents the expected column coordinate when row position is 0. Combined with slope, defines the expected column trend line for quality assessment and position prediction.

PredRR

Predicted row coordinate from column-wise linear regression. Uses the column position and column regression parameters (ColM, ColB) to estimate where the row coordinate should be if the grid were perfectly aligned. Used for calculating residual errors and detecting misaligned colonies.

PredCC

Predicted column coordinate from row-wise linear regression. Uses the row position and row regression parameters (RowM, RowB) to estimate where the column coordinate should be if the grid were perfectly aligned. Used for calculating residual errors and detecting misaligned colonies.

ResidualError

Euclidean distance between the actual colony centroid and the predicted position from linear regression. Quantifies how far each colony deviates from the expected grid pattern. High values indicate misdetections, off-grid growth, or local plate warping. Used by refinement operations to filter outliers and select the most plausible colony per grid cell.

Methods

__init__

measure

Compute grid edges and assign each detected object to a grid cell.

Parameters:

section_num (Optional[int])

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