Type: Package
Title: Wrapper for the Computational Morphometry Toolkit ('CMTK') Library
Version: 0.2.2
Date: 2026-03-03
Description: Provides R bindings for selected components of the Computational Morphometry Toolkit ('CMTK') for image registration and point transformation. A subset of the 'C++' source code required for point transforms is bundled with 'cmtkr'. This allows direct calls into the 'CMTK' library, avoiding command-line invocations and providing order-of-magnitude speed improvements. Additional 'CMTK' functionality may be wrapped in future releases. 'CMTK' is described in Rohlfing T and Maurer CR (2003) <doi:10.1109/titb.2003.808506>.
License: GPL-3
Imports: Rcpp (≥ 0.11.2)
LinkingTo: Rcpp
Suggests: testthat, nat
SystemRequirements: zlib
Encoding: UTF-8
RoxygenNote: 7.3.3
URL: https://github.com/jefferis/cmtkr
BugReports: https://github.com/jefferis/cmtkr/issues
NeedsCompilation: yes
Packaged: 2026-03-03 15:17:09 UTC; jefferis
Author: Gregory Jefferis ORCID iD [aut, cre], Torsten Rohlfing [aut] (CMTK library author (included source)), SRI International [cph] (Copyright holder for CMTK library), Google, Inc. [cph] (Copyright holder for CMTK library contributions)
Maintainer: Gregory Jefferis <jefferis@gmail.com>
Repository: CRAN
Date/Publication: 2026-03-08 09:50:06 UTC

R wrapper for CMTK

Description

Provides R bindings for selected components of the Computational Morphometry Toolkit ('CMTK') for image registration and point transformation. A subset of the 'C++' source code required for point transforms is bundled with 'cmtkr'. This allows direct calls into the 'CMTK' library, avoiding command-line invocations and providing order-of-magnitude speed improvements. Additional 'CMTK' functionality may be wrapped in future releases. 'CMTK' is described in Rohlfing T and Maurer CR (2003) doi:10.1109/titb.2003.808506.

Author(s)

Maintainer: Gregory Jefferis jefferis@gmail.com (ORCID)

Authors:

Other contributors:

See Also

Useful links:


transform 3D points using one or more CMTK registrations

Description

transform 3D points using one or more CMTK registrations

Usage

streamxform(points, reglist, inversionTolerance = 1e-08, affineonly = FALSE)

Arguments

points

an Nx3 matrix of 3D points

reglist

A character vector specifying registrations. See details.

inversionTolerance

the precision of the numerical inversion when transforming in the inverse direction.

affineonly

Whether to apply only the affine portion of transforms default FALSE.

Details

To transform points from sample to reference space, you will need to use the inverse transformation. This can be achieved by preceding the registration with a ⁠--inverse⁠ flag. When multiple registrations are being used the are ordered from sample to reference brain.

Value

An Nx3 numeric matrix with the same dimensions as points containing transformed coordinates. Rows for points that cannot be transformed are returned as NA_real_.

Examples

m=matrix(rnorm(30,mean = 50), ncol=3)
reg=system.file("extdata","cmtk","FCWB_JFRC2_01_warp_level-01.list", package='cmtkr')
# from reference to sample
streamxform(m, reg)

# from sample to reference
streamxform(m, c("--inverse", reg))

## Not run: 
# concatenating 3 registrations to map S -> B1 -> B2 -> T
# the first two registrations are inverted, the last is not.
streamxform(m, c("--inverse", StoB1, "--inverse", B1toB2, TtoB2))

## End(Not run)