cellmil.segmentation¶
- class cellmil.segmentation.CellSegmenter(config: CellSegmenterConfig)[source]¶
Bases:
objectClass for cell instance segmentation in whole slide images.
Features reliable multiprocessing with Pool.imap and automatic fallback to sequential processing if multiprocessing fails.
- __init__(config: CellSegmenterConfig) None[source]¶
- set_wsi(wsi_path: str | pathlib.Path, patched_slide_path: str | pathlib.Path) None[source]¶
Set the WSI path and patched slide path for segmentation.
- _get_wsi_dimensions() tuple[int, int][source]¶
Get the dimensions (width, height) of the WSI at level 0.
- _are_contour_coordinates_valid(contour_global: ndarray[Any, Any]) bool[source]¶
Check if contour coordinates are within the WSI bounds.
- Parameters:
contour_global (np.ndarray) – Global contour coordinates, shape (N, 2) where each point is [x, y]
- Returns:
True if all contour points are within WSI bounds, False otherwise
- Return type:
- get_cell_predictions(predictions: dict[str, torch.Tensor], magnification: float | int = 40) list[dict[numpy.int32, dict[str, Any]]] | list[dict[int, dict[str, Any]]][source]¶
Get cell predictions from model output
- Parameters:
predictions (torch.Tensor) – Model output
magnification (float, optional) – Magnification of the WSI. Defaults to 40.0.
- Returns:
Dictionary with cell predictions
- Return type:
Modules