-
-
Notifications
You must be signed in to change notification settings - Fork 11
Description
When the volume dimensions are not perfectly divisible by the sliding window stride, the boundary regions of the volume will not be covered by any window.
For example, with a volume of shape (144, 96, 96) and window_shape=(32, 32, 32), the kernel becomes (64, 64, 64) and stride becomes (32, 32, 32). The window positions along the D dimension are [0, 32, 64], which means the last window covers voxels 64:128. This leaves voxels 128:143 (16 voxels) completely uncovered during inference.
This behavior can cause the model to miss predictions in boundary regions, potentially affecting segmentation accuracy when tumors or other structures are located near the volume edges.
The issue occurs because the loop in do_sliding_window uses range(0, d - kd + 1, sd), which stops before reaching the end if the remaining space is less than the kernel size.
A possible fix would be to add an extra window position at the end when there is a gap, similar to how nnU-Net handles this by ensuring full coverage even if it means the last window has more overlap than others.
Related to #133.