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

Method __call__

monai/transforms/utility/array.py:1519–1531  ·  view source on GitHub ↗

Args: img: data to be transformed, assuming `img` is channel first.

(self, img: NdarrayOrTensor)

Source from the content-addressed store, hash-verified

1517 self.spatial_dims = spatial_dims
1518
1519 def __call__(self, img: NdarrayOrTensor) -> NdarrayOrTensor:
1520 """
1521 Args:
1522 img: data to be transformed, assuming `img` is channel first.
1523 """
1524 if max(self.spatial_dims) > img.ndim - 2 or min(self.spatial_dims) < 0:
1525 raise ValueError(f"`spatial_dims` values must be within [0, {img.ndim - 2}]")
1526
1527 spatial_size = img.shape[1:]
1528 coord_channels = np.array(np.meshgrid(*tuple(np.linspace(-0.5, 0.5, s) for s in spatial_size), indexing="ij"))
1529 coord_channels, *_ = convert_to_dst_type(coord_channels, img) # type: ignore
1530 coord_channels = coord_channels[list(self.spatial_dims)]
1531 return concatenate((img, coord_channels), axis=0)
1532
1533
1534class ImageFilter(Transform):

Callers

nothing calls this directly

Calls 5

convert_to_dst_typeFunction · 0.90
concatenateFunction · 0.90
maxFunction · 0.85
minFunction · 0.85
arrayMethod · 0.80

Tested by

no test coverage detected