cellcoloc.CellposeModelConfig

class cellcoloc.CellposeModelConfig(model_name_or_path, segmentation_method='cellpose', diameter=None, do_3d=None, z_axis=0, channel_axis=None, cellprob_threshold=0.0, flow_threshold=0.4, anisotropy=False, flow3d_smooth=0, prefilter=None, prefilter_sigma_xy=1.0, prefilter_sigma_z=None, prefilter_median_size_xy=3, prefilter_median_size_z=None, z_crop=None, z_projection=None, threshold_percentile=98.0, threshold_background_sigma=None, threshold_min_object_voxels=10, threshold_min_hole_voxels=10, threshold_apply_closing=True, postfilters=None, min_intensity_measure='mean', min_intensity_threshold=None, local_contrast_k=1.0, local_contrast_shell_inner_radius=1, local_contrast_shell_outer_radius=4, bright_pixel_measure='count', bright_pixel_threshold=None, bright_pixel_min_count=None, bright_pixel_min_fraction=None)[source]

Collect Cellpose settings for one segmentation target.

diameter

Diameter parameter passed to cellpose.models.CellposeModel.eval(). For Cellpose 4 and newer this can be set to None to let Cellpose choose its default behavior without an explicit diameter.

model_name_or_path

Either a built-in Cellpose model identifier such as "cyto3" or "nuclei", or a filesystem path pointing to a custom trained model.

segmentation_method

Segmentation backend used for this channel. "cellpose" keeps the existing neural-network workflow. "otsu", "li", and "percentile" use intensity thresholding followed by connected component labeling.

do_3d

Whether Cellpose should run in 3D mode. If set to None, the pipeline auto-detects 2D versus 3D from the loaded image z-size.

z_axis

Array axis representing the z dimension for Cellpose.

channel_axis

Channel axis passed to Cellpose. Keep this as None for single channel volumes.

cellprob_threshold

Cellpose pixel probability threshold used during mask generation. This is only forwarded explicitly for Cellpose 4 and newer.

flow_threshold

Cellpose flow error threshold used during mask generation. This is only forwarded explicitly for Cellpose 4 and newer.

anisotropy

Controls whether a 3D Cellpose run should use anisotropy correction. Set this to False to disable anisotropy handling entirely, to True to let the pipeline derive an anisotropy factor from the configured voxel size, or to a numeric value to force a specific Cellpose anisotropy factor. The value is ignored for 2D runs.

flow3d_smooth

Optional Gaussian smoothing strength forwarded to Cellpose for 3D flow fields. This setting only has an effect for true 3D runs and is ignored for 2D data. Keep the default 0 to disable smoothing.

prefilter

Optional image prefilter or ordered prefilter chain applied before segmentation. Supported values are None, a single string such as "gaussian", "laplacian_of_gaussian" (alias "log"), or "median", or a sequence combining these filters in the requested execution order.

prefilter_sigma_xy

Gaussian prefilter sigma in the in-plane directions. Used when prefilter="gaussian".

prefilter_sigma_z

Gaussian prefilter sigma along z. If None, the pipeline reuses prefilter_sigma_xy. Only relevant for 3D data.

prefilter_median_size_xy

Median prefilter kernel size in the in-plane directions. Used when prefilter="median".

prefilter_median_size_z

Median prefilter kernel size along z. If None, the pipeline reuses prefilter_median_size_xy. Only relevant for 3D data.

z_crop

Optional global z-range restriction in (start, stop) form. When set on any participating channel config, the pipeline applies this crop consistently to all channels and all ROIs for the internal segmentation and quantification steps. The full stack is still shown in visualization outputs.

z_projection

Optional global projection method applied along the z axis before any later ROI drawing, segmentation, quantification, or visualization. Supported values are None (default), "max", "mean", "median", "std", and "var". When used together with z_crop, only the cropped z interval is projected.

threshold_percentile

Percentile used when segmentation_method="percentile".

threshold_background_sigma

Optional Gaussian sigma used for background subtraction before threshold-based segmentation.

threshold_min_object_voxels

Minimum object size kept after threshold-based segmentation.

threshold_min_hole_voxels

Minimum hole size filled after threshold-based segmentation.

threshold_apply_closing

Whether a small binary closing step should be applied before threshold cleanup.

postfilters

Optional post-segmentation filters applied to the resulting masks. Supported values are None, "min_intensity", "local_contrast", "bright_pixel_support", or a list combining them in the requested execution order.

min_intensity_measure

Statistic used by the "min_intensity" postfilter. Supported values are "mean", "median", and "max".

min_intensity_threshold

Intensity threshold used by the "min_intensity" postfilter.

local_contrast_k

Contrast multiplier used by the "local_contrast" postfilter in the criterion object_median > background_median + k * background_mad.

local_contrast_shell_inner_radius

Inner dilation radius, in pixels or voxels, used to construct the local shell for the "local_contrast" postfilter.

local_contrast_shell_outer_radius

Outer dilation radius, in pixels or voxels, used to construct the local shell for the "local_contrast" postfilter.

bright_pixel_measure

Statistic used by the "bright_pixel_support" postfilter. "count" requires at least a minimum number of bright pixels within the mask, while "fraction" requires a minimum fraction of bright pixels relative to the object size.

bright_pixel_threshold

Intensity threshold above which a pixel or voxel counts as bright for the "bright_pixel_support" postfilter.

bright_pixel_min_count

Minimum number of bright pixels or voxels required when bright_pixel_measure="count".

bright_pixel_min_fraction

Minimum fraction of bright pixels or voxels required when bright_pixel_measure="fraction".

__init__(model_name_or_path, segmentation_method='cellpose', diameter=None, do_3d=None, z_axis=0, channel_axis=None, cellprob_threshold=0.0, flow_threshold=0.4, anisotropy=False, flow3d_smooth=0, prefilter=None, prefilter_sigma_xy=1.0, prefilter_sigma_z=None, prefilter_median_size_xy=3, prefilter_median_size_z=None, z_crop=None, z_projection=None, threshold_percentile=98.0, threshold_background_sigma=None, threshold_min_object_voxels=10, threshold_min_hole_voxels=10, threshold_apply_closing=True, postfilters=None, min_intensity_measure='mean', min_intensity_threshold=None, local_contrast_k=1.0, local_contrast_shell_inner_radius=1, local_contrast_shell_outer_radius=4, bright_pixel_measure='count', bright_pixel_threshold=None, bright_pixel_min_count=None, bright_pixel_min_fraction=None)

Methods

__init__(model_name_or_path[,Β ...])

Attributes

model_name_or_path

segmentation_method

diameter

do_3d

z_axis

channel_axis

cellprob_threshold

flow_threshold

anisotropy

flow3d_smooth

prefilter

prefilter_sigma_xy

prefilter_sigma_z

prefilter_median_size_xy

prefilter_median_size_z

z_crop

z_projection

threshold_percentile

threshold_background_sigma

threshold_min_object_voxels

threshold_min_hole_voxels

threshold_apply_closing

postfilters

min_intensity_measure

min_intensity_threshold

local_contrast_k

local_contrast_shell_inner_radius

local_contrast_shell_outer_radius

bright_pixel_measure

bright_pixel_threshold

bright_pixel_min_count

bright_pixel_min_fraction