@@ -1431,7 +1431,8 @@ class RandCoarseDropoutd(RandomizableTransform, MapTransform):
1431
1431
if some components of the `spatial_size` are non-positive values, the transform will use the
1432
1432
corresponding components of input img size. For example, `spatial_size=(32, -1)` will be adapted
1433
1433
to `(32, 64)` if the second spatial dimension size of img is `64`.
1434
- fill_value: target value to fill the dropout regions.
1434
+ fill_value: target value to fill the dropout regions, if providing a tuple for the `min` and `max`,
1435
+ will randomly select value for every pixel / voxel from the range `[min, max)`.
1435
1436
max_holes: if not None, define the maximum number to randomly select the expected number of regions.
1436
1437
max_spatial_size: if not None, define the maximum spatial size to randomly select size for every region.
1437
1438
if some components of the `max_spatial_size` are non-positive values, the transform will use the
@@ -1447,7 +1448,7 @@ def __init__(
1447
1448
keys : KeysCollection ,
1448
1449
holes : int ,
1449
1450
spatial_size : Union [Sequence [int ], int ],
1450
- fill_value : Union [float , int ] = 0 ,
1451
+ fill_value : Union [Tuple [ Union [ float , int ]], Union [ float , int ] ] = 0 ,
1451
1452
max_holes : Optional [int ] = None ,
1452
1453
max_spatial_size : Optional [Union [Sequence [int ], int ]] = None ,
1453
1454
prob : float = 0.1 ,
@@ -1483,7 +1484,12 @@ def __call__(self, data):
1483
1484
if self ._do_transform :
1484
1485
for key in self .key_iterator (d ):
1485
1486
for h in self .hole_coords :
1486
- d [key ][h ] = self .fill_value
1487
+ if isinstance (self .fill_value , (tuple , list )):
1488
+ if len (self .fill_value ) != 2 :
1489
+ raise ValueError ("fill_value should contain 2 numbers if providing the `min` and `max`." )
1490
+ d [key ][h ] = self .R .uniform (self .fill_value [0 ], self .fill_value [1 ], size = d [key ][h ].shape )
1491
+ else :
1492
+ d [key ][h ] = self .fill_value
1487
1493
return d
1488
1494
1489
1495
0 commit comments