Description Usage Arguments Value Author(s) Examples
Represents feature images as a neighborhood and uses the features to build a random forest prediction from an image population
1 2 3 4 5 6 7 8 9 10 11 |
y |
list of training label images, can be a factor or numeric vector this can also be a regular old vector |
x |
a list of lists where each list contains feature images |
labelmasks |
a list of masks where each mask defines the image space for the given list. that is, the nth mask indexes the nth feature set. multi-label masks will try to balance sampling for each label. |
rad |
vector of dimensionality d define nhood radius |
nsamples |
(per subject to enter training) |
ntrees |
(for the random forest model) |
asFactors |
boolean - treat the y entries as factors |
reduceFactor |
integer factor by which to reduce (imaging) data resolution |
... |
arguments to pass to |
list a 4-list with the rf model, training vector, feature matrix and the random mask
Avants BB, Tustison NJ, Pustina D
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 26 27 28 29 30 31 32 33 34 35 | mask<-makeImage( c(10,10), 0 )
mask[ 3:6, 3:6 ]<-1
mask[ 5, 5:6]<-2
ilist<-list()
lablist<-list()
masklist<-list()
inds<-1:5
scl<-0.33 # a noise parameter
for ( predtype in c("label","scalar") )
{
for ( i in inds ) {
img<-antsImageClone(mask)
imgb<-antsImageClone(mask)
limg<-antsImageClone(mask)
if ( predtype == "label") { # 4 class prediction
img[ 3:6, 3:6 ]<-rnorm(16)*scl+(i %% 4)+scl*mean(rnorm(1))
imgb[ 3:6, 3:6 ]<-rnorm(16)*scl+(i %% 4)+scl*mean(rnorm(1))
limg[ 3:6, 3:6 ]<-(i %% 4)+1 # the label image is constant
}
if ( predtype == "scalar") {
img[ 3:6, 3:6 ]<-rnorm(16,1)*scl*(i)+scl*mean(rnorm(1))
imgb[ 3:6, 3:6 ]<-rnorm(16,1)*scl*(i)+scl*mean(rnorm(1))
limg<-i^2.0 # a real outcome
}
ilist[[i]]<-list(img,imgb) # two features
lablist[[i]]<-limg
masklist[[i]] = mask
}
rfm<-vwnrfs( lablist , ilist, masklist[[1]], rad=c(2,2) ) # use single mask
rfm<-vwnrfs( lablist , ilist, masklist, rad=c(2,2) )
if ( predtype == "label" )
print( sum( rfm$tv != predict(rfm$rfm) ) )
if ( predtype == "scalar" )
print( cor(as.numeric(rfm$tv) , as.numeric(predict(rfm$rfm) ) ) )
} # end predtype loop
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.