-
Notifications
You must be signed in to change notification settings - Fork 35
Registration Concatenation
stnava edited this page Nov 2, 2018
·
1 revision
The R version of this ANTsPy example https://github.com/ANTsX/ANTsPy/blob/master/tutorials/concatenateRegistrations.ipynb
library(ANTsR)
img1 = ri( 1 ) %>% n3BiasFieldCorrection( 4 ) %>% iMath( "Normalize" )
img2 = ri( 2 )
img3 = ri( 5 )
msk = getMask( img1 ) %>% thresholdImage( 1, 33 )
segs1 <- kmeansSegmentation( img1, 3 )
plot( img1, segs1$segmentation )
reg12 = antsRegistration( img1, img2, 'SyN', affIterations=c(100,100,100,100),
regIterations=c(50,50,20,5) )
reg23 = antsRegistration( img2, img3, 'SyN', affIterations=c(100,100,100,100),
regIterations=c(50,50,20,5) )
mytx = c( reg23$invtransforms, reg12$invtransforms )
mywarpedimage = antsApplyTransforms( fixed = img3,
moving = segs1$segmentation ,
transformlist = mytx,
interpolator = 'nearestNeighbor',
whichtoinvert = c(T,F,T,F) )
plot( img3, mywarpedimage, alpha = 0.5, doCropping=F )