Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix casting of location dtype in GridPatch #4635

Merged
merged 8 commits into from
Jul 6, 2022
10 changes: 9 additions & 1 deletion monai/transforms/spatial/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -3128,8 +3128,16 @@ def __call__(self, array: NdarrayOrTensor):
patched_image, locations = self.filter_threshold(patched_image, locations)

# Convert to original data type
# Locations data type should differ from array data type
if isinstance(array, torch.Tensor):
location_dtype = torch.int
elif isinstance(array, np.ndarray):
location_dtype = np.int
else:
location_dtype = None
output = list(
zip(convert_to_dst_type(src=patched_image, dst=array)[0], convert_to_dst_type(src=locations, dst=array)[0])
zip(convert_to_dst_type(src=patched_image, dst=array)[0],
convert_to_dst_type(src=locations, dst=array, dtype=location_dtype)[0])
vale-salvatelli marked this conversation as resolved.
Show resolved Hide resolved
)

# Pad the patch list to have the requested number of patches
Expand Down