diff --git a/monai/transforms/croppad/array.py b/monai/transforms/croppad/array.py index b23fbac7d9..4b18c74b2d 100644 --- a/monai/transforms/croppad/array.py +++ b/monai/transforms/croppad/array.py @@ -965,6 +965,7 @@ class RandWeightedCrop(Randomizable, TraceableTransform, LazyTransform, MultiSam weight_map: weight map used to generate patch samples. The weights must be non-negative. Each element denotes a sampling weight of the spatial location. 0 indicates no sampling. It should be a single-channel array in shape, for example, `(1, spatial_dim_0, spatial_dim_1, ...)`. + The weight map is only used to compute the patch sample locations; it is not cropped itself. lazy: a flag to indicate whether this transform should execute lazily or not. Defaults to False. """ diff --git a/monai/transforms/croppad/dictionary.py b/monai/transforms/croppad/dictionary.py index 510ff72938..7c82fe065b 100644 --- a/monai/transforms/croppad/dictionary.py +++ b/monai/transforms/croppad/dictionary.py @@ -943,7 +943,11 @@ class RandWeightedCropd(Randomizable, MapTransform, LazyTransform, MultiSampleTr keys: keys of the corresponding items to be transformed. See also: :py:class:`monai.transforms.compose.MapTransform` w_key: key for the weight map. The corresponding value will be used as the sampling weights, - it should be a single-channel array in size, for example, `(1, spatial_dim_0, spatial_dim_1, ...)` + it should be a single-channel array with shape, for example, `(1, spatial_dim_0, spatial_dim_1, ...)`. + The weight map is only used to compute the patch sample locations; it is not cropped itself. + To obtain the cropped weight map (e.g. to batch it alongside the image), include ``w_key`` in + ``keys`` so it is cropped with the same sample centers; otherwise it is passed through unchanged + at its original spatial size. spatial_size: the spatial size of the image patch e.g. [224, 224, 128]. If its components have non-positive values, the corresponding size of `img` will be used. num_samples: number of samples (image patches) to take in the returned list.