cyto.segmentation

Deep-learning and classical segmentation models. StarDist requires TensorFlow; Cellpose requires PyTorch.

class cyto.segmentation.base.SegmentationBase(name: str, verbose: bool = True, execution_config: Dict[str, Any] | None = None)[source]

Bases: PipelineTask

run_baremetal(data: Dict[str, Any]) Dict[str, Any][source]

Main segmentation pipeline for baremetal execution.

Parameters:

data (Dict) – Dictionary containing ‘image’ key with image data

Returns:

Dictionary with ‘image’ and ‘label’ keys

Return type:

Dict

run_container(data: Dict[str, Any]) Dict[str, Any][source]

Run segmentation in a container using the configured runner.

This method handles the container execution by:

  1. Getting the appropriate runner (Docker/Singularity) from execution_config.

  2. Passing the task (self) and data to the runner.

  3. The runner serializes the task and data, runs them in a container, and deserializes the result.

  4. Inside the container, the container_worker calls run_baremetal().

Parameters:

data (Dict[str, Any]) – Dictionary containing ‘image’ key with image data

Returns:

Dictionary with ‘image’ and ‘label’ keys from container execution

Return type:

Dict[str, Any]

class cyto.segmentation.stardist.StarDist(model_name='2D_versatile_fluo', prob_thresh=0.479071, nms_thresh=0.3, verbose=True)[source]

Bases: SegmentationBase

class cyto.segmentation.cellpose.Cellpose(model_type='cyto', cellprob_thresh=-3, model_matching_thresh=10.0, gpu=True, channels=[0, 0], batch_size=16, diameter=16.18, verbose=True, execution_config=None)[source]

Bases: SegmentationBase

run_container(data: Dict[str, Any]) Dict[str, Any][source]

Run CellPose segmentation in a container.

This method uses the base class container execution logic which handles the container orchestration and calls run_baremetal inside the container.

Parameters:

data (Dict[str, Any]) – Dictionary containing ‘image’ key with image data

Returns:

Dictionary with ‘image’ and ‘label’ keys from container execution

Return type:

Dict[str, Any]