mrvnrfs | R Documentation |
Represents multiscale feature images as a neighborhood and uses the features to build a random forest segmentation model from an image population
mrvnrfs(
y,
x,
labelmasks,
rad = NA,
nsamples = 1,
ntrees = 500,
multiResSchedule = c(4, 2, 1),
asFactors = TRUE,
voxchunk = 50000,
...
)
y |
list of training labels. either an image or numeric value |
x |
a list of lists where each list contains feature images |
labelmasks |
a mask (or list of masks) used to define where the samples will come from. Note, two labels (e.g., GM and WM) will double the number of samples from each feature images. If the mask is binary, samples are selected randomly within 1 values. |
rad |
vector of dimensionality d define nhood radius |
nsamples |
(per subject to enter training) |
ntrees |
(for the random forest model) |
multiResSchedule |
an integer vector defining multi-res levels |
asFactors |
boolean - treat the y entries as factors |
voxchunk |
value of maximal voxels to predict at once. This value is used to split the prediction into smaller chunks such that memory requirements do not become too big |
... |
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()
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
}
rad <- rep(1, 2)
mr <- c(1.5, 1)
rfm <- mrvnrfs(lablist, ilist, mask,
rad = rad, multiResSchedule = mr,
asFactors = (predtype == "label")
)
rfmresult <- mrvnrfs.predict(rfm$rflist,
ilist, mask,
rad = rad, asFactors = (predtype == "label"),
multiResSchedule = mr
)
if (predtype == "scalar") {
print(cor(unlist(lablist), unlist(rfmresult$seg)))
}
} # end predtype loop
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.