MCPcopy Index your code
hub / github.com/Project-MONAI/MONAI / __call__

Method __call__

monai/transforms/spatial/array.py:1103–1153  ·  view source on GitHub ↗

Args: img: channel first array, must have shape: (num_channels, H[, W, ..., ]). mode: {``"nearest"``, ``"nearest-exact"``, ``"linear"``, ``"bilinear"``, ``"bicubic"``, ``"trilinear"``, ``"area"``} The interpolation mode. Defaults to ``

(
        self,
        img: torch.Tensor,
        mode: str | None = None,
        padding_mode: str | None = None,
        align_corners: bool | None = None,
        dtype: DtypeLike | torch.dtype = None,
        lazy: bool | None = None,
    )

Source from the content-addressed store, hash-verified

1101 self.kwargs = kwargs
1102
1103 def __call__(
1104 self,
1105 img: torch.Tensor,
1106 mode: str | None = None,
1107 padding_mode: str | None = None,
1108 align_corners: bool | None = None,
1109 dtype: DtypeLike | torch.dtype = None,
1110 lazy: bool | None = None,
1111 ) -> torch.Tensor:
1112 """
1113 Args:
1114 img: channel first array, must have shape: (num_channels, H[, W, ..., ]).
1115 mode: {``"nearest"``, ``"nearest-exact"``, ``"linear"``,
1116 ``"bilinear"``, ``"bicubic"``, ``"trilinear"``, ``"area"``}
1117 The interpolation mode. Defaults to ``self.mode``.
1118 See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html
1119 padding_mode: available modes for numpy array:{``"constant"``, ``"edge"``, ``"linear_ramp"``, ``"maximum"``,
1120 ``"mean"``, ``"median"``, ``"minimum"``, ``"reflect"``, ``"symmetric"``, ``"wrap"``, ``"empty"``}
1121 available modes for PyTorch Tensor: {``"constant"``, ``"reflect"``, ``"replicate"``, ``"circular"``}.
1122 One of the listed string values or a user supplied function. Defaults to ``"edge"``.
1123 The mode to pad data after zooming.
1124 See also: https://numpy.org/doc/1.18/reference/generated/numpy.pad.html
1125 https://pytorch.org/docs/stable/generated/torch.nn.functional.pad.html
1126 align_corners: This only has an effect when mode is
1127 'linear', 'bilinear', 'bicubic' or 'trilinear'. Defaults to ``self.align_corners``.
1128 See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html
1129 dtype: data type for resampling computation. Defaults to ``self.dtype``.
1130 If None, use the data type of input data.
1131 lazy: a flag to indicate whether this transform should execute lazily or not
1132 during this call. Setting this to False or True overrides the ``lazy`` flag set
1133 during initialization for this call. Defaults to None.
1134 """
1135 img = convert_to_tensor(img, track_meta=get_track_meta())
1136 _zoom = ensure_tuple_rep(self.zoom, img.ndim - 1) # match the spatial image dim
1137 _mode = self.mode if mode is None else mode
1138 _padding_mode = padding_mode or self.padding_mode
1139 _align_corners = self.align_corners if align_corners is None else align_corners
1140 _dtype = get_equivalent_dtype(dtype or self.dtype or img.dtype, torch.Tensor)
1141 lazy_ = self.lazy if lazy is None else lazy
1142 return zoom( # type: ignore
1143 img,
1144 _zoom,
1145 self.keep_size,
1146 _mode,
1147 _padding_mode,
1148 _align_corners,
1149 _dtype,
1150 lazy=lazy_,
1151 transform_info=self.get_transform_info(),
1152 **self.kwargs,
1153 )
1154
1155 def inverse(self, data: torch.Tensor) -> torch.Tensor:
1156 transform = self.pop_transform(data)

Callers

nothing calls this directly

Calls 6

convert_to_tensorFunction · 0.90
get_track_metaFunction · 0.90
ensure_tuple_repFunction · 0.90
get_equivalent_dtypeFunction · 0.90
zoomFunction · 0.90
get_transform_infoMethod · 0.80

Tested by

no test coverage detected