spacr.png_list

Resolve crop records stored in the png_list database table.

The public helper joins png_list rows to measurement-table locations so the corresponding object can be cut from merged/*.npy. This lightweight module avoids importing segmentation or model dependencies; spacr.io re-exports the helper for compatibility.

Functions

crop_rows_from_png_list(db_path, png_df[, ...])

Add the locations and labels required to cut png_list objects.

Module Contents

spacr.png_list.crop_rows_from_png_list(db_path, png_df, object_type='cell', verbose=True)[source]

Add the locations and labels required to cut png_list objects.

png_list records where a crop was written and which object it came from (<object>_id), but not which merged array produced it. This joins the object table on plate/row/column/field to recover path_name, and turns 'o12' into 12.

Rows whose object id is 'omulti' / 'onone' (a crop overlapping several objects or none) cannot be cut from a single label and are dropped, with a count, rather than silently producing the wrong object.

Parameters:
  • db_path – path to the measurements.db that contains png_df.

  • png_df – rows read from png_list or a compatible object table.

  • object_type – crop mode used to select the object-id column. The default is 'cell'; supported names are the keys of PNG_LIST_ID_COLUMNS.

  • verbose – print the number of unusable rows when True.

Returns:

a copy of png_df with path_name, object_label, object_type and object_label_type columns, minus the rows that cannot be cut. object_type is what was ASKED for and is what the crop cutter reads to choose a mask plane; object_label_type is which object’s labels were actually available, and the two differ when a png_list written for one crop mode is read for another.

Raises:

ValueError – if object_type is unsupported, or if its ID column is absent while multiple other object-ID columns make fallback ambiguous.