Problem with monai.data.utils.iter_patch #6606
-
Firstly, I want to crop some overlap 3D patches with sliding window from a medical Image. Then I found the function iter_patch and I checked if it work in a simple way. a = np.array([[1,2,3,4],[5,6,7,8],[8,7,6,5],[4,3,2,1]])
print(a)
c= iter_patch(a,patch_size=[2,2],start_pos=0,overlap=0.5,copy_back=False)
for i,b in c:
print(i,"\n") but get a wired output like this
but when I change the Input into string, it seems to work well a = np.array([["a", "a", "b", "b"], ["a", "a", "b", "b"], ["c", "c", "d", "d"], ["c", "c", "d", "d"]])
print(a)
c= iter_patch(a,patch_size=[2,2],start_pos=0,overlap=0.5,copy_back=False)
for i,b in c:
print(i,"\n")
So, I want to know what happened, and how can I create some overlap patches and save it in files with monai? Thanks a lot |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi @Mo-Junyang, you need to ensure the data is channel-first, try something like this:
You can also try to use Hope it can help you, thanks! |
Beta Was this translation helpful? Give feedback.
Hi @Mo-Junyang, you need to ensure the data is channel-first, try something like this:
You can also try to use
PatchDataset
andGridPatchDataset
Hope it can help you, thanks!