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
634 stars 162 forks source link

Is it possible to save intermediate step results to generate an animation of the registration process? #254

Closed ants2021 closed 3 years ago

ants2021 commented 3 years ago

New to ANTsPy.

After running the 'C' example (https://github.com/stnava/C), five files were generated in the output folder.

One is "antsr0VelocityField.nii.gz" with dimensionality of (150, 150, 8, 1, 2).

150 150 represent the input image dimensions,

I wonder what '8, 1, 2' represent.

Does '2' represent the two components of a velocity vector field as shown in the following figure?

image

Thanks in advance.

stnava commented 3 years ago
>>> ants.image_read("antsr0VelocityField.nii.gz")
ANTsImage (RPI)
     Pixel Type : float (float32)
     Components : 2
     Dimensions : (150, 150, 8)
     Spacing    : (1.0, 1.0, 1.0)
     Origin     : (0.0, 0.0, 0.0)
     Direction  : [ 1.  0.  0.  0. -1.  0.  0.  0.  1.]

try using the ants reader - it's a velocity field as defined https://en.wikipedia.org/wiki/Flow_velocity

so the "extra" dimension (8) is time.

space - x, y = (150,150) time - t = 8 components = dx,dy = 2

ants2021 commented 3 years ago

Thanks for your prompt reply.

I wonder if there is a document or something like (best users' guide) for the whole pipeline and tuning the parameters and explaining them.

I wonder if it possible to apply Bayesian optimisation to find the optimal parameters for a registration.

ntustison commented 3 years ago

There are a couple papers that you can see in the README file in the ANTs GitHub repo. You might want to start with this one.

stnava commented 3 years ago

there are several papers on such topics as well as several tutorials and user guides. you can google for them or read the documentation pages.

yes - you can run a parameter search to find the "best" registration parameters assuming you can define "best" objectively and quantitatively.

ants2021 commented 3 years ago

Thank you very much for your responses that are really helpful.

Yes. I have read through yours 2011 paper https://pubmed.ncbi.nlm.nih.gov/20851191/, which gives me a bird's view of registration.

I am going to read the one pointed by @ntustison.

@stnava, I wonder if you would be kind enough to point me to the documents. I have run through the 'cars' example (https://github.com/stnava/cars).

its=[1500x1500x1500x300x100x0,1.e-7,5] its2=[200x200x200x200x150x50,0,5] smth=5x4x3x2x1x0 down=7x6x5x4x2x1 ---Any principles I can follow to set up the parameters for multi-resolution(?) registration process? Not sure I understood this correct?
tx=" syn[ 0.25 , 3.0, 1 ] " 3.0--- correlation radius (window size)? if [[ ! -s b2f0GenericAffine.mat ]] ; then antsRegistration -d $dim \ -m Mattes[ $f, $m , 1, 20, Random, 0.2 ] \ --- how about this 20? -t affine[ 2.0 ] \ -c $its \ -s $smth \ -f $down \ -u 1 -v 1 \ -o [b2f,b2f_aff.nii.gz] fi

-m cc[ $f, $m , 1, 8 ] \

antsRegistration -d $dim -r [b2f0GenericAffine.mat] \ -m Mattes[ $f, $m , 1, 32 ] \ --- how about this 32? -t $tx \ -c $its2 \ -s $smth \ -f $down \ -u 1 -v 1 \ -o [b2f,b2f_diff.nii.gz,b2f_diff_inv.nii.gz]

I am aware that antsRegistration can do joint optimisation (combine multiple metrics). If it is possible, please point me to such an example.

to define "best" registration objectively and quantitatively, I wonder if it is possible to wrap another optimiser around the current metrics.

Thanks again for the great tool and your response.

stnava commented 3 years ago

see https://github.com/ANTsX/ANTs and the wiki that is there

see the https://github.com/ANTsX/ANTsPy/tree/master/tutorials

ants2021 commented 3 years ago

@stnava many thanks. That is really helpful. Cheers