MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / __call__

Method __call__

monai/transforms/utility/array.py:1113–1144  ·  view source on GitHub ↗

Args: img: the image that we want to add new channel to. label: label image to get extreme points from. Shape must be (1, spatial_dim1, [, spatial_dim2, ...]). Doesn't support one-hot labels. sigma: if a list of values, must match the coun

(
        self,
        img: NdarrayOrTensor,
        label: NdarrayOrTensor | None = None,
        sigma: Sequence[float] | float | Sequence[torch.Tensor] | torch.Tensor = 3.0,
        rescale_min: float = -1.0,
        rescale_max: float = 1.0,
    )

Source from the content-addressed store, hash-verified

1111 self._points = get_extreme_points(label, rand_state=self.R, background=self._background, pert=self._pert)
1112
1113 def __call__(
1114 self,
1115 img: NdarrayOrTensor,
1116 label: NdarrayOrTensor | None = None,
1117 sigma: Sequence[float] | float | Sequence[torch.Tensor] | torch.Tensor = 3.0,
1118 rescale_min: float = -1.0,
1119 rescale_max: float = 1.0,
1120 ) -> NdarrayOrTensor:
1121 """
1122 Args:
1123 img: the image that we want to add new channel to.
1124 label: label image to get extreme points from. Shape must be
1125 (1, spatial_dim1, [, spatial_dim2, ...]). Doesn't support one-hot labels.
1126 sigma: if a list of values, must match the count of spatial dimensions of input data,
1127 and apply every value in the list to 1 spatial dimension. if only 1 value provided,
1128 use it for all spatial dimensions.
1129 rescale_min: minimum value of output data.
1130 rescale_max: maximum value of output data.
1131 """
1132 if label is None:
1133 raise ValueError("This transform requires a label array!")
1134 if label.shape[0] != 1:
1135 raise ValueError("Only supports single channel labels!")
1136
1137 # Generate extreme points
1138 self.randomize(label[0, :])
1139
1140 points_image = extreme_points_to_image(
1141 points=self._points, label=label, sigma=sigma, rescale_min=rescale_min, rescale_max=rescale_max
1142 )
1143 points_image, *_ = convert_to_dst_type(points_image, img) # type: ignore
1144 return concatenate((img, points_image), axis=0)
1145
1146
1147class TorchVision(Transform):

Callers

nothing calls this directly

Calls 4

randomizeMethod · 0.95
extreme_points_to_imageFunction · 0.90
convert_to_dst_typeFunction · 0.90
concatenateFunction · 0.90

Tested by

no test coverage detected