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

Method __init__

monai/transforms/intensity/array.py:392–420  ·  view source on GitHub ↗

Args: factors: if tuple, the randomly picked range is (min(factors), max(factors)). If single number, the range is (-factors, factors). prob: probability of std shift. nonzero: whether only count non-zero values. channel_wise:

(
        self,
        factors: tuple[float, float] | float,
        prob: float = 0.1,
        nonzero: bool = False,
        channel_wise: bool = False,
        dtype: DtypeLike = np.float32,
    )

Source from the content-addressed store, hash-verified

390 backend = [TransformBackends.TORCH, TransformBackends.NUMPY]
391
392 def __init__(
393 self,
394 factors: tuple[float, float] | float,
395 prob: float = 0.1,
396 nonzero: bool = False,
397 channel_wise: bool = False,
398 dtype: DtypeLike = np.float32,
399 ) -> None:
400 """
401 Args:
402 factors: if tuple, the randomly picked range is (min(factors), max(factors)).
403 If single number, the range is (-factors, factors).
404 prob: probability of std shift.
405 nonzero: whether only count non-zero values.
406 channel_wise: if True, calculate on each channel separately.
407 dtype: output data type, if None, same as input image. defaults to float32.
408
409 """
410 RandomizableTransform.__init__(self, prob)
411 if isinstance(factors, (int, float)):
412 self.factors = (min(-factors, factors), max(-factors, factors))
413 elif len(factors) != 2:
414 raise ValueError(f"factors should be a number or pair of numbers, got {factors}.")
415 else:
416 self.factors = (min(factors), max(factors))
417 self.factor = self.factors[0]
418 self.nonzero = nonzero
419 self.channel_wise = channel_wise
420 self.dtype = dtype
421
422 def randomize(self, data: Any | None = None) -> None:
423 super().randomize(None)

Callers

nothing calls this directly

Calls 3

minFunction · 0.85
maxFunction · 0.85
__init__Method · 0.45

Tested by

no test coverage detected