Args: applied_labels: Labels for applying the connected component analysis on. If given, voxels whose value is in this list will be analyzed. If `None`, all non-zero values will be analyzed. is_onehot: if `True`, treat the input data a
(
self,
applied_labels: Sequence[int] | int | None = None,
is_onehot: bool | None = None,
independent: bool = True,
connectivity: int | None = None,
num_components: int = 1,
)
| 291 | backend = [TransformBackends.NUMPY, TransformBackends.CUPY] |
| 292 | |
| 293 | def __init__( |
| 294 | self, |
| 295 | applied_labels: Sequence[int] | int | None = None, |
| 296 | is_onehot: bool | None = None, |
| 297 | independent: bool = True, |
| 298 | connectivity: int | None = None, |
| 299 | num_components: int = 1, |
| 300 | ) -> None: |
| 301 | """ |
| 302 | Args: |
| 303 | applied_labels: Labels for applying the connected component analysis on. |
| 304 | If given, voxels whose value is in this list will be analyzed. |
| 305 | If `None`, all non-zero values will be analyzed. |
| 306 | is_onehot: if `True`, treat the input data as OneHot format data, otherwise, not OneHot format data. |
| 307 | default to None, which treats multi-channel data as OneHot and single channel data as not OneHot. |
| 308 | independent: whether to treat ``applied_labels`` as a union of foreground labels. |
| 309 | If ``True``, the connected component analysis will be performed on each foreground label independently |
| 310 | and return the intersection of the largest components. |
| 311 | If ``False``, the analysis will be performed on the union of foreground labels. |
| 312 | default is `True`. |
| 313 | connectivity: Maximum number of orthogonal hops to consider a pixel/voxel as a neighbor. |
| 314 | Accepted values are ranging from 1 to input.ndim. If ``None``, a full |
| 315 | connectivity of ``input.ndim`` is used. for more details: |
| 316 | https://scikit-image.org/docs/dev/api/skimage.measure.html#skimage.measure.label. |
| 317 | num_components: The number of largest components to preserve. |
| 318 | |
| 319 | """ |
| 320 | super().__init__() |
| 321 | self.applied_labels = ensure_tuple(applied_labels) if applied_labels is not None else None |
| 322 | self.is_onehot = is_onehot |
| 323 | self.independent = independent |
| 324 | self.connectivity = connectivity |
| 325 | self.num_components = num_components |
| 326 | |
| 327 | def __call__(self, img: NdarrayOrTensor) -> NdarrayOrTensor: |
| 328 | """ |
nothing calls this directly
no test coverage detected