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

Method __init__

monai/transforms/post/array.py:934–958  ·  view source on GitHub ↗
(
        self,
        spatial_dims: int = 2,
        sigma: Sequence[float] | float | Sequence[torch.Tensor] | torch.Tensor = 0.0,
        prob_threshold: float = 0.5,
        box_size: int | Sequence[int] = 48,
    )

Source from the content-addressed store, hash-verified

932 backend = [TransformBackends.NUMPY]
933
934 def __init__(
935 self,
936 spatial_dims: int = 2,
937 sigma: Sequence[float] | float | Sequence[torch.Tensor] | torch.Tensor = 0.0,
938 prob_threshold: float = 0.5,
939 box_size: int | Sequence[int] = 48,
940 ) -> None:
941 self.sigma = sigma
942 self.spatial_dims = spatial_dims
943 if self.sigma != 0:
944 self.filter = GaussianFilter(spatial_dims=spatial_dims, sigma=sigma)
945 if prob_threshold < 0:
946 raise ValueError("prob_threshold should be no less than 0.0.")
947 self.prob_threshold = prob_threshold
948 if isinstance(box_size, int):
949 self.box_size = np.asarray([box_size] * spatial_dims)
950 elif len(box_size) != spatial_dims:
951 raise ValueError("the sequence length of box_size should be the same as spatial_dims.")
952 else:
953 self.box_size = np.asarray(box_size)
954 if self.box_size.min() <= 0:
955 raise ValueError("box_size should be larger than 0.")
956
957 self.box_lower_bd = self.box_size // 2
958 self.box_upper_bd = self.box_size - self.box_lower_bd
959
960 def __call__(self, prob_map: NdarrayOrTensor):
961 """

Callers

nothing calls this directly

Calls 1

GaussianFilterClass · 0.90

Tested by

no test coverage detected