From b1bb6761b7778cb9bea4d8d9cd3e5c593da3f7cd Mon Sep 17 00:00:00 2001 From: vale-salvatelli Date: Mon, 27 Jun 2022 19:01:09 +0100 Subject: [PATCH 1/3] Fix the location type returned in GridPatch when padding This PR fixes this issue https://github.com/Project-MONAI/MONAI/issues/4597 --- monai/transforms/spatial/array.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monai/transforms/spatial/array.py b/monai/transforms/spatial/array.py index 05ee474590..1023806f21 100644 --- a/monai/transforms/spatial/array.py +++ b/monai/transforms/spatial/array.py @@ -2770,7 +2770,7 @@ def __call__(self, array: NdarrayOrTensor): patch = convert_to_dst_type( src=np.full((array.shape[0], *self.patch_size), self.pad_kwargs.get("constant_values", 0)), dst=array )[0] - start_location = convert_to_dst_type(src=np.zeros((len(self.patch_size), 1)), dst=array)[0] + start_location = convert_to_dst_type(src=np.zeros(len(self.patch_size)), dst=array)[0] output += [(patch, start_location)] * (self.num_patches - len(output)) return output From 7e9a9e876e2dfb8c6214b4e8e60604545b8d9830 Mon Sep 17 00:00:00 2001 From: Valentina Salvatelli Date: Wed, 29 Jun 2022 10:52:31 +0100 Subject: [PATCH 2/3] signing and fixing docstring Signed-off-by: Valentina Salvatelli --- monai/transforms/spatial/array.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/monai/transforms/spatial/array.py b/monai/transforms/spatial/array.py index 1023806f21..140973d26d 100644 --- a/monai/transforms/spatial/array.py +++ b/monai/transforms/spatial/array.py @@ -2667,7 +2667,8 @@ class GridPatch(Transform): Args: patch_size: size of patches to generate slices for, 0 or None selects whole dimension offset: offset of starting position in the array, default is 0 for each dimension. - num_patches: number of patches to return. Defaults to None, which returns all the available patches. + num_patches: number of patches to return. Defaults to None, which returns all the available patches. + If the required patches are more than the available patches, padding will be applied. overlap: the amount of overlap of neighboring patches in each dimension (a value between 0.0 and 1.0). If only one float number is given, it will be applied to all dimensions. Defaults to 0.0. sort_fn: when `num_patches` is provided, it determines if keep patches with highest values (`"max"`), From 2a9dc1e83b4aade38fb2662dc0e4aedcedbbc95a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 29 Jun 2022 09:53:50 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- monai/transforms/spatial/array.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monai/transforms/spatial/array.py b/monai/transforms/spatial/array.py index 140973d26d..83792d49a7 100644 --- a/monai/transforms/spatial/array.py +++ b/monai/transforms/spatial/array.py @@ -2667,7 +2667,7 @@ class GridPatch(Transform): Args: patch_size: size of patches to generate slices for, 0 or None selects whole dimension offset: offset of starting position in the array, default is 0 for each dimension. - num_patches: number of patches to return. Defaults to None, which returns all the available patches. + num_patches: number of patches to return. Defaults to None, which returns all the available patches. If the required patches are more than the available patches, padding will be applied. overlap: the amount of overlap of neighboring patches in each dimension (a value between 0.0 and 1.0). If only one float number is given, it will be applied to all dimensions. Defaults to 0.0.