harpy.im.baysor_callable#
- harpy.im.baysor_callable(img, df, name_x, name_y, name_gene, config_path, tmp_dir=None, threads=1, diameter=40, min_size=None, use_prior_segmentation=True, prior_confidence=0.2)#
Perform cell segmentation using the Baysor algorithm.
Designed to be compatible with
harpy.im.segment_pointsfor distributed segmentation workflows.- Parameters:
img (
ndarray[tuple[Any,...],dtype[TypeVar(_ScalarT, bound=generic)]]) – The input image as anumpyarray. Dimensions should follow the format (z, y, x, c).df (
DataFrame) – Apandas.DataFramecontaining transcripts. Should include columns for coordinates and gene names.name_x (
str) – The name of the column indfthat contains the X-coordinate of each molecule.name_y (
str) – The name of the column indfthat contains the Y-coordinate of each molecule.name_gene (
str) – The name of the column indfthat contains gene identities (e.g. gene symbols or IDs).config_path (
str|Path) – Path to theconfig.tomlfile used to configure Baysor segmentation parameters.tmp_dir (
str|Path|None(default:None)) – Optional temporary directory to store intermediate files. IfNone, a temporary directory will be created automatically.threads (
int(default:1)) – Number of threads to use during Baysor execution. Defaults to 1.diameter (
int(default:40)) – Approximate expected cell diameter (in pixels). Sets the “scale” parameter in Baysor, which influences segmentation granularity.min_size (
int|None(default:None)) – Minimum allowed cell size (in pixels). Cells smaller than this will be filtered out. IfNone, no filtering is applied.use_prior_segmentation (
bool(default:True)) – Whether to incorporate a prior segmentation mask when running Baysor. IfTrue, segmentation results can be influenced by prior knowledge.prior_confidence (
int(default:0.2)) – Degree of confidence in the prior segmentation, ranging from 0.0 (ignore prior entirely) to 1.0 (strictly adhere to prior). Defaults to 0.2.
- Return type:
ndarray[tuple[Any,...],dtype[TypeVar(_ScalarT, bound=generic)]]- Returns:
: A labeled image (
numpyarray) where each pixel contains an integer representing the segmented cell ID.