-
Notifications
You must be signed in to change notification settings - Fork 1.5k
RandZoomd align_corners incorrect #3983
Description
align_corners is handled incorrectly in RandZoomd (and possibly bugs in other transforms)
Example:
RandZoomd(keys=['image'], prob=0.5, min_zoom=0.9, max_zoom=1.1, mode=['trilinear'], align_corners=[False])
Will call Zoom transforms with mode = trilinear, but align_corners=None. Which will also show a lot of pytorch Warnings indicating that align_corners is not set.
Root cause:
MONAI/monai/transforms/spatial/array.py
Line 1279 in 42159ff
| return Zoom( |
when calling Zoom transform, for some reason we use parameters as
mode=look_up_option(mode or self.mode, InterpolateMode),
align_corners=align_corners or self.align_corners,
The use of 'or' is very ambiguous and leads to a bug in this case.
A or B -> returns A (if both A and B are strings or enums)
A or B -> returns B (if either A==None or B==None)
In our case
mode or self.mode -> returns mode
align_corners or self.align_corners -> returns self.align_corners (because align_corners==None)
as a result we get mode='trilinear', align_corners=None (the original option is lost)
We use this 'or' throughout the code for align_corners, and other parameters, which potentially created bugs if one of the options is None...