Skip to contents

Map points using h5 registrations

Usage

# S3 method for h5reg
xformpoints(reg, points, ..., method = c("auto", "java", "rjava"))

Arguments

reg

A h5reg object specifying one or more h5 registrations.

points

An Nx3 matrix of 3D points to transform

...

Additional arguments passed to java transform tool (currently ignored).

method

Whether to shell out to java executable (method='java') or use the rJava package (method='rjava'). The default (method='auto') uses rJava if installed. See Java section for implications of this choice.

Value

An Nx3 matrix of transformed points

Details

See h5reg for details of the ordering of registrations.

Java

By default xformpoints.h5reg starts a separate Java Virtual Machine (JVM) for every call. This has an overhead that might be in the 0.5s range, which quickly builds up. Alternatively, you can use method='rjava', which depends on the 'rJava' package; since rJava can be a little fiddly to install, this is only a suggested dependency. Using rJava transparently starts a single JVM session from R and then reuses that, substantially speeding up the situation when you have many small objects to transform. It is also somewhat more efficient in terms of disk/CPU since points are retained in memory rather than written out as text files. However in my hands this has limited impact on the elapsed time.

See also

h5reg for an example of point transformations using h5 registrations and xform and xformpoints for details of how transformations are handled within the neuroanatomy toolbox suite.

Other h5reg: h5reg()

Examples

# \donttest{
# basic usage
library(nat)
#> Loading required package: rgl
#> Some nat functions depend on a CMTK installation. See ?cmtk and README.md for details.
#> 
#> Attaching package: ‘nat’
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, union
sampleh5path=system.file("samples/JRC2018F_FAFB_extrasmall.h5",
  package = 'nat.h5reg')
sampleh5reg=h5reg(sampleh5path)
xform(cbind(50,50,30), sampleh5reg)
#>          [,1]     [,2]     [,3]
#> [1,] 221.2568 147.9268 19.90423
xform(cbind(50,50,30), sampleh5reg, swap=TRUE)
#>          [,1]     [,2]     [,3]
#> [1,] 221.2568 147.9268 19.90423
# }

if (FALSE) {
# specify a particular level for registration containing more than 1 level
# of detail
# NB not implemented in this sample
xform(cbind(50,50,30), sampleh5reg, level=0)
# choose faster, lower resolution registration
xform(cbind(50,50,30), sampleh5reg, level=2)
# print more detailed error messages when trying to debug
xform(cbind(50,50,30), sampleh5reg, level=0, stderr="")
}