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

Method inverse

monai/transforms/spatial/array.py:241–256  ·  view source on GitHub ↗
(self, data: torch.Tensor)

Source from the content-addressed store, hash-verified

239 )
240
241 def inverse(self, data: torch.Tensor) -> torch.Tensor:
242 transform = self.pop_transform(data)
243 # Create inverse transform
244 kw_args = transform[TraceKeys.EXTRA_INFO]
245 # need to convert dtype from string back to torch.dtype
246 kw_args["dtype"] = get_torch_dtype_from_string(kw_args["dtype"])
247 # source becomes destination
248 kw_args["dst_affine"] = kw_args.pop("src_affine")
249 kw_args["spatial_size"] = transform[TraceKeys.ORIG_SIZE]
250 if kw_args.get("align_corners") == TraceKeys.NONE:
251 kw_args["align_corners"] = False
252 with self.trace_transform(False):
253 # we can't use `self.__call__` in case a child class calls this inverse.
254 out: torch.Tensor = SpatialResample.__call__(self, data, **kw_args)
255 kw_args["src_affine"] = kw_args.get("dst_affine")
256 return out
257
258
259class ResampleToMatch(SpatialResample):

Callers 1

test_inverseMethod · 0.95

Calls 6

pop_transformMethod · 0.80
popMethod · 0.80
getMethod · 0.80
trace_transformMethod · 0.45
__call__Method · 0.45

Tested by 1

test_inverseMethod · 0.76