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

Method __call__

monai/transforms/intensity/array.py:723–743  ·  view source on GitHub ↗

Apply the transform to `img`.

(self, img: NdarrayOrTensor, randomize: bool = True)

Source from the content-addressed store, hash-verified

721 self.factor = self.R.uniform(low=self.factors[0], high=self.factors[1])
722
723 def __call__(self, img: NdarrayOrTensor, randomize: bool = True) -> NdarrayOrTensor:
724 """
725 Apply the transform to `img`.
726 """
727 img = convert_to_tensor(img, track_meta=get_track_meta())
728 if randomize:
729 self.randomize(img)
730
731 if not self._do_transform:
732 return convert_data_type(img, dtype=self.dtype)[0]
733
734 ret: NdarrayOrTensor
735 if self.channel_wise:
736 out = []
737 for i, d in enumerate(img):
738 out_channel = ScaleIntensity(minv=None, maxv=None, factor=self.factor[i], dtype=self.dtype)(d) # type: ignore
739 out.append(out_channel)
740 ret = torch.stack(out) # type: ignore
741 else:
742 ret = ScaleIntensity(minv=None, maxv=None, factor=self.factor, dtype=self.dtype)(img)
743 return ret
744
745
746class RandBiasField(RandomizableTransform):

Callers

nothing calls this directly

Calls 6

randomizeMethod · 0.95
convert_to_tensorFunction · 0.90
get_track_metaFunction · 0.90
convert_data_typeFunction · 0.90
ScaleIntensityClass · 0.85
appendMethod · 0.45

Tested by

no test coverage detected