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

Method __call__

monai/transforms/intensity/array.py:1469–1496  ·  view source on GitHub ↗

Args: mask_data: if mask data is single channel, apply to every channel of input image. if multiple channels, the channel number must match input data. mask_data will be converted to `bool` values by `mask_data > 0` before applying

(self, img: NdarrayOrTensor, mask_data: NdarrayOrTensor | None = None)

Source from the content-addressed store, hash-verified

1467 self.select_fn = select_fn
1468
1469 def __call__(self, img: NdarrayOrTensor, mask_data: NdarrayOrTensor | None = None) -> NdarrayOrTensor:
1470 """
1471 Args:
1472 mask_data: if mask data is single channel, apply to every channel
1473 of input image. if multiple channels, the channel number must
1474 match input data. mask_data will be converted to `bool` values
1475 by `mask_data > 0` before applying transform to input image.
1476
1477 Raises:
1478 - ValueError: When both ``mask_data`` and ``self.mask_data`` are None.
1479 - ValueError: When ``mask_data`` and ``img`` channels differ and ``mask_data`` is not single channel.
1480
1481 """
1482 img = convert_to_tensor(img, track_meta=get_track_meta())
1483 mask_data = self.mask_data if mask_data is None else mask_data
1484 if mask_data is None:
1485 raise ValueError("must provide the mask_data when initializing the transform or at runtime.")
1486
1487 mask_data_, *_ = convert_to_dst_type(src=mask_data, dst=img)
1488
1489 mask_data_ = self.select_fn(mask_data_)
1490 if mask_data_.shape[0] != 1 and mask_data_.shape[0] != img.shape[0]:
1491 raise ValueError(
1492 "When mask_data is not single channel, mask_data channels must match img, "
1493 f"got img channels={img.shape[0]} mask_data channels={mask_data_.shape[0]}."
1494 )
1495
1496 return convert_to_dst_type(img * mask_data_, dst=img)[0]
1497
1498
1499class SavitzkyGolaySmooth(Transform):

Callers

nothing calls this directly

Calls 3

convert_to_tensorFunction · 0.90
get_track_metaFunction · 0.90
convert_to_dst_typeFunction · 0.90

Tested by

no test coverage detected