| 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, |