Skip to content

iter_patch_slices Patch Order #4287

@bhashemian

Description

@bhashemian

Similar to convolutions, the way usually sliding window is implemented is going over the slow dimension first and then go down the other indices (sweeping row by row), like this:

A = [[ a, a, b, b],
     [ a, a, b, b],
     [ c, c, d, d],
     [ c, c, d, d]] 

L = [[[a,a],[a,a]],[[b,b],[b,b]], [[c,c],[c,c]], [[d,d],[d,d]]

However, in iter_patch_slices, this behavior is intentionally reversed:

MONAI/monai/data/utils.py

Lines 148 to 149 in cd77e91

for position in product(*ranges[::-1]): # reverse ranges order to iterate in index order
yield tuple(slice(s, s + p) for s, p in zip(position[::-1], patch_size_))

Is there any reason for that? Can we stick to the more common convention?

Metadata

Metadata

Assignees

No one assigned

    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