vwnrfs.Rd
Represents feature images as a neighborhood and uses the features to build a random forest prediction from an image population
vwnrfs( y, x, labelmasks, rad = NA, nsamples = 8, ntrees = 500, asFactors = TRUE, reduceFactor = 1, ... )
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
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#> [1] 6 #> [1] 0.7881108