Args: transform: the previously applied transform. nearest_interp: whether to use `nearest` interpolation mode when inverting the spatial transforms, default to `True`. If `False`, use the same interpolation mode as the original transform.
(
self,
transform: InvertibleTransform | None = None,
nearest_interp: bool | Sequence[bool] = True,
device: str | torch.device | None = None,
post_func: Callable | None = None,
to_tensor: bool | Sequence[bool] = True,
)
| 994 | backend = [TransformBackends.TORCH] |
| 995 | |
| 996 | def __init__( |
| 997 | self, |
| 998 | transform: InvertibleTransform | None = None, |
| 999 | nearest_interp: bool | Sequence[bool] = True, |
| 1000 | device: str | torch.device | None = None, |
| 1001 | post_func: Callable | None = None, |
| 1002 | to_tensor: bool | Sequence[bool] = True, |
| 1003 | ) -> None: |
| 1004 | """ |
| 1005 | Args: |
| 1006 | transform: the previously applied transform. |
| 1007 | nearest_interp: whether to use `nearest` interpolation mode when inverting the spatial transforms, |
| 1008 | default to `True`. If `False`, use the same interpolation mode as the original transform. |
| 1009 | device: move the inverted results to a target device before `post_func`, default to `None`. |
| 1010 | post_func: postprocessing for the inverted result, should be a callable function. |
| 1011 | to_tensor: whether to convert the inverted data into PyTorch Tensor first, default to `True`. |
| 1012 | """ |
| 1013 | if not isinstance(transform, InvertibleTransform): |
| 1014 | raise ValueError("transform is not invertible, can't invert transform for the data.") |
| 1015 | self.transform = transform |
| 1016 | self.nearest_interp = nearest_interp |
| 1017 | self.device = device |
| 1018 | self.post_func = post_func |
| 1019 | self.to_tensor = to_tensor |
| 1020 | self._totensor = ToTensor() |
| 1021 | |
| 1022 | def __call__(self, data): |
| 1023 | if not isinstance(data, MetaTensor): |