Skip to contents

Computes the vertex-wise difference (a - b) between two surface maps (numeric vectors or MGH/GII file paths) for each hemisphere, then renders the result on a standard fsaverage surface via plot_vw_surf().

Useful for contrasting two conditions, time-points, groups, or model terms without pre-computing the difference outside R.

Usage

plot_vw_diff(
  lh_a = NULL,
  lh_b = NULL,
  rh_a = NULL,
  rh_b = NULL,
  label_a = "a",
  label_b = "b",
  cutoffs = 0,
  ...
)

Arguments

lh_a, lh_b

Left-hemisphere map: numeric vector or path to an MGH/GII file. Both must have the same length / vertex count. Pass NULL to omit the left hemisphere entirely.

rh_a, rh_b

Right-hemisphere map: same as above for the right hemisphere. Pass NULL to omit the right hemisphere.

label_a, label_b

Short character labels used in the default figure title (e.g. "group A", "group B"). Ignored when title is supplied via ....

cutoffs

Numeric vector or cutoffs for counting positive and negative differences. Passed to vw_diff() for difference summary. Default = 0.

...

Additional arguments forwarded to plot_vw_surf(), e.g. roi_outline, views, cmap, vmin, vmax, colorbar, colorbar_label, title, to_file, dpi, fs_home, fs_template.

Value

Invisibly: the output of plot_vw_surf() — the temp HTML file path (interactive mode) or to_file path (static PNG mode). Called primarily for its side-effect of opening or saving the figure.

Examples

if (FALSE) { # rlang::is_installed("reticulate") && dir.exists("path/to/model1/")
# Two numeric vectors
plot_vw_diff(
  lh_a = lh_term1, lh_b = lh_term2,
  rh_a = rh_term1, rh_b = rh_term2,
  label_a = "Term 1", label_b = "Term 2",
  cmap = "RdBu_r"
)

# Two MGH files, left hemisphere only
plot_vw_diff(
  lh_a = "path/to/model1/lh.area.aic.mgh",
  lh_b = "path/to/model2/lh.area.aic.mgh",
  label_a = "model1", label_b = "model2"
)
}