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

Method randomize

monai/transforms/spatial/array.py:1630–1640  ·  view source on GitHub ↗
(self, img: NdarrayOrTensor)

Source from the content-addressed store, hash-verified

1628 self._zoom: Sequence[float] = [1.0]
1629
1630 def randomize(self, img: NdarrayOrTensor) -> None:
1631 super().randomize(None)
1632 if not self._do_transform:
1633 return None
1634 self._zoom = [self.R.uniform(l, h) for l, h in zip(self.min_zoom, self.max_zoom)]
1635 if len(self._zoom) == 1:
1636 # to keep the spatial shape ratio, use same random zoom factor for all dims
1637 self._zoom = ensure_tuple_rep(self._zoom[0], img.ndim - 1)
1638 elif len(self._zoom) == 2 and img.ndim > 3:
1639 # if 2 zoom factors provided for 3D data, use the first factor for H and W dims, second factor for D dim
1640 self._zoom = ensure_tuple_rep(self._zoom[0], img.ndim - 2) + ensure_tuple(self._zoom[-1])
1641
1642 def __call__(
1643 self,

Callers 15

__call__Method · 0.95
__call__Method · 0.45
__call__Method · 0.45
__call__Method · 0.45
__call__Method · 0.45
__call__Method · 0.45
__call__Method · 0.45
__call__Method · 0.45
__call__Method · 0.45
randomizeMethod · 0.45
randomizeMethod · 0.45
__call__Method · 0.45

Calls 2

ensure_tuple_repFunction · 0.90
ensure_tupleFunction · 0.90

Tested by

no test coverage detected