rfSegmentation: A rfSegmentation function.

Description Usage Arguments Value Author(s) See Also Examples

View source: R/rfSegmentation.R

Description

Unsupervised image segmentation via random forests. An example.

Usage

1
2
3
4
5
6
7
rfSegmentation(
  featureMatrix,
  mask,
  labelimg = NULL,
  ntrees = 100,
  verbose = FALSE
)

Arguments

featureMatrix

input matrix of features matched to mask size n predictors in rf

mask

input antsImage mask

labelimg

input antsImage labelimage, optional for supervised seg

ntrees

number of rf trees

verbose

boolean

Value

list of n-probability images is output where n is number of classes

Author(s)

Tustison NJ, Avants BB

See Also

mrvnrfs

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
## Not run: 
if ( usePkg("randomForest") ) {
img<-antsImageRead( getANTsRData("r16") ) %>% iMath("Normalize")
mask<-getMask( img )
segs<-kmeansSegmentation( img, k=3, kmask = mask)
fmat0 = t( antsrimpute( getNeighborhoodInMask( img, mask, c(2,2) ) ) )
fmat1 = t( antsrimpute( getNeighborhoodInMask(
  segs$probabilityimages[[1]], mask, c(2,2) ) ) )
fmat2 = t( antsrimpute( getNeighborhoodInMask(
  segs$probabilityimages[[2]], mask, c(2,2) ) ) )
fmat3 = t( antsrimpute( getNeighborhoodInMask(
  segs$probabilityimages[[3]], mask, c(2,2) ) ) )
fmat = cbind( fmat0, fmat1, fmat2, fmat3 )
# produces proximity between all voxel pairs
rfsegs<-rfSegmentation( fmat, verbose=FALSE )
lrr = lowrankRowMatrix( rfsegs, 10, faster = TRUE )
nv = eanatSelect( inmat=lrr, mask=mask, selectorScale=1.2,  cthresh=50,
  verbose=T, smooth=1 )
ee = eanatDef( lrr, mask, nvecs=nv, smooth=0., cthresh=50,
  its=2, verbose=TRUE )
eseg = eigSeg( mask, ee )
plot( img, eseg )
}

## End(Not run)

neuroconductor-devel/ANTsR documentation built on April 1, 2021, 1:02 p.m.