MONAI icon indicating copy to clipboard operation
MONAI copied to clipboard

can't use TrainableBilateralFilter for 3d image

Open kfir7755 opened this issue 1 year ago • 3 comments

I am trying to use the TrainableBilateralFilter from from monai.networks.layers for a random 3d tensor but I don't understand how an image can be used there since there is a limitation that input_image.shape[1] (channels dimension) will be 1 and also a limitation for self.len_spatial_sigma != len_input. Since len(spatial_sigma) always equals to 3 it is impossible to be able to upload a 3d image due to the first limitation.

To Reproduce from monai.networks.layers import TrainableBilateralFilter bilateralFilter = TrainableBilateralFilter([1.0, 1.0, 1.0], 1.0)

  1. for bilateralFilter (torch.randn(1,1,10,10,10)) the error we will have is

ValueError: Spatial dimension (5) must match initialized len(spatial_sigma).

  1. for bilateralFilter (torch.randn(1,10,10,10)) (meaning no batch dimension) the error we will have is

ValueError: Currently channel dimensions >1 (10) are not supported. Please use multiple parallel filter layers if you want to filter multiple channels. it suggests me to use other function because it mistakes my 1st image dimension as a channel dimension. for torch.randn(10,10,10) as an input the same will happen as well.

Expected behavior for atleast one of the above image format the forward function should work

Environment Python 3.10.12 monai 1.3.0

I hope I am not mistaken for what the input shape you can use for this filter but as much as I could understand it should work for 3d input as well. I couldn't find examples or uses for this filter.

Any kind of help or correction will be really apprecitiated. TY in advance

kfir7755 avatar Feb 07 '24 00:02 kfir7755

I have the same issue with 2D images (sorry, it seems I made a duplicate -> I will link mine to this one). In the assertion the batch and channel dimension are forgotten.

Nora-Go avatar Feb 12 '24 07:02 Nora-Go

Our team from CodeDayLabs '24 will be working on this issue.

K-Rilla avatar Aug 23 '24 00:08 K-Rilla

Actually after claiming it, we weren't able to reproduce the error. We're thinking the issue might've been fixed with later updates after this issue was posted.

K-Rilla avatar Aug 23 '24 00:08 K-Rilla