-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Please add another interpolation mode for NiftiSaver to avoid ziazag pattern caused by 'nearest' #3333
Comments
related to #3178 |
Hi @Jingnan-Jia , Thanks for your interesting experiments and detailed feedback. Thanks. |
Hi @wyli and @Nic-Ma , Thanks for your reply. I have tried some experiments and found that my expectated feature is almost the same with [#3178 ]. The only difference is that the implementation of [#3178 ] is using Gaussian filger, while my implementation is using Mean filter. And my threshold is also 0.4. (By the way, my task is 3D lung lobe segmentation.) I have tried his Gassian filter but it did not work. Maybe because I did not set the correct sigma value. |
The left figure is the original mask. The middle figure is the results after down-sampling and up-sampling. Obvious ziazzag pattern appeared at the edge. The right figgure is the result after I apply my smooth algorithm to the middle figure. We can see the significant improvement. The dice between figure 1 and figure 2: 0.982 |
However, now I am not sure if we should add this feature to MONAI. Because it is not easy to select a good smooth hyper parameter or threshold for different masks with different resolutions. |
closing this in favour of #3333 and #5264
val_post_transforms = Compose(
[
EnsureTyped(keys="pred"),
Activationsd(keys="pred", sigmoid=True),
AsDiscreted(keys="pred", threshold=0.5),
KeepLargestConnectedComponentd(keys="pred", applied_labels=[1]),
SaveImaged(keys="pred", resample=False, output_dir="./runs/")
]
) |
Is your feature request related to a problem? Please describe.
In the current NiftiSaver, there are only two interpolation modes: "nereast" and "bilinear". It is not enough. Detailed explanication as follows.
If I have an lung CT image with shape (1024, 512, 512). To do lung or lobe segmentation, I need to down sample the original CT image to a smaller size (256, 256, 256). So the resample factors are (0.25, 0.5, 0.5). After I finish the model training, the predicted lung or lobe segmentation needs to be up-sampled to the original shape during inference. If I use "bilinear" mode for NiftiSaver, some zigzag pattern would appear along the edge of lung or lobe.
Describe the solution you'd like
Using current MONAI, I came up with several possible solutions to avoid the zigzag pattern in NiftiSaver :
I do not have a satisfied solution in current MONAI. I hope NiftiSaver can have a mode "bilinear2nearest". In this mode, the NiftiSaver will:
I have implementated this workflow in my own code, and it works well. I hope MONAI can also add this feature to NiftiSaver.
Note: The zigzag pattern matters especially when the interpolation factor is far from 1.
Note: this initial idea was implementated by myself these days and this idea can not remove zigzag pattern. So I followed [#3178 ], changed his Gaussian filter to Mean filter, and then got satisfied results. More details were shown bellow.
The text was updated successfully, but these errors were encountered: