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

Method __call__

monai/transforms/intensity/array.py:477–497  ·  view source on GitHub ↗

Apply the transform to `img`. Raises: ValueError: When ``self.minv=None`` or ``self.maxv=None`` and ``self.factor=None``. Incompatible values.

(self, img: NdarrayOrTensor)

Source from the content-addressed store, hash-verified

475 self.dtype = dtype
476
477 def __call__(self, img: NdarrayOrTensor) -> NdarrayOrTensor:
478 """
479 Apply the transform to `img`.
480
481 Raises:
482 ValueError: When ``self.minv=None`` or ``self.maxv=None`` and ``self.factor=None``. Incompatible values.
483
484 """
485 img = convert_to_tensor(img, track_meta=get_track_meta())
486 img_t = convert_to_tensor(img, track_meta=False)
487 ret: NdarrayOrTensor
488 if self.minv is not None or self.maxv is not None:
489 if self.channel_wise:
490 out = [rescale_array(d, self.minv, self.maxv, dtype=self.dtype) for d in img_t]
491 ret = torch.stack(out) # type: ignore
492 else:
493 ret = rescale_array(img_t, self.minv, self.maxv, dtype=self.dtype)
494 else:
495 ret = (img_t * (1 + self.factor)) if self.factor is not None else img_t
496 ret = convert_to_dst_type(ret, dst=img, dtype=self.dtype or img_t.dtype)[0]
497 return ret
498
499
500class ScaleIntensityFixedMean(Transform):

Callers

nothing calls this directly

Calls 4

convert_to_tensorFunction · 0.90
get_track_metaFunction · 0.90
rescale_arrayFunction · 0.90
convert_to_dst_typeFunction · 0.90

Tested by

no test coverage detected