Skip to content

Commit

Permalink
Fix the location type returned in GridPatch when padding (#4598)
Browse files Browse the repository at this point in the history
* Fix the location type returned in GridPatch when padding

This PR fixes this issue #4597

* signing and fixing docstring

Signed-off-by: Valentina Salvatelli <[email protected]>
  • Loading branch information
vale-salvatelli authored Jun 29, 2022
1 parent 91ec2b5 commit 112d36c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion monai/transforms/spatial/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -2668,6 +2668,7 @@ class GridPatch(Transform):
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.
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"`),
Expand Down Expand Up @@ -2770,7 +2771,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
Expand Down

0 comments on commit 112d36c

Please sign in to comment.