cmtk.call: Utility function to create and run calls to CMTK commandline...

View source: R/cmtk.R

cmtk.callR Documentation

Utility function to create and run calls to CMTK commandline tools

Description

cmtk.call processes arguments into a form compatible with CMTK command line tools.

cmtk.system2 actually calls a cmtk tool using a call list produced by cmtk.call

Usage

cmtk.call(
  tool,
  PROCESSED.ARGS = NULL,
  ...,
  FINAL.ARGS = NULL,
  RETURN.TYPE = c("string", "list")
)

cmtk.system2(cmtkcall, moreargs = NULL, ...)

Arguments

tool

Name of the CMTK tool

PROCESSED.ARGS

Character vector of arguments that have already been processed by the callee. Placed immediately after cmtk tool.

...

Additional named arguments to be processed by (cmtk.call, see details) or passed to system2 (cmtk.system2).

FINAL.ARGS

Character vector of arguments that have already been processed by the callee. Placed at the end of the call after optional arguments.

RETURN.TYPE

Sets return type to a character string or list (the latter is suitable for use with system2)

cmtkcall

A list containing processed arguments prepared by cmtk.call(RETURN.TYPE="list")

moreargs

Additional arguments to add to the processed call

Details

cmtk.call processes arguments in ... as follows:

argument names

will be converted from arg.name to --arg-name

logical vectors

(which must be of length 1) will be passed on as --arg-name

character vectors

(which must be of length 1) will be passed on as --arg-name arg i.e. quoting is left up to callee.

numeric vectors

will be collapsed with commas if of length greater than 1 and then passed on unquoted e.g. target.offset=c(1,2,3) will result in --target-offset 1,2,3

Value

Either a string of the form "<tool> <PROCESSED.ARGS> <...> <FINAL.ARGS>" or a list containing elements

  • command A character vector of length 1 indicating the full path to the CMTK tool, shell quoted for protection.

  • args A character vector of arguments of length 0 or greater.

See the help of system2 for details.

See Also

cmtk.bindir

Examples

## Not run: 
cmtk.call("reformatx",'--outfile=out.nrrd', floating='floating.nrrd',
  mask=TRUE, target.offset=c(1,2,3), FINAL.ARGS=c('target.nrrd','reg.list'))
# get help for a cmtk tool
system(cmtk.call('reformatx', help=TRUE))

## End(Not run)
## Not run: 
cmtk.system2(cmtk.call('mat2dof', help=TRUE, RETURN.TYPE="list"))
# capture response into an R variable
helptext=cmtk.system2(cmtk.call('mat2dof', help=TRUE, RETURN.TYPE="list"),
  stdout=TRUE)

## End(Not run)

nat documentation built on May 29, 2024, 10:36 a.m.