Learn R Programming

ANTsR (version 0.3.3)

sparseRegression: Sparse regression on input images.

Description

Compute a sparse, spatially coherent regression from a set of input images (with mask) to an outcome variable.

Usage

sparseRegression(inmatrix, demog, outcome, mask = NA, sparseness = 0.05, nvecs = 10, its = 5, cthresh = 250, statdir = NA, z = 0, smooth = 0)

Arguments

inmatrix
Input data matrix, with dimension number of subjects by number of voxels.
demog
Input demographics data frame. Contains outcome variable to regress against.
outcome
Name of column in demog to regress against.
mask
Mask for reconstructing inmatrix in physical space.
sparseness
Level of sparsity desired. 0.05, for example, makes 5% of the matrix be non-zero.
nvecs
Number of eigenvectors to return.
its
Number of cross-validation folds to run.
cthresh
Cluster threshold.
statdir
Where to put results. If not provided, a temp directory is created.
z
Row (subject-wise) sparseness.
smooth
Amount of smoothing.

Value

A list of values: A list of values:

References

Kandel B.M., D. Wolk, J. Gee, and B. Avants. Predicting Cognitive Data from Medical Images Using Sparse Linear Regression. Information Processing in Medical Imaging, 2013. literature/web site here ~

Examples

Run this code

## Not run: 
# nsubj <- 1000
# prop.train <- 1/2
# subj.train <- sample(1:nsubj, prop.train*nsubj, replace=F)
# input <- t(replicate(nsubj, rnorm(125)))
# outcome <- seq(1, 5, length.out=nsubj)
# demog <- data.frame(outcome=outcome)
# input[, 40:60] <- 30 + outcome + rnorm(length(input[, 40:60]), sd=2)
# input.train <- input[subj.train, ]
# input.test <- input[-subj.train, ]
# demog.train <- data.frame(outcome=demog[subj.train, ])
# demog.test <- data.frame(outcome=demog[-subj.train, ])
# mymask <- as.antsImage(array(rep(1, 125), dim=c(5,5,5)))
# myregression <- sparseRegression(input.train, demog.train, 'outcome', mymask,
#     sparseness=0.05, nvecs=5, its=3, cthresh=250)
# # visualization of results
# sample <- rep(0, 125)
# sample[40:60] <-1
# signal.img <- as.antsImage(array(rep(0,125), dim=c(5, 5, 5)))
# signal.img[signal.img >= 0 ] <- sample
# plot( signal.img, axis=2, slices='1x5x1') # actual source of signal
# # compare against first learned regression vector
# myimgs <- list()
# for( i in 1:5){
#   myarray <- as.array(myregression$eigenanatomyimages[[ i ]])
#   myarray <- myarray / max(abs(myarray)) # normalize for visualization
#   myimgs[[ i ]] <- antsImageClone(myregression$eigenanatomyimages[[ i ]])
#   myimgs[[ i ]][mymask > 0] <- myarray
# }
# plot(myimgs[[1]], axis=2, slices='1x5x1')
# # use learned eigenvectors for prediction
# result <- regressProjections(input.train, input.test, demog.train,
#     demog.test, myregression$eigenanatomyimages, mymask, 'outcome')
# plot(result$outcome.comparison$real, result$outcome.comparison$predicted)
# ## End(Not run)

Run the code above in your browser using DataLab