cyto_dl.models.im2im.utils.instance_seg module#
- class cyto_dl.models.im2im.utils.instance_seg.InstanceSegCluster(dim: int = 3, anisotropy: float = 2.6, skel_threshold: float = 0, semantic_threshold: float = 0, min_size: int = 1000, distance_threshold: int = 100, progress: bool = True)[source]#
Bases:
object
Clustering for InstanceSeg - finds skeletons and assigns semantic points to skeleton based on spatial embedding and nearest neighbor distances.
- class cyto_dl.models.im2im.utils.instance_seg.InstanceSegLoss(dim: int = 3, weights: Dict[str, float] | None = {})[source]#
Bases:
object
Loss function for InstanceSeg.
- Parameters:
dim (int=3) – Spatial dimension of input images.
weights (Optional[Dict[str, float]]={}) – Dictionary of weights for each loss component.
- class cyto_dl.models.im2im.utils.instance_seg.InstanceSegPreprocessd(label_keys: Sequence[str] | str, kernel_size: int = 3, thin: int = 5, dim: int = 3, anisotropy: float = 2.6, keep_largest: bool = True, allow_missing_keys: bool = False)[source]#
Bases:
Transform
- Parameters:
label_keys (Union[Sequence[str], str]) – Keys of instance segmentations in input dictionary to convert to Instance Seg ground truth images.
kernel_size (int=3) – Size of kernel for gaussian smoothing of flows
thin (int=5) – Amount to thin to create psuedo-skeleton
dim (int=3) – Spatial dimension of images
anisotropy (float=2.6) – Anisotropy of images
keep_largest (bool=True) – Whether to keep only the largest connected component of each label
allow_missing_keys (bool=False) – Whether to raise error if key in label_keys is not present
- embed_from_skel(skel: ndarray, iseg: ndarray)[source]#
Find per-pixel embedding vector to closest point on skeleton.
- class cyto_dl.models.im2im.utils.instance_seg.InstanceSegRandFlipd(spatial_axis: int, label_keys: str | Sequence[str] = [], image_keys: str | Sequence[str] = [], prob: float = 0.5, dim: int = 3, allow_missing_keys: bool = False)[source]#
Bases:
RandomizableTransform
Flipping Augmentation for InstanceSeg training.
When flipping ground truths generated by InstanceSegPreprocessD, the sign of gradients have to be changed after flipping.
- Parameters:
spatial_axis (int) – axis to flip across
label_keys (Union[str, Sequence[str]]=[]) – key or list of keys generated by InstanceSegPreprocessD to flip
image_keys (Union[str, Sequence[str]]=[]) – key or list of keys NOT generated by InstanceSegPreprocessd to flip
prob (float=0.1) – probability of flipping
dim (int=3) – spatial dimensions of images
allow_missing_keys (bool=False) – Whether to raise error if a provided key is missing