run_searchlight: run_searchlight

View source: R/allgeneric.R

run_searchlightR Documentation

run_searchlight

Description

Execute a searchlight analysis.

This function runs a searchlight analysis using a specified MVPA model, radius, and method. It can be customized with a combiner function and permutation options.

This function runs a searchlight analysis using a specified RSA model, radius, and method. It can be customized with permutation options, distance computation methods, and regression methods.

This function runs a searchlight analysis using a specified MANOVA model, radius, and method. It can be customized with permutation options.

This function runs a searchlight analysis using a specified vector RSA model, radius, and method. It can be customized with permutation options, distance computation methods, and regression methods.

Usage

run_searchlight(model_spec, radius, method, niter, ...)

## S3 method for class 'mvpa_model'
run_searchlight(
  model_spec,
  radius = 8,
  method = c("randomized", "standard"),
  niter = 4,
  combiner = "average",
  permute = FALSE,
  ...
)

## S3 method for class 'rsa_model'
run_searchlight(
  model_spec,
  radius = 8,
  method = c("randomized", "standard"),
  niter = 4,
  permute = FALSE,
  distmethod = c("spearman", "pearson"),
  regtype = c("pearson", "spearman", "lm", "rfit"),
  ...
)

## S3 method for class 'manova_model'
run_searchlight(
  model_spec,
  radius = 8,
  method = c("randomized", "standard"),
  niter = 4,
  permute = FALSE,
  ...
)

## S3 method for class 'vector_rsa'
run_searchlight(
  model_spec,
  radius = 8,
  method = c("randomized", "standard"),
  niter = 4,
  permute = FALSE,
  ...
)

Arguments

model_spec

An object of type vector_rsa_model specifying the vector RSA model to be used.

radius

The radius of the searchlight sphere (default is 8, allowable range: 1-100).

method

The method used for the searchlight analysis ("randomized" or "standard").

niter

The number of iterations for randomized searchlight (default is 4).

...

Additional arguments to be passed to the function.

combiner

A function that combines results into an appropriate output, or one of the following strings: "pool" or "average".

permute

Whether to permute the labels (default is FALSE).

distmethod

The method used to compute distances between searchlight samples ("spearman" or "pearson").

regtype

The method used to fit response and predictor distance matrices ("pearson", "spearman", "lm", or "rfit").

Value

A named list of NeuroVol objects, where each element contains a performance metric (e.g. AUC) at every voxel location.

References

Bjornsdotter, M., Rylander, K., & Wessberg, J. (2011). A Monte Carlo method for locally multivariate brain mapping. Neuroimage, 56(2), 508-516.

Kriegeskorte, N., Goebel, R., & Bandettini, P. (2006). Information-based functional brain mapping. Proceedings of the National academy of Sciences of the United States of America, 103(10), 3863-3868.

See Also

run_searchlight.randomized, run_searchlight.standard

Examples

# TODO: Add an example
 
dataset <- gen_sample_dataset(c(4,4,4), 100, blocks=3)
cval <- blocked_cross_validation(dataset$design$block_var)
model <- load_model("sda_notune")
mspec <- mvpa_model(model, dataset$dataset, design=dataset$design, model_type="classification", crossval=cval)
res <- run_searchlight(mspec, radius=8, method="standard")

# A custom "combiner" can be used to post-process the output of the searchlight classifier for special cases.
# In the example below, the supplied "combining function" extracts the predicted probability of the correct class 
# for every voxel and every trial and then stores them in a data.frame.

## Not run:  
custom_combiner <- function(mspec, good, bad) { 
   good %>% pmap(function(result, id, ...) { 
     data.frame(trial=1:length(result$observed), id=id, prob=prob_observed(result)) 
   }) %>% bind_rows()
}

res2 <- run_searchlight(mspec, radius=8, method="standard", combiner=custom_combiner)

## End(Not run)

bbuchsbaum/rMVPA documentation built on April 28, 2024, 6:30 a.m.