You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Working with augmentation for DL pipelines, it would be nice to have a transform that downsamples the image by a factor (as opposed to a specified tensor shape or voxel size) while preserving the shape of the input to simulate images acquired at a low resolution that have been resampled to a larger shape.
Describe the solution you'd like
An ideal solution would downsample the image by a specified factor, then upsample back to the original shape. Similar to RandomAnisotropy from TorchIO (https://torchio.readthedocs.io/transforms/augmentation.html) except with the capability to do isotropic downsampling.
Describe alternatives you've considered
I can get close to the desired behavior by placing two instances of a Zoom transform one after another, with reciprocal zoom factors and keep_size=False (e.g., Compose([Zoom(zoom=0.5, keep_size=False), Zoom(zoom=2.0, keep_size=False)])); however, this solution doesn't guarantee that the output shape will be the same as the input (although it will likely be close). For example, if the input shape is [192, 256, 256] and the desired downsampling factor is 3, the output shape will be [192, 255, 255].
There may be an alternative solution that I haven't considered. Otherwise, if you think this is worth adding as a new transform (or an adaptation to an existing transform), I'd be more than happy to try to submit a PR.
Yes, exactly; I was thinking of the case where the input shape is not known beforehand. I'd be happy to submit a PR for a new transform (assuming it isn't more appropriate to adapt an existing transform). What should the new transform be called? Perhaps something with Resolution in the name?
We would want a random and non-random version I suppose. @lyndonboone you could calculate the input size at the start of the __call__ method and then create the ResizeWithPadOrCrop accordingly. In this way, you wouldn't need to a priori know the image shape.
I've got one question about RandSimulateLowResolution. The nnUNet upsamples the downsampled image with cubic interpolation (according to the supplementary material, Section 4). Currently, there's only linear interpolation available for 3D images.
I've got one question about RandSimulateLowResolution. The nnUNet upsamples the downsampled image with cubic interpolation (according to the supplementary material, Section 4). Currently, there's only linear interpolation available for 3D images.
That's true. This transform uses MONAI's Resize transform which is based on torch's interpolate function, which does not offer cubic interpolation in 3D. I guess one could try to replace Resize with MONAI's Resample transform or ResampleToMatch if cubic interpolation is a requirement.
Activity
wyli commentedon Feb 8, 2022
For the alternative solution, I think you can use
ResizeWithPadOrCropas the final part of the compose to make the shapes consistentMONAI/monai/transforms/croppad/array.py
Line 1121 in 4d0baa0
if the input shape is not known beforehand, perhaps a new transform is needed? would be great to have your PR on this...
lyndonboone commentedon Feb 9, 2022
Hi @wyli , thanks for the comment.
Yes, exactly; I was thinking of the case where the input shape is not known beforehand. I'd be happy to submit a PR for a new transform (assuming it isn't more appropriate to adapt an existing transform). What should the new transform be called? Perhaps something with
Resolutionin the name?wyli commentedon Feb 9, 2022
great thanks! perhaps the name could be RandReinterpolate?
rijobro commentedon Feb 11, 2022
We would want a random and non-random version I suppose. @lyndonboone you could calculate the input size at the start of the
__call__method and then create theResizeWithPadOrCropaccordingly. In this way, you wouldn't need to a priori know the image shape.ashwinkumargb commentedon Jul 29, 2023
Has there been any updates to this? I would be interested in this functionality especially something similar to batchgenerator's SimulateLowResolutionTransform: https://github.com/MIC-DKFZ/batchgenerators/blob/master/batchgenerators/transforms/resample_transforms.py
wyli commentedon Jul 29, 2023
@aaronkujawa has kindly shared his implementations but not yet has the bandwidth to integrate them into monai core https://github.com/aaronkujawa/MONAI/blob/04e24e3e1d6030d70063aedc97884f4cd6eebb75/monai/transforms/spatial/dictionary.py#L2151 I'm labelling this as contribution wanted.
Added RandSimulateLowResolution(d) array and dictionary transforms an…
function2-llx commentedon Aug 8, 2023
I've got one question about
RandSimulateLowResolution. The nnUNet upsamples the downsampled image with cubic interpolation (according to the supplementary material, Section 4). Currently, there's only linear interpolation available for 3D images.aaronkujawa commentedon Aug 11, 2023
That's true. This transform uses MONAI's
Resizetransform which is based on torch'sinterpolatefunction, which does not offer cubic interpolation in 3D. I guess one could try to replaceResizewith MONAI'sResampletransform orResampleToMatchif cubic interpolation is a requirement.function2-llx commentedon Oct 20, 2023
FYI, it seems that the following one will work with 3D cubic interpolation now: