Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent patch size from antspynet.extract_image_patches #46

Closed
stnava opened this issue Jan 15, 2022 · 13 comments
Closed

Inconsistent patch size from antspynet.extract_image_patches #46

stnava opened this issue Jan 15, 2022 · 13 comments

Comments

@stnava
Copy link
Member

stnava commented Jan 15, 2022

hi @ntustison - do you know a quick solution to this?

img=ants.image_read( ants.get_data( "r16" ) )
radder=[20,20]
msk=ants.get_mask( img )
ptch = antspynet.extract_image_patches( img, tuple(radder), mask_image=msk, 
  max_number_of_patches = 512, return_as_array=False )
for k in range(512):
     print( ptch[k].shape )

shows patches of variable sizes. when trying to compute consistent patch statistics, this can lead to issues of power. I believe this behavior is different from antsrnet.

img=ri(1)
radder=c(20,20)
msk=getMask( img )
ptch = extractImagePatches( img, radder, maskImage=msk, 
  max_number_of_patches = 512, return_as_array=False )

@ntustison
Copy link
Member

Oh, that's not good. Let me see if I can figure it out.

@ntustison
Copy link
Member

Hey, @stnava , I just ran your code snippet a couple times on a couple different machines (2 macs/python 3.7 and archeozoic/python 3.8) and I'm getting patch shapes of the same size (20, 20). What are you getting?

@stnava
Copy link
Member Author

stnava commented Jan 15, 2022

this should do it more reliably

import ants
import antspynet
msk=ants.image_read("exmsk.nii.gz")
img=ants.image_read("eximg.nii.gz")
ptch = antspynet.extract_image_patches( img, tuple([20,20,20]), mask_image=msk,max_number_of_patches = 1000, return_as_array=False )
for k in range(len(ptch)):
    print(ptch[k].shape)

you see things like: (20, 20, 13)

exmsk.nii.gz
eximg.nii.gz

I just ran this on archeozoic - images are in my ~/

@stnava
Copy link
Member Author

stnava commented Jan 15, 2022

image

just trying to get this application correct - images sorted by quality using a blind image quality method

@stnava
Copy link
Member Author

stnava commented Jan 15, 2022

were you able to reproduce?

@ntustison
Copy link
Member

Sorry @stnava , just getting breakfast for the kids. I’ll test it in just a sec.

@stnava
Copy link
Member Author

stnava commented Jan 15, 2022

np - am about to head out for surf in 4 degree weather

@ntustison
Copy link
Member

Oh, man, that’s insane.

@ntustison
Copy link
Member

Okay, yeah, I was able to reproduce. Interesting that it seems to be only in the 3rd dimension which makes me wonder if it is a dimensionality issue when I modified the code from 2-D to 3-D.

I have to go run an errand (on my OneWheel so it'll kind of be like surfing but in 64 degree weather) but I'll work on it when I get back.

@ntustison
Copy link
Member

Okay, check this commit which should fix the issue.

@stnava
Copy link
Member Author

stnava commented Jan 15, 2022

that did it - thx! do you have any thoughts on my PR?

@stnava stnava closed this as completed Jan 15, 2022
@ntustison
Copy link
Member

Great. During my attempts at debugging, I found a second, unrelated bug so I'm glad you discovered this issue.

I really didn't have any thoughts on the brain extraction part as I just assumed you had discovered a problem with "nobrainer". If its related to quality assessment than I confess I haven't used that much (although I was thinking quite a bit about these models recently with deep flash and using it to see if it is as I suspect that DeepFlash performs relatively better (compared to e.g., FreeSurfer) on higher quality data.

@stnava
Copy link
Member Author

stnava commented Jan 16, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants