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

Class DivisiblePadd

monai/transforms/croppad/dictionary.py:280–326  ·  view source on GitHub ↗

Pad the input data, so that the spatial sizes are divisible by `k`. Dictionary-based wrapper of :py:class:`monai.transforms.DivisiblePad`. This transform is capable of lazy execution. See the :ref:`Lazy Resampling topic ` for more information.

Source from the content-addressed store, hash-verified

278
279
280class DivisiblePadd(Padd):
281 """
282 Pad the input data, so that the spatial sizes are divisible by `k`.
283 Dictionary-based wrapper of :py:class:`monai.transforms.DivisiblePad`.
284
285 This transform is capable of lazy execution. See the :ref:`Lazy Resampling topic<lazy_resampling>`
286 for more information.
287 """
288
289 backend = DivisiblePad.backend
290
291 def __init__(
292 self,
293 keys: KeysCollection,
294 k: Sequence[int] | int,
295 mode: SequenceStr = PytorchPadMode.CONSTANT,
296 method: str = Method.SYMMETRIC,
297 allow_missing_keys: bool = False,
298 lazy: bool = False,
299 **kwargs,
300 ) -> None:
301 """
302 Args:
303 keys: keys of the corresponding items to be transformed.
304 See also: :py:class:`monai.transforms.compose.MapTransform`
305 k: the target k for each spatial dimension.
306 if `k` is negative or 0, the original size is preserved.
307 if `k` is an int, the same `k` be applied to all the input spatial dimensions.
308 mode: available modes for numpy array:{``"constant"``, ``"edge"``, ``"linear_ramp"``, ``"maximum"``,
309 ``"mean"``, ``"median"``, ``"minimum"``, ``"reflect"``, ``"symmetric"``, ``"wrap"``, ``"empty"``}
310 available modes for PyTorch Tensor: {``"constant"``, ``"reflect"``, ``"replicate"``, ``"circular"``}.
311 One of the listed string values or a user supplied function. Defaults to ``"constant"``.
312 See also: https://numpy.org/doc/1.18/reference/generated/numpy.pad.html
313 https://pytorch.org/docs/stable/generated/torch.nn.functional.pad.html
314 It also can be a sequence of string, each element corresponds to a key in ``keys``.
315 method: {``"symmetric"``, ``"end"``}
316 Pad image symmetrically on every side or only pad at the end sides. Defaults to ``"symmetric"``.
317 allow_missing_keys: don&#x27;t raise exception if key is missing.
318 lazy: a flag to indicate whether this transform should execute lazily or not. Defaults to False.
319 kwargs: other arguments for the `np.pad` or `torch.pad` function.
320 note that `np.pad` treats channel dimension as the first dimension.
321
322 See also :py:class:`monai.transforms.SpatialPad`
323
324 """
325 padder = DivisiblePad(k=k, method=method, lazy=lazy, **kwargs)
326 Padd.__init__(self, keys, padder=padder, mode=mode, allow_missing_keys=allow_missing_keys, lazy=lazy)
327
328
329class Cropd(MapTransform, InvertibleTransform, LazyTransform):

Callers 5

test_transformsMethod · 0.90
test_deep_copyMethod · 0.90
test_inverse.pyFile · 0.90

Calls

no outgoing calls

Tested by 4

test_transformsMethod · 0.72
test_deep_copyMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…