Run Searchlight Analysis
run_searchlight.Rd
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. Currently supported:
batch_size
: Integer specifying the number of searchlights to process per batch. Default is 10% of total searchlights. Lower values reduce memory usage but may impact performance. This controls how searchlights are grouped for processing - each batch is processed sequentially, while searchlights within a batch are processed in parallel.
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
)
# 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
)
# Run searchlight analysis
results <- run_searchlight(
mspec,
radius = 8, # 8mm radius
method = "standard" # Use standard searchlight
)
#> INFO [2025-09-28 22:01:18] Running standard searchlight with radius = 8
#> INFO [2025-09-28 22:01:18] creating standard searchlight
#> INFO [2025-09-28 22:01:18] running standard searchlight iterator
#> INFO [2025-09-28 22:01:18] Processing batch 1/11 (24 ROIs in this batch)
#> INFO [2025-09-28 22:01:26] Processing batch 2/11 (23 ROIs in this batch)
#> INFO [2025-09-28 22:01:33] Processing batch 3/11 (23 ROIs in this batch)
#> INFO [2025-09-28 22:01:40] Processing batch 4/11 (23 ROIs in this batch)
#> INFO [2025-09-28 22:01:47] Processing batch 5/11 (23 ROIs in this batch)
#> INFO [2025-09-28 22:01:54] Processing batch 6/11 (23 ROIs in this batch)
#> INFO [2025-09-28 22:02:01] Processing batch 7/11 (23 ROIs in this batch)
#> INFO [2025-09-28 22:02:08] Processing batch 8/11 (23 ROIs in this batch)
#> INFO [2025-09-28 22:02:15] Processing batch 9/11 (23 ROIs in this batch)
#> INFO [2025-09-28 22:02:22] Processing batch 10/11 (23 ROIs in this batch)
#> INFO [2025-09-28 22:02:28] Processing batch 11/11 (23 ROIs in this batch)
#> INFO [2025-09-28 22:02:35]
#> MVPA Iteration Complete
#> - Total ROIs: 254
#> - Processed: 254
#> - Skipped: 0
#> WARN [2025-09-28 22:02:35] Observed probabilities map skipped: expected 512 rows but found 100.
# Run with custom batch size for memory management
# results <- run_searchlight(
# mspec,
# radius = 8,
# method = "standard",
# batch_size = 500 # Process 500 searchlights per batch
# )
# Results contain performance metrics
# Access them with results$performance
# }