Learn R Programming

nat (version 1.8.24)

cmtk.bindir: Return path to directory containing CMTK binaries

Description

The Computational Morphometry Toolkit (CMTK) is the default image registration toolkit supported by nat. An external CMTK installation is required in order to apply CMTK registrations. This function attempts to locate the full path to the CMTK executable files and can query and set an option.

Usage

cmtk.bindir(
  firstdir = getOption("nat.cmtk.bindir"),
  extradirs = c("~/bin", "/usr/local/lib/cmtk/bin", "/usr/local/bin", "/opt/local/bin",
    "/opt/local/lib/cmtk/bin/", "/Applications/IGSRegistrationTools/bin",
    "C:\\cygwin64\\usr\\local\\lib\\cmtk\\bin",
    "C:\\Program Files\\CMTK-3.3\\CMTK\\lib\\cmtk\\bin"),
  set = FALSE,
  check = FALSE,
  cmtktool = "gregxform"
)

Value

Character vector giving path to CMTK binary directory or NULL when this cannot be found.

Arguments

firstdir

Character vector specifying path containing CMTK binaries or NA (see details). This defaults to options('nat.cmtk.bindir').

extradirs

Where to look if CMTK is not in firstdir or the PATH

set

Whether to set options('nat.cmtk.bindir') with the found directory. Also check/sets cygwin path on Windows (see Installation section).

check

Whether to (re)check that a path that has been set appropriately in options(nat.cmtk.bindir='/some/path') or now found in the PATH or alternative directories. Will throw an error on failure.

cmtktool

Name of a specific cmtk tool which will be used to identify the location of all cmtk binaries.

Installation

It is recommended to install released CMTK versions available from the NITRC website. A bug in composition of affine transformations from CMTK parameters in the CMTK versions <2.4 series means that CMTK>=3.0 is strongly recommended. CMTK v3 registrations are not backwards compatible with CMTK v2, but CMTKv3 can correctly interpret and convert registrations from earlier versions.

On Windows, when set=TRUE, cmtk.bindir will also check that the cygwin bin directory is in the PATH. If it is not, then it is added for the current R session. This should solve issues with missing cygwin dlls.

Details

Queries options('nat.cmtk.bindir') if firstdir is not specified. If that does not contain the appropriate binaries, it will look in the system PATH for the cmtk wrapper script installed by most recent cmtk installations.

Failing that, it will look for the cmtk tool specified by cmtktool, first in the path and then a succession of plausible places until it finds something. Setting options(nat.cmtk.bindir=NA) or passing firstdir=NA will stop the function from trying to locate CMTK, always returning NULL unless check=TRUE, in which case it will error out.

See Also

Examples

Run this code
message(ifelse(is.null(d<-cmtk.bindir()), "CMTK not found!",
               paste("CMTK is at:",d)))
if (FALSE) {
# set options('nat.cmtk.bindir') according to where cmtk was found
op=options(nat.cmtk.bindir=NULL)
cmtk.bindir(set=TRUE)
options(op)}

Run the code above in your browser using DataLab