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

Method __call__

monai/transforms/transform.py:442–466  ·  view source on GitHub ↗

``data`` often comes from an iteration over an iterable, such as :py:class:`torch.utils.data.Dataset`. To simplify the input validations, this method assumes: - ``data`` is a Python dictionary, - ``data[key]`` is a Numpy ndarray, PyTorch Tensor or string, w

(self, data)

Source from the content-addressed store, hash-verified

440
441 @abstractmethod
442 def __call__(self, data):
443 """
444 ``data`` often comes from an iteration over an iterable,
445 such as :py:class:`torch.utils.data.Dataset`.
446
447 To simplify the input validations, this method assumes:
448
449 - ``data`` is a Python dictionary,
450 - ``data[key]`` is a Numpy ndarray, PyTorch Tensor or string, where ``key`` is an element
451 of ``self.keys``, the data shape can be:
452
453 #. string data without shape, `LoadImaged` transform expects file paths,
454 #. most of the pre-/post-processing transforms expect: ``(num_channels, spatial_dim_1[, spatial_dim_2, ...])``,
455 except for example: `AddChanneld` expects (spatial_dim_1[, spatial_dim_2, ...])
456
457 - the channel dimension is often not omitted even if number of channels is one.
458
459 Raises:
460 NotImplementedError: When the subclass does not override this method.
461
462 returns:
463 An updated dictionary version of ``data`` by applying the transform.
464
465 """
466 raise NotImplementedError(f"Subclass {self.__class__.__name__} must implement this method.")
467
468 def key_iterator(self, data: Mapping[Hashable, Any], *extra_iterables: Iterable | None) -> Generator:
469 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected