Skip to content

tutorial on occlusion sensitivity #8428

Closed

Description

@robsver

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!

Thanks a lot in advance :) !

Activity

  1. ericspod commented on Apr 23, 2025

    @ericspod
    Member

    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.

  2. robsver commented on May 8, 2025

    @robsver
    Author

    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! 😄

  3. kavin2003 commented on May 11, 2025

    @kavin2003
    Contributor

    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!

    Image

  4. ericspod commented on May 12, 2025

    @ericspod
    Member

    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!

  5. robsver commented on May 13, 2025

    @robsver
    Author

    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!

  6. ericspod commented on May 15, 2025

    @ericspod
    Member

    I have merged the change now so if we've resolved the expected behaviour we can close this issue as completed now. Thanks all!

  7. PARODBE commented on Oct 3, 2025

    @PARODBE

    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

  8. PARODBE commented on Oct 3, 2025

    @PARODBE

    By the way, My problema is multiclass, and also I'd like implement a grad-cam, is It possible with monai?

  9. ericspod commented on Oct 30, 2025

    @ericspod
    Member

    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.

  10. PARODBE commented on Nov 7, 2025

    @PARODBE

    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?

  11. ericspod commented on Nov 14, 2025

    @ericspod
    Member

    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 Invertd something like here to put the result in the original's space.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions