ANTsPy icon indicating copy to clipboard operation
ANTsPy copied to clipboard

finding some properties of antsRegistration in ants.registration

Open amirreza1998 opened this issue 3 years ago • 1 comments

hi i have code below in ANTs to convert to ANTspy code :

f = <fixed image path>
m = <moving image path>

${ANTSPATH}/antsRegistration -d 3 \
			-r [$f, $m,1]\
			-m MI[$f,$m,1,32] \
                        -t affine[ 0.5 ]  \
			-c [50x50x5 , 1.e-7, 5]  \
                        -s 4x2x1  \
			-f 4x2x1 \
						-m MI[$f,$m,1,32] \
						-t syn[ 0.25 , 2, 2 ]\
						-c [5x5x5,1.e-7,5]  \
						-s 4x2x1  \
						-f 4x2x1 \
						-u 1 \
			-o [${nm},${nm}_diffToMRN1.nii,${nm}_invToMRN1.nii]

and i make below code in ANTspy :

MImetric = ["MattesMutualInformation", fname1, fname2, 1,  32]
metrics = list( )
metrics.append(MImetric)
mytx_affine = ants.registration(fixed=fname1, moving=fname2,
                          type_of_transform = 'Affine',
                          grad_step=0.5,                                               #           -t affine[ 0.5 ] set that 0.5 gradient step
                          multivariate_extras=metrics,                                 #          -m MI[$f,$m,1,32] \
                          aff_iterations=(50, 50, 5),                                  #       -c $its  \         =>              its=[50x50x5,1.e-7,5]
                          aff_smoothing_sigmas=(4, 2, 1),                              #        -s 4x2x1  \
                          aff_shrink_factors=(4, 2, 1),                                #       	-f 4x2x1 \
)

mytx4 = ants.registration(fixed=fname1, moving=fname2,
                          type_of_transform = 'SyNOnly',
                          syn_sampling=32, 
                          reg_iterations=(5, 5, 5),                                  #       -c $its  \         =>              its=[50x50x5,1.e-7,5]
                          multivariate_extras=metrics,                                 #          -m MI[$f,$m,1,32] \
                          
                          grad_step=0.25,                                             #tx=" syn[ 0.25 , 2, 2 ] "
                          flow_sigma=2,
                          total_sigma=2,

                          #aff_smoothing_sigmas=(4, 2, 1),                              #        -s 4x2x1  \
                          #aff_shrink_factors=(4, 2, 1),                                #       	-f 4x2x1 \
                          
                          initial_transform = mytx_affine['fwdtransforms'][0],
                          outprefix = "diffToMRN1_",                                    #          -o [${nm},${nm}_diffToMRN1.nii,${nm}_invToMRN1.nii]

)
mywarpedimage = ants.apply_transforms( fixed=fname1, moving=fname2,
                                           transformlist=mytx4['fwdtransforms'] )

but i don't know how should implement :

  • what is equivalent for 1.e-7,5 as convergenceThreshold and convergenceWindowSize in ANTsPy?
  • how should implement -r [$f, $m,1] in ANTsPy (or initializationFeature set to image intensities)
  • how should set -u 1 as use-histogram-matching in ANTsPy?
  • and is it correct set -s 4x2x as aff_smoothing_sigmas=(4, 2, 1) and -f 4x2x1 \ as aff_shrink_factors=(4, 2, 1) and could i use this parameter for Syn transform type ?

it's very important to me to convert this code i will be so thankful if you could help me

amirreza1998 avatar Apr 27 '22 10:04 amirreza1998

I made a PR to show users what's being done (#377) but not all of the command line options are exposed in the function.

Some of the things you asked about are done by default, for example -r [ fixed, moving, 1 ] is the default initialization.

If you really need to reproduce your CLI command precisely, I think you should write a script to run it directly.

cookpa avatar Jun 01 '22 19:06 cookpa