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

Method __init__

monai/transforms/croppad/array.py:811–854  ·  view source on GitHub ↗

Args: select_fn: function to select expected foreground, default is to select values > 0. channel_indices: if defined, select foreground only on the specified channels of image. if None, select foreground on the whole image. margin: add ma

(
        self,
        select_fn: Callable = is_positive,
        channel_indices: IndexSelection | None = None,
        margin: Sequence[int] | int = 0,
        allow_smaller: bool = False,
        return_coords: bool = False,
        k_divisible: Sequence[int] | int = 1,
        mode: str = PytorchPadMode.CONSTANT,
        lazy: bool = False,
        **pad_kwargs,
    )

Source from the content-addressed store, hash-verified

809 """
810
811 def __init__(
812 self,
813 select_fn: Callable = is_positive,
814 channel_indices: IndexSelection | None = None,
815 margin: Sequence[int] | int = 0,
816 allow_smaller: bool = False,
817 return_coords: bool = False,
818 k_divisible: Sequence[int] | int = 1,
819 mode: str = PytorchPadMode.CONSTANT,
820 lazy: bool = False,
821 **pad_kwargs,
822 ) -> None:
823 """
824 Args:
825 select_fn: function to select expected foreground, default is to select values > 0.
826 channel_indices: if defined, select foreground only on the specified channels
827 of image. if None, select foreground on the whole image.
828 margin: add margin value to spatial dims of the bounding box, if only 1 value provided, use it for all dims.
829 allow_smaller: when computing box size with `margin`, whether to allow the image edges to be smaller than the
830 final box edges. If `False`, part of a padded output box might be outside of the original image, if `True`,
831 the image edges will be used as the box edges. Default to `False`.
832 The default value is changed from `True` to `False` in v1.5.0.
833 return_coords: whether return the coordinates of spatial bounding box for foreground.
834 k_divisible: make each spatial dimension to be divisible by k, default to 1.
835 if `k_divisible` is an int, the same `k` be applied to all the input spatial dimensions.
836 mode: available modes for numpy array:{``"constant"``, ``"edge"``, ``"linear_ramp"``, ``"maximum"``,
837 ``"mean"``, ``"median"``, ``"minimum"``, ``"reflect"``, ``"symmetric"``, ``"wrap"``, ``"empty"``}
838 available modes for PyTorch Tensor: {``"constant"``, ``"reflect"``, ``"replicate"``, ``"circular"``}.
839 One of the listed string values or a user supplied function. Defaults to ``"constant"``.
840 See also: https://numpy.org/doc/1.18/reference/generated/numpy.pad.html
841 https://pytorch.org/docs/stable/generated/torch.nn.functional.pad.html
842 lazy: a flag to indicate whether this transform should execute lazily or not. Defaults to False.
843 pad_kwargs: other arguments for the `np.pad` or `torch.pad` function.
844 note that `np.pad` treats channel dimension as the first dimension.
845
846 """
847 LazyTransform.__init__(self, lazy)
848 self.select_fn = select_fn
849 self.channel_indices = ensure_tuple(channel_indices) if channel_indices is not None else None
850 self.margin = margin
851 self.allow_smaller = allow_smaller
852 self.return_coords = return_coords
853 self.k_divisible = k_divisible
854 self.padder = Pad(mode=mode, lazy=lazy, **pad_kwargs)
855
856 @Crop.lazy.setter # type: ignore
857 def lazy(self, _val: bool):

Callers

nothing calls this directly

Calls 3

ensure_tupleFunction · 0.90
PadClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected