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

antspy is much slower than ANTs. #717

Closed
hz1z opened this issue Oct 16, 2024 · 8 comments
Closed

antspy is much slower than ANTs. #717

hz1z opened this issue Oct 16, 2024 · 8 comments

Comments

@hz1z
Copy link

hz1z commented Oct 16, 2024

For the same functionality, I can get results in one minute using the ANTs command line, but it’s very slow and doesn’t produce results when using Python.
image

python

import ants

fix_img_pt = '/home/hyh/code/coregister/tmax.nii.gz'
move_img_pt = '/home/hyh/code/coregister/dwi_dcm.nii.gz'
save_path = './reg_img.nii.gz'

fix_img = ants.image_read(fix_img_pt)
move_img = ants.image_read(move_img_pt)

outs = ants.registration(fix_img, move_img, type_of_transforme='Affine')

reg_img = outs['warpedmovout']
ants.image_write(reg_img, save_path)

ANTs

antsRegistrationSyN.sh -d 3 -f tmax,nii.gz -m dwi_dcm.nii.gz -o aff -t a
@ntustison
Copy link
Member

Even though they're both affine registrations, the parameters between the two are different.

@cookpa
Copy link
Member

cookpa commented Oct 16, 2024

There were some speed differences fixed in #703, but as @ntustison says, parameters differ. To compare like to like, you need to use type_of_transform='antsRegistrationSyN[a]'

@hz1z
Copy link
Author

hz1z commented Oct 16, 2024

outs = ants.registration(fix_img, move_img,
                             type_of_transforme='Affine', verbose=True)

try to use verbose to debug, i find ...
image
I think it didn’t perform the registration; it just got stuck at…

@hz1z
Copy link
Author

hz1z commented Oct 16, 2024

It’s possible that I want to register DWI to the three-component Tmax, and I tried with one component T1 and DWI, and there was no issue; it worked.

@ntustison
Copy link
Member

Note that there is overlap when you use the family of transforms, e.g., type_of_transforme="antsRegistrationSyN[a]". Consult the help menu for further guidance.

@cookpa
Copy link
Member

cookpa commented Oct 16, 2024

It’s possible that I want to register DWI to the three-component Tmax, and I tried with one component T1 and DWI, and there was no issue; it worked.

That's probably the problem then, antspy sees the 4D image and tries to do a 4D registration (much slower).

In your command line example you had -d 3. You must extract a 3D image to use here (eg, b0 from dwi) or the output will be incorrect

@cookpa
Copy link
Member

cookpa commented Oct 16, 2024

@cookpa
Copy link
Member

cookpa commented Oct 22, 2024

Faster ANTsPy now available in 0.5.4

@cookpa cookpa closed this as completed Oct 22, 2024
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

3 participants