def __init__(self, keys: KeysCollection, offset: float, allow_missing_keys: bool = False) -> None: """ Args: keys: keys of the corresponding items to be transformed. See also: :py:class:`monai.transforms.compose.MapTransform` offset: offset value to shift the intensity of image. allow_missing_keys: don't raise exception if key is missing. """ super().__init__(keys, allow_missing_keys) self.shifter = ShiftIntensity(offset)
def __call__( self, data: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]: d = dict(data) self.randomize() if not self._do_transform: return d shifter = ShiftIntensity(self._offset) for key in self.keys: d[key] = shifter(d[key]) return d