Skip to contents

Execute a searchlight analysis using multivariate pattern analysis.

Usage

run_searchlight(
  model_spec,
  radius,
  method = c("standard", "randomized"),
  niter = NULL,
  ...
)

Arguments

model_spec

A mvpa_model instance containing the model specifications

radius

The searchlight radius in millimeters

method

The type of searchlight, either 'randomized' or 'standard'

niter

The number of searchlight iterations (used only for 'randomized' method)

...

Extra arguments passed to specific searchlight methods

Value

A named list of NeuroVol objects containing performance metrics (e.g., AUC) at each voxel location

Examples

# \donttest{
  # Generate sample dataset with categorical response
  dataset <- gen_sample_dataset(
    D = c(8,8,8),           # 8x8x8 volume
    nobs = 100,             # 100 observations
    response_type = "categorical",
    data_mode = "image",
    blocks = 3,             # 3 blocks for cross-validation
    nlevels = 2             # binary classification
  )
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'i' in selecting a method for function '[<-': could not find function "coords"
  
  # Create cross-validation specification using blocks
  cval <- blocked_cross_validation(dataset$design$block_var)
  
  # Load the SDA classifier (Shrinkage Discriminant Analysis)
  model <- load_model("sda_notune")
  
  # Create MVPA model
  mspec <- mvpa_model(
    model = model,
    dataset = dataset$dataset,
    design = dataset$design,
    model_type = "classification",
    crossval = cval
  )
#> Error in assert_that(!is.null(model$fit)): could not find function "assert_that"
  
  # Run searchlight analysis
  results <- run_searchlight(
    mspec,
    radius = 8,            # 8mm radius
    method = "standard"    # Use standard searchlight
  )
#> Error in UseMethod("run_searchlight"): no applicable method for 'run_searchlight' applied to an object of class "c('vector_rsa_model', 'model_spec', 'list')"
  
  # Results contain performance metrics
  # Access them with results$performance
# }