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
Hi everyone,
I’ve been trying to run the 3D classification example based on the DenseNet tutorial on occlusion sensitivity (from tutorials/3d_classification/densenet_training_array.ipynb), as mentioned in Project-MONAI/tutorials#1971 with @ericspod.
It seems like the notebook might not be running as expected on my end. I might be missing something too, so I’d really appreciate any suggestions or guidance you might have!
Hi @KumoLiu@Nic-Ma I think the issue is that monai.visualize.OcclusionSensitivity has different expectations of what's going on internally. In older versions of MONAI the tutorial worked so some code change or assumption is different now, perhaps how we're doing sliding window is now different.
Hi robsver,I'm interested in this issue, I just checked the code implementation of version 0.7.0 against the current version and I think it's the small overlap of the current siliding window that's causing the issue, I think you can simply add occ_sens = monai.visualize. OcclusionSensitivity(nn_module=model, mask_size=32, n_batch=10) by adding a parameter occ_sens = monai.visualize. mask_size=32, n_batch=10,overlap=0.75) to solve this problem, hope it helps!
Hi @kavin2003 thanks for looking into this. @robsver would you please look at the PR and try things on your end with the changed overlap value? I think it looks good so it can be merged if you're happy with the results. Thanks!
Hi @kavin2003, Thank you so much! I really appreciate your help. I'm almost certain the different activation is due to the short training performed for the tutorial, and that it has learned to distinguish other features.
Hi @ericspod, I’m running your code innmy own data and it works well, but I have a few questions. In my case, I have three sequences (three channels) with different sizes and a different number of slices between patients, so I need to resample without “inventing” slices. What strategy would you recommend? Because when I later run the occlusion code, I see it with a lot of zoom, and I would like to see it in its original size.
Hi @PARODBE Resampling images is going to be a question of compromise no matter what, so either you choose the lowest resolution image as the base and resample others to its space, or invent slices for lower resolution images to match larger ones. Using linear interpolation is going to be fine for either strategy, I wouldn't worry about inventing slices via interpolation too much honestly. The zoom issue is harder to comment on though I would guess you will just have to play with image input sizes to get the desired output.
We have tutorials on interpretability here which includes using GradCAM. I haven't used it much myself so I can't really advise what to use beyond what the tutorials demonstrate currently, but I don't see why it can be adapted to your data.
Hi @ericspod , thanks you very much for your response. Have you ever tried to implement cropping, building a CNN over cropped images, obtaining grad-cam and decropping grad-cam in order to adapt it to the original space?
Have you ever tried to implement cropping, building a CNN over cropped images, obtaining grad-cam and decropping grad-cam in order to adapt it to the original space?
Sorry @PARODBE but I haven't tried this specifically. As I mentioned, I think this can be adapted to your data, and the approach should be feasible with transforms. If you have trained a CNN on cropped images you can get a grad-cam output which is like any other image result. Perhaps one approach is to crop the input using transforms, apply grad-cam, then post-process the result with Invertdsomething like here to put the result in the original's space.
Activity
ericspod commentedon Apr 23, 2025
Hi @KumoLiu @Nic-Ma I think the issue is that
monai.visualize.OcclusionSensitivityhas different expectations of what's going on internally. In older versions of MONAI the tutorial worked so some code change or assumption is different now, perhaps how we're doing sliding window is now different.robsver commentedon May 8, 2025
Hi there! Sorry for bothering you, I was wondering if you had any updates on the issue mentioned above.
Take your time, I really appreciate it.
Thanks a lot! 😄
kavin2003 commentedon May 11, 2025
Hi robsver,I'm interested in this issue, I just checked the code implementation of version 0.7.0 against the current version and I think it's the small overlap of the current siliding window that's causing the issue, I think you can simply add occ_sens = monai.visualize. OcclusionSensitivity(nn_module=model, mask_size=32, n_batch=10) by adding a parameter occ_sens = monai.visualize. mask_size=32, n_batch=10,overlap=0.75) to solve this problem, hope it helps!
ericspod commentedon May 12, 2025
Hi @kavin2003 thanks for looking into this. @robsver would you please look at the PR and try things on your end with the changed overlap value? I think it looks good so it can be merged if you're happy with the results. Thanks!
robsver commentedon May 13, 2025
Hi @kavin2003, Thank you so much! I really appreciate your help. I'm almost certain the different activation is due to the short training performed for the tutorial, and that it has learned to distinguish other features.
But now it definitely makes sense!!
Thanks a lot @kavin2003 and @ericspod for your time!
Update default overlap value in occlusion_sensitivity to 0.6 (#8446)
ericspod commentedon May 15, 2025
I have merged the change now so if we've resolved the expected behaviour we can close this issue as completed now. Thanks all!
PARODBE commentedon Oct 3, 2025
Hi @ericspod, I’m running your code innmy own data and it works well, but I have a few questions. In my case, I have three sequences (three channels) with different sizes and a different number of slices between patients, so I need to resample without “inventing” slices. What strategy would you recommend? Because when I later run the occlusion code, I see it with a lot of zoom, and I would like to see it in its original size.
Thanks a lot!
Best regards,
Pablo
PARODBE commentedon Oct 3, 2025
By the way, My problema is multiclass, and also I'd like implement a grad-cam, is It possible with monai?
ericspod commentedon Oct 30, 2025
Hi @PARODBE Resampling images is going to be a question of compromise no matter what, so either you choose the lowest resolution image as the base and resample others to its space, or invent slices for lower resolution images to match larger ones. Using linear interpolation is going to be fine for either strategy, I wouldn't worry about inventing slices via interpolation too much honestly. The zoom issue is harder to comment on though I would guess you will just have to play with image input sizes to get the desired output.
We have tutorials on interpretability here which includes using GradCAM. I haven't used it much myself so I can't really advise what to use beyond what the tutorials demonstrate currently, but I don't see why it can be adapted to your data.
PARODBE commentedon Nov 7, 2025
Hi @ericspod , thanks you very much for your response. Have you ever tried to implement cropping, building a CNN over cropped images, obtaining grad-cam and decropping grad-cam in order to adapt it to the original space?
ericspod commentedon Nov 14, 2025
Sorry @PARODBE but I haven't tried this specifically. As I mentioned, I think this can be adapted to your data, and the approach should be feasible with transforms. If you have trained a CNN on cropped images you can get a grad-cam output which is like any other image result. Perhaps one approach is to crop the input using transforms, apply grad-cam, then post-process the result with
Invertdsomething like here to put the result in the original's space.