cellcoloc.analyze_existing_masks

cellcoloc.analyze_existing_masks(loaded_images, roi_labels_2d, cell_masks, marker_masks, colocalization_config, optional_region_result=None, optional_region_masks=None, analysis_z_bounds=None, cell_refinement_context=None, marker_refinement_context=None, optional_region_refinement_context=None, cell_model_config=None, marker_model_config=None, optional_region_model_config=None)[source]

Recompute colocalization tables from existing label masks.

This helper is used both after the initial Cellpose segmentation and after any later manual or threshold-based refinement of the label masks.

Parameters:
  • loaded_images – Loaded raw analysis channels and dataset metadata.

  • roi_labels_2d – Drawn or generated 2D ROI label mask.

  • cell_masks, marker_masks – Full-stack label masks for the two primary analysis channels. They may originate from Cellpose, thresholding, or manual relabeling.

  • colocalization_config – Thresholds controlling how per-cell overlaps are interpreted.

  • optional_region_result, optional_region_masks – Optional third-channel segmentation supplied either as the legacy result wrapper or directly as a label image. When both are provided, optional_region_masks takes precedence.

  • analysis_z_bounds – Optional global z interval used for the current analysis. Labels outside this interval are ignored internally but the stored masks keep full-stack shape.

  • cell_refinement_context, marker_refinement_context – Optional cached Cellpose network outputs used for later threshold-only refinement.

  • cell_model_config, marker_model_config, optional_region_model_config – Optional channel configs reused here mainly so postfilters can be applied consistently when masks are reanalyzed.

Return type:

ColocalizationRunResult

Returns:

ColocalizationRunResult – Structured masks and tables reflecting the provided segmentation state.