itasc.contact_analysis.contacts.build

Functions

assign_persistent_edge_ids(frame_edges)

Assign deterministic edge IDs, linking losing/gaining pairs through T1s.

build_contacts(*, cell_labels_path, output_path)

Build the canonical contact-analysis HDF5 file from label stacks.

build_position_contacts(position_path, ...)

Staged-layout wrapper around build_contacts().

ensure_contacts(*, cell_labels_path, output_path)

Build the contact-analysis HDF5 only when it is missing (or overwrite).

Classes

EdgeRecord(frame, pair, kind, edge_label, ...)

T1Record(t1_event_id, frame, edge_id, ...)

class itasc.contact_analysis.contacts.build.EdgeRecord(frame, pair, kind, edge_label, length, midpoint_y, midpoint_x, coordinates)[source]

Bases: object

Parameters:
frame: int
pair: tuple[int, int]
kind: str
edge_label: str
length: float
midpoint_y: float
midpoint_x: float
coordinates: ndarray
class itasc.contact_analysis.contacts.build.T1Record(t1_event_id, frame, edge_id, losing_pair, gaining_pair, location_y, location_x)[source]

Bases: object

Parameters:
t1_event_id: int
frame: int
edge_id: int
losing_pair: tuple[int, int]
gaining_pair: tuple[int, int]
location_y: float
location_x: float
property losing_cell_a: int
property losing_cell_b: int
property gaining_cell_a: int
property gaining_cell_b: int
itasc.contact_analysis.contacts.build.build_contacts(*, cell_labels_path, output_path, nucleus_labels_path=None, source_path=None, edge_extraction_params=None, progress_cb=None)[source]

Build the canonical contact-analysis HDF5 file from label stacks.

Position-agnostic core: takes an explicit cell-label TIFF (2D+t) and an optional nucleus-label TIFF, writing the HDF5 to output_path. source_path is recorded as provenance only. When nucleus_labels_path is given the cell_id == nucleus_id invariant is enforced; otherwise nucleus validation is skipped.

Return type:

Path

Parameters:
itasc.contact_analysis.contacts.build.ensure_contacts(*, cell_labels_path, output_path, nucleus_labels_path=None, overwrite=False, edge_extraction_params=None, progress_cb=None)[source]

Build the contact-analysis HDF5 only when it is missing (or overwrite).

The .h5 is a pure derived artifact of the label inputs, so callers that only need it present (the visualizer, the batch runner) should go through this guard rather than rebuilding unconditionally. Returns (output_path, built) where built is False when an existing file was reused.

Return type:

tuple[Path, bool]

Parameters:
itasc.contact_analysis.contacts.build.build_position_contacts(position_path, output_path, *, cell_tracked_labels_path=None, nucleus_tracked_labels_path=None, edge_extraction_params=None, progress_cb=None)[source]

Staged-layout wrapper around build_contacts().

Resolves the committed <position>/cell_labels.tif and <position>/nucleus_labels.tif labels (what finalize/”commit” writes to the position base folder) when explicit paths are not supplied, then delegates to the position-agnostic core. These are the downstream-stable inputs, not the pre-commit working 3_cell / 2_nucleus tracked labels. Retained for the orchestrator and out-of-repo consumers that pass a position directory.

Return type:

Path

Parameters:
itasc.contact_analysis.contacts.build.assign_persistent_edge_ids(frame_edges)[source]

Assign deterministic edge IDs, linking losing/gaining pairs through T1s.

Return type:

tuple[list[dict[tuple[int, int], int]], list[T1Record]]

Parameters:

frame_edges (list[Iterable[tuple[int, int]]])