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

Method _stdshift

monai/transforms/intensity/array.py:355–369  ·  view source on GitHub ↗
(self, img: NdarrayOrTensor)

Source from the content-addressed store, hash-verified

353 self.dtype = dtype
354
355 def _stdshift(self, img: NdarrayOrTensor) -> NdarrayOrTensor:
356 ones: Callable
357 std: Callable
358 if isinstance(img, torch.Tensor):
359 ones = torch.ones
360 std = partial(torch.std, unbiased=False)
361 else:
362 ones = np.ones
363 std = np.std
364
365 slices = (img != 0) if self.nonzero else ones(img.shape, dtype=bool)
366 if slices.any():
367 offset = self.factor * std(img[slices])
368 img[slices] = img[slices] + offset
369 return img
370
371 def __call__(self, img: NdarrayOrTensor) -> NdarrayOrTensor:
372 """

Callers 1

__call__Method · 0.95

Calls 1

stdFunction · 0.85

Tested by

no test coverage detected