Apply the transform to `img`, assuming `img` is channel-first and slicing doesn't apply to the channel dim.
( # type: ignore[override]
self, img: torch.Tensor, slices: tuple[slice, ...], lazy: bool | None = None
)
| 406 | return ensure_tuple([slice(int(s), int(e)) for s, e in zip(roi_start_t.tolist(), roi_end_t.tolist())]) |
| 407 | |
| 408 | def __call__( # type: ignore[override] |
| 409 | self, img: torch.Tensor, slices: tuple[slice, ...], lazy: bool | None = None |
| 410 | ) -> torch.Tensor: |
| 411 | """ |
| 412 | Apply the transform to `img`, assuming `img` is channel-first and |
| 413 | slicing doesn't apply to the channel dim. |
| 414 | |
| 415 | """ |
| 416 | slices_ = list(slices) |
| 417 | sd = len(img.peek_pending_shape() if isinstance(img, MetaTensor) else img.shape[1:]) # spatial dims |
| 418 | if len(slices_) < sd: |
| 419 | slices_ += [slice(None)] * (sd - len(slices_)) |
| 420 | # Add in the channel (no cropping) |
| 421 | slices_ = list([slice(None)] + slices_[:sd]) |
| 422 | |
| 423 | img_t: MetaTensor = convert_to_tensor(data=img, track_meta=get_track_meta()) |
| 424 | lazy_ = self.lazy if lazy is None else lazy |
| 425 | return crop_func(img_t, tuple(slices_), lazy_, self.get_transform_info()) |
| 426 | |
| 427 | def inverse(self, img: MetaTensor) -> MetaTensor: |
| 428 | transform = self.pop_transform(img) |
nothing calls this directly
no test coverage detected