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

Method __call__

monai/transforms/croppad/array.py:928–941  ·  view source on GitHub ↗

Apply the transform to `img`, assuming `img` is channel-first and slicing doesn't change the channel dim.

(  # type: ignore[override]
        self, img: torch.Tensor, mode: str | None = None, lazy: bool | None = None, **pad_kwargs
    )

Source from the content-addressed store, hash-verified

926 return ret
927
928 def __call__( # type: ignore[override]
929 self, img: torch.Tensor, mode: str | None = None, lazy: bool | None = None, **pad_kwargs
930 ) -> torch.Tensor:
931 """
932 Apply the transform to `img`, assuming `img` is channel-first and
933 slicing doesn't change the channel dim.
934 """
935 box_start, box_end = self.compute_bounding_box(img)
936 lazy_ = self.lazy if lazy is None else lazy
937 cropped = self.crop_pad(img, box_start, box_end, mode, lazy=lazy_, **pad_kwargs)
938
939 if self.return_coords:
940 return cropped, box_start, box_end # type: ignore[return-value]
941 return cropped
942
943 def inverse(self, img: MetaTensor) -> MetaTensor:
944 transform = self.get_most_recent_transform(img)

Callers

nothing calls this directly

Calls 2

compute_bounding_boxMethod · 0.95
crop_padMethod · 0.95

Tested by

no test coverage detected