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

Method __call__

monai/transforms/spatial/dictionary.py:1682–1712  ·  view source on GitHub ↗

Args: data: a dictionary containing the tensor-like data to be processed. The ``keys`` specified in this dictionary must be tensor like arrays that are channel first and have at most three spatial dimensions lazy: a flag to indicate wh

(self, data: Mapping[Hashable, torch.Tensor], lazy: bool | None = None)

Source from the content-addressed store, hash-verified

1680 return self
1681
1682 def __call__(self, data: Mapping[Hashable, torch.Tensor], lazy: bool | None = None) -> dict[Hashable, torch.Tensor]:
1683 """
1684 Args:
1685 data: a dictionary containing the tensor-like data to be processed. The ``keys`` specified
1686 in this dictionary must be tensor like arrays that are channel first and have at most
1687 three spatial dimensions
1688 lazy: a flag to indicate whether this transform should execute lazily or not
1689 during this call. Setting this to False or True overrides the ``lazy`` flag set
1690 during initialization for this call. Defaults to None.
1691
1692 Returns:
1693 a dictionary containing the transformed data, as well as any other data present in the dictionary
1694 """
1695 d = dict(data)
1696 first_key: Hashable = self.first_key(d)
1697 if first_key == ():
1698 return d
1699
1700 self.randomize(None)
1701
1702 # all the keys share the same random selected axis
1703 self.flipper.randomize(d[first_key])
1704
1705 lazy_ = self.lazy if lazy is None else lazy
1706 for key in self.key_iterator(d):
1707 if self._do_transform:
1708 d[key] = self.flipper(d[key], randomize=False, lazy=lazy_)
1709 else:
1710 d[key] = convert_to_tensor(d[key], track_meta=get_track_meta())
1711 self.push_transform(d[key], replace=True, lazy=lazy_)
1712 return d
1713
1714 def inverse(self, data: Mapping[Hashable, torch.Tensor]) -> dict[Hashable, torch.Tensor]:
1715 d = dict(data)

Callers

nothing calls this directly

Calls 6

convert_to_tensorFunction · 0.90
get_track_metaFunction · 0.90
first_keyMethod · 0.80
key_iteratorMethod · 0.80
push_transformMethod · 0.80
randomizeMethod · 0.45

Tested by

no test coverage detected