Skip to contents

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 mvpa_model
run_searchlight(
  model_spec,
  radius = 8,
  method = c("randomized", "standard"),
  niter = 4,
  combiner = "average",
  permute = FALSE,
  ...
)

# S3 method for 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 manova_model
run_searchlight(
  model_spec,
  radius = 8,
  method = c("randomized", "standard"),
  niter = 4,
  permute = FALSE,
  ...
)

# S3 method for 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")
#> INFO [2024-04-23 13:39:56] model is: sda_notune
#> INFO [2024-04-23 13:39:56] running standard searchlight with 8 radius 
#> INFO [2024-04-23 13:39:56] creating standard searchlight
#> INFO [2024-04-23 13:39:56] running standard searchlight iterator
#> INFO [2024-04-23 13:39:56] mvpa_iterate: compute analysis for batch 1 ...
#> INFO [2024-04-23 13:39:57] mvpa_iterate: compute analysis for batch 2 ...
#> INFO [2024-04-23 13:39:57] mvpa_iterate: compute analysis for batch 3 ...
#> INFO [2024-04-23 13:39:57] mvpa_iterate: compute analysis for batch 4 ...
#> INFO [2024-04-23 13:39:58] mvpa_iterate: compute analysis for batch 5 ...
#> INFO [2024-04-23 13:39:58] mvpa_iterate: compute analysis for batch 6 ...
#> INFO [2024-04-23 13:39:59] mvpa_iterate: compute analysis for batch 7 ...
#> INFO [2024-04-23 13:39:59] mvpa_iterate: compute analysis for batch 8 ...
#> INFO [2024-04-23 13:40:00] mvpa_iterate: compute analysis for batch 9 ...
#> INFO [2024-04-23 13:40:00] mvpa_iterate: compute analysis for batch 10 ...
#> INFO [2024-04-23 13:40:00] mvpa_iterate: compute analysis for batch 11 ...
#> INFO [2024-04-23 13:40:01] mvpa_iterate: compute analysis for batch 12 ...
#> INFO [2024-04-23 13:40:01] mvpa_iterate: compute analysis for batch 13 ...

# 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.

if (FALSE) { 
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)
}