-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit 77fd5f4
authored
Occlusion sensitivity to use slidiing_window_inference (#5230)
### Description
Occlusion sensitivity currently works by setting the logits at the
center of the occluded region. Even though neighbouring voxels are
occluded at the same time, this is not recorded. A better way to do it
would be to do an average each time a voxel is occluded. This is taken
care of by switching to using `sliding_window_inference`.
We had to do a bit of hacking to get this to work.
`sliding_window_inference` normally takes a subset of the whole image
and infers that. We want `sliding_window_inference` to tell us which
part of the image we should occlude, then we occlude it and infer the
**whole** image. To that end, we use a meshgrid to tell us the
coordinates of the region `sliding_window_inference` wants us to
occlude. We occlude, infer and then crop back to the size of the region
that was requested by `sliding_window_inference`.
This PR also allows for different occlusion kernels. We currently have:
- gaussian (actually inverse gaussian): the center of the occluded
region is zero, and towards the edge of the image is unchanged. This
doesn't introduce hard edges into the image, which might undermine the
visualisation process.
- mean_patch: the occluded region is replaced with the mean of the patch
it is occluding.
- mean_img: the occluded region is replaced with the mean of the whole
image (current implementation).
## Changes to input arguments
This PR is backwards incompatible, as using `sliding_window_inference`
means changing the API significantly.
- pad_val: now determined by `mode`
- stride: `overlap` used instead
- per_channel: all channels are done simultaneously
- upsampler: image is no longer downsampled
## Changes to output
Output previously had the shape `B,C,H,W,[D],N` where `C` and `N` were
the number of input and output channels of the network, respectively.
Now, we output the shape `B,N,H,W,[D]` as the `per_channel` feature is
no longer present.
Columns 2-4 are occlusion sensitivity done with Gaussian, mean of patch
and mean of image:

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [x] Breaking change (fix or new feature that would cause existing
functionality to change).
- [x] New tests added to cover the changes.
- [x] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [x] In-line docstrings updated.
- [x] Documentation updated, tested `make html` command in the `docs/`
folder.
Signed-off-by: Richard Brown <[email protected]>1 parent 607123b commit 77fd5f4Copy full SHA for 77fd5f4
File tree
Expand file treeCollapse file tree
2 files changed
+302
-253
lines changedFilter options
- monai/visualize
- tests
Expand file treeCollapse file tree
2 files changed
+302
-253
lines changed
0 commit comments