sparseRegression: Sparse regression on input images.

Description Usage Arguments Value Author(s) References Examples

View source: R/sparseRegression.R

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
sparseRegression(
  inmatrix,
  demog,
  outcome,
  mask = NULL,
  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:

eigenanatomyimages

Coefficient vector images.

umatrix

Projections of input images on the sparse regression vectors. Can be used for, e.g., subsequent classification/predictions.

projections

Predicted values of outcome variable.

Author(s)

Kandel BM, Avants BB.

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

 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
nsubj <- 50
prop.train <- 1/2
subj.train <- sample(1:nsubj, prop.train*nsubj, replace = FALSE )
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)

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