train_model.contrast_rsa_model: Train method for contrast_rsa_model

View source: R/contrast_rsa_model.R

train_model.contrast_rsa_modelR Documentation

Train method for contrast_rsa_model

Description

This function implements the core logic for the MS-ReVE analysis within a single searchlight or region.

Usage

## S3 method for class 'contrast_rsa_model'
train_model(obj, sl_data, sl_info, cv_spec, ...)

Arguments

obj

An object of class contrast_rsa_model.

sl_data

The data matrix for the current searchlight (samples x voxels).

sl_info

A list containing information about the current searchlight, including center_local_id, the column index of the center voxel within sl_data.

cv_spec

The cross-validation specification object (e.g., from \link{blocked_cross_validation}).

...

Additional arguments (currently ignored).

Value

A named list where each element corresponds to a requested 'output_metric' from the 'obj$output_metric' vector. Each element is:

  • For metrics like "beta_delta", "beta_only", "delta_only": A Q-length named vector where values are indexed by contrast and names match the contrast_matrix column names (Q = number of contrasts)

  • For metrics like "recon_score", "composite": A single numeric value

The list will have an attribute "na_reason" if any metric calculation failed, which can be used for diagnostics.

For example, if 'obj$output_metric = c("beta_delta", "recon_score")', the returned list will have two elements: '$beta_delta' (a Q-length vector) and '$recon_score' (a single value).

Examples

# This example shows the structure of the returned list but doesn't actually run the function
# For a multi-metric model: output_metric = c("beta_delta", "recon_score", "beta_only")
# With 2 contrasts named "contrast1" and "contrast2", the return structure would be:
# 
# result <- list(
#   beta_delta = c(contrast1 = 0.23, contrast2 = -0.15),
#   recon_score = 0.72,
#   beta_only = c(contrast1 = 1.45, contrast2 = 0.88)
# )
#
# Accessing individual metrics:
# result$beta_delta["contrast1"]  # Value for first contrast's beta*delta
# result$recon_score              # Single value for reconstruction score


bbuchsbaum/rMVPA documentation built on June 10, 2025, 8:23 p.m.