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

Method __call__

monai/transforms/croppad/array.py:549–555  ·  view source on GitHub ↗
(self, img: torch.Tensor, lazy: bool | None = None)

Source from the content-addressed store, hash-verified

547 self.roi_scale = roi_scale
548
549 def __call__(self, img: torch.Tensor, lazy: bool | None = None) -> torch.Tensor: # type: ignore[override]
550 img_size = img.peek_pending_shape() if isinstance(img, MetaTensor) else img.shape[1:]
551 ndim = len(img_size)
552 roi_size = [ceil(r * s) for r, s in zip(ensure_tuple_rep(self.roi_scale, ndim), img_size)]
553 lazy_ = self.lazy if lazy is None else lazy
554 cropper = CenterSpatialCrop(roi_size=roi_size, lazy=lazy_)
555 return super().__call__(img=img, slices=cropper.compute_slices(img_size), lazy=lazy_)
556
557
558class RandSpatialCrop(Randomizable, Crop):

Callers

nothing calls this directly

Calls 5

compute_slicesMethod · 0.95
ensure_tuple_repFunction · 0.90
CenterSpatialCropClass · 0.85
peek_pending_shapeMethod · 0.80
__call__Method · 0.45

Tested by

no test coverage detected