spacr.dependent_join

Join dependent-variable values to object-level measurement rows.

The direct identifier columns are preferred. When they are incomplete, crop paths provide a documented fallback from which plate, well, field, and object identifiers can be recovered. Each successful join reports the route used and the number of matched rows; a join with no matches raises an error.

Functions

describe(→ str)

Format the join route and matched-row count for display.

join(→ Tuple[pandas.DataFrame, Dict[str, Any]])

Attach dependent-variable columns to object-level rows.

parts_from_path(→ Dict[str, str])

Extract object identifiers from a crop-image path.

well_to_row_and_column(→ Tuple[str, str])

Convert a well name to canonical row and column identifiers.

Module Contents

spacr.dependent_join.describe(report: Dict[str, Any]) → str[source]

Format the join route and matched-row count for display.

Parameters:

report – dependent-variable join report to summarize.

spacr.dependent_join.join(objects: pandas.DataFrame, dependent: pandas.DataFrame, *, value: str = '') → Tuple[pandas.DataFrame, Dict[str, Any]][source]

Attach dependent-variable columns to object-level rows.

Parameters:
  • objects (pandas.DataFrame) – Object-level measurement rows.

  • dependent (pandas.DataFrame) – Table containing dependent variables and join identifiers or paths.

  • value (str, optional) – Single dependent-variable column to add. When omitted, all columns not already present in objects are added.

Returns:

  • pandas.DataFrame – Copy of objects with matched dependent-variable columns.

  • dict – Join route, matched-row count, total-row count, attempted routes, and names of added columns.

Raises:

ValueError – If the dependent table is empty or no route matches any object row.

spacr.dependent_join.parts_from_path(path: str) → Dict[str, str][source]

Extract object identifiers from a crop-image path.

Parameters:

path (str) – Path whose stem contains plate_well_field_object.

Returns:

dict – Canonical plate, row, column, field, and object identifiers plus the parsed well name. An empty mapping is returned when the pattern is not present.

spacr.dependent_join.well_to_row_and_column(well: str) → Tuple[str, str][source]

Convert a well name to canonical row and column identifiers.

Parameters:

well (str) – Well name such as "A01" or canonical identifier such as "r1c1".

Returns:

tuple of str – Canonical (rowID, columnID) values, for example ("r1", "c1"). Invalid well names return two empty strings.