# NOT RUN {
if ( usePkg('randomForest') ) {
img<-antsImageRead( getANTsRData("r16"))
mask<-getMask( img )
mask2<-getMask( img )
mask [ 129:255, 1:255 ]<-0
mask2[ 2:128, 1:255 ]<-0
segs<-kmeansSegmentation( img, k=3, kmask = mask)
fmat = t( antsrimpute( getNeighborhoodInMask( img, mask, c(2,2) ) ) )
rfsegs<-rfSegmentation( fmat, mask, segs$segmentation, ntrees=100 )
fmat2 = t( antsrimpute( getNeighborhoodInMask( img, mask2, c(2,2) ) ) )
rfseg2<-rfSegmentationPredict( rfsegs$rfModel , fmat2 , mask2 )
}
# }
Run the code above in your browser using DataLab