jointLabelFusion.Rd
A multiple atlas voting scheme to customize labels for a new subject. This
function will also perform intensity fusion. It almost directly calls the
C++
in the ANTs executable so is much faster than other variants in ANTsR.
One may want to normalize image intensities for each input image before
passing to this function. If no labels are passed, we do intensity fusion.
Note on computation time: the underlying C++
is multithreaded. You can control the number of threads by setting the
environment variable ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS
e.g. to use all or
some of your CPUs. This will improve performance substantially. For instance,
on a macbook pro from 2015, 8 cores improves speed by about 4x.
jointLabelFusion(targetI, targetIMask, atlasList, beta = 4, rad = 2, labelList = NA, rho = 0.01, usecor = FALSE, rSearch = 3, nonnegative = FALSE, verbose = FALSE)
targetI | antsImage to be approximated |
---|---|
targetIMask | mask with value 1 |
atlasList | list containing antsImages with intensity images |
beta | weight sharpness, default to 2 |
rad | neighborhood radius, default to 2 |
labelList | optional list containing antsImages with segmentation labels |
rho | ridge penalty increases robustness to outliers but also makes image converge to average |
usecor | employ correlation as local similarity |
rSearch | radius of search, default is 3 |
nonnegative | constrain weights to be non-negative |
verbose | boolean |
approximated image, segmentation and probabilities
set.seed(123) ref <- ri( 1 ) ref<-resampleImage(ref,c(50,50),1,0) ref<-iMath(ref,"Normalize") mi<- ri( 2 ) mi2<-ri( 3 ) mi3<-ri( 4 ) mi4<-ri( 5 ) mi5<-ri( 6 ) refmask<-getMask(ref) refmask<-iMath(refmask,"ME",2) # just to speed things up ilist<-list(mi,mi2,mi3,mi4,mi5) seglist<-list() for ( i in 1:length(ilist) ) { ilist[[i]]<-iMath(ilist[[i]],"Normalize") mytx<-antsRegistration(fixed=ref , moving=ilist[[i]] , typeofTransform = c("Affine"), verbose = TRUE ) mywarpedimage<-antsApplyTransforms(fixed=ref, moving=ilist[[i]], transformlist=mytx$fwdtransforms) ilist[[i]]=mywarpedimage seg<-thresholdImage( ilist[[i]],"Otsu", 3) seglist[[i]]<-seg } r<-2 pp<-jointLabelFusion(ref,refmask,ilist, rSearch=2, labelList=seglist, rad=rep(r, length(dim(ref)) ) ) pp2<-jointLabelFusion(ref,refmask,ilist, rSearch=2, labelList=seglist, rad=rep(r, length(dim(ref)) ) ) testthat::expect_equal(pp2$segmentation, pp$segmentation) pp<-jointLabelFusion(ref,refmask,ilist, rSearch=2, rad=rep(r, length(dim(ref)) ) )# NOT RUN { ref = antsImageRead( getANTsRData("ch2") ) n = 50 ref = resampleImage(ref,c(n,n,n),1,0) ref = iMath(ref,"Normalize") refmask = getMask(ref) ilist = list() seglist = list() for ( k in 1:5 ) { mi = antsImageClone( ref ) + rnorm( n^3, 0, 0.1 ) mykseg = kmeansSegmentation( mi, 3, refmask )$segmentation ilist[[ k ]] = mi seglist[[ k ]] = mykseg } pp = jointLabelFusion( ref, refmask,ilist, rSearch=2, labelList=seglist, rad=rep(2, length(dim(ref)) ), verbose=TRUE ) plot( ref, pp$segmentation ) plot( pp$intensity ) # }