ANTsX / ANTsPy

A fast medical imaging analysis library in Python with algorithms for registration, segmentation, and more.
https://antspyx.readthedocs.io
Apache License 2.0
630 stars 161 forks source link

Low Spect 3D registration #339

Open Dauriel opened 2 years ago

Dauriel commented 2 years ago

Dear devs,

I am trying to align two 3D images using ANTsPy in a low spec machine. By just running the default code:

fi = ants.image_read(file1) mi = ants.image_read(file2) mytx = ants.registration(fixed=fi, moving=mi, type_of_transform = 'SyN' )

my RAM is not sufficient and it crashes. I have tried downsampling both 3D images but the quality of the registration seems to decreased substantially. Both images have different shapes.

Is there an alternative? Time is not a constraint for me, I don't mind if it takes quite some time to run.

Thank!

ntustison commented 2 years ago

Running "SyN" is going to be difficult for low RAM due to the memory requirements to run it. Are you able to do something simpler like "FastAffine"?

Dauriel commented 2 years ago

No luck with a FastAffine either, it also crashes (tried running it on Colab with 25gb RAM and it also crashes)

ntustison commented 2 years ago

Can you post the images?

Dauriel commented 2 years ago

I cannot post the images, but these are their shapes and info:

ANTsImage (RAI)
     Pixel Type : float (float32)
     Components : 1
     Dimensions : (766, 1156, 352)
     Spacing    : (0.8303, 0.8303, 1.0)
     Origin     : (0.0, 0.0, 0.0)
     Direction  : [1. 0. 0. 0. 1. 0. 0. 0. 1.]
ANTsImage (RAI)
     Pixel Type : float (float32)
     Components : 1
     Dimensions : (1024, 1946, 363)
     Spacing    : (0.4151, 0.4151, 1.0)
     Origin     : (0.0, 0.0, 0.0)
     Direction  : [1. 0. 0. 0. 1. 0. 0. 0. 1.]
ntustison commented 2 years ago

Yeah, those are pretty big images. Outside of downsampling, there's not much you can do with low memory constraints.