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

Method randomize

monai/transforms/intensity/array.py:2373–2385  ·  view source on GitHub ↗
(self, img_size: Sequence[int])

Source from the content-addressed store, hash-verified

2371 self.hole_coords: list = []
2372
2373 def randomize(self, img_size: Sequence[int]) -> None:
2374 super().randomize(None)
2375 if not self._do_transform:
2376 return None
2377 size = fall_back_tuple(self.spatial_size, img_size)
2378 self.hole_coords = [] # clear previously computed coords
2379 num_holes = self.holes if self.max_holes is None else self.R.randint(self.holes, self.max_holes + 1)
2380 for _ in range(num_holes):
2381 if self.max_spatial_size is not None:
2382 max_size = fall_back_tuple(self.max_spatial_size, img_size)
2383 size = tuple(self.R.randint(low=size[i], high=max_size[i] + 1) for i in range(len(img_size)))
2384 valid_size = get_valid_patch_size(img_size, size)
2385 self.hole_coords.append((slice(None),) + get_random_patch(img_size, valid_size, self.R))
2386
2387 @abstractmethod
2388 def _transform_holes(self, img: np.ndarray) -> np.ndarray:

Callers 1

__call__Method · 0.95

Calls 5

fall_back_tupleFunction · 0.90
get_valid_patch_sizeFunction · 0.90
get_random_patchFunction · 0.90
randomizeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected