If you work with neuroimaging data
in R, you’ve probably typed out a system() call to
wb_command at some point. Maybe you wrapped it in a helper
function. Maybe that helper grew. wbcmd is the version of that helper
that validates your inputs, finds your binary, and gets out of the
way.
Install Connectome Workbench, then load the package:
wb_sitrep() checks whether the binary is reachable and
prints what it finds. On macOS and Linux, wbcmd searches common
installation paths and the system PATH automatically.
If the binary lives somewhere unusual, tell wbcmd where:
The full lookup order is:
wbcmd.pathWB_PATH/Applications/wb_view.app/... on macOS)PATHSet WB_PATH in your .Renviron and you never
think about it again.
wb_cmd() is the universal entry point. It takes the
subcommand name and arguments exactly as you would type them on the
command line:
Every wrapper function in wbcmd calls wb_cmd()
internally. If a wrapper doesn’t exist for the command you need,
wb_cmd() always works.
The wrappers handle argument construction, file validation, and output path management. They error before the command runs if an input file is missing, and they create output directories on the fly.
cifti_math(), metric_math(), and
volume_math() all take a symbolic expression and a named
list of file paths:
ciftiTools reads and writes CIFTI files as R objects. wbcmd runs Workbench operations on those files. They complement each other — ciftiTools gives you the data in R, wbcmd gives you the processing pipeline.
Both packages need the same binary. Point them to the same path and they share the setup:
wb_path <- "/opt/workbench/bin_linux64/wb_command"
wbcmd::set_wb_path(wb_path)
ciftiTools::ciftiTools.setOption("wb_path", wb_path)A typical workflow reads data with ciftiTools, processes files with wbcmd, then reads the results back:
library(ciftiTools)
library(wbcmd)
xii <- read_cifti("data.dtseries.nii", brainstructures = "all")
cifti_parcellate(
"data.dtseries.nii",
"atlas.dlabel.nii",
direction = "COLUMN",
cifti_out = "parcellated.ptseries.nii"
)
parcellated <- read_cifti("parcellated.ptseries.nii")ciftiTools also has its own run_wb_cmd() function that
takes a pre-formatted command string. If you already use that, wbcmd’s
wb_cmd() does the same job with the addition of path
detection, argument quoting, and verbose logging.