Learn R Programming

rpyANTs (version 0.0.4)

is_affine3D: Check if an object is a 3D 'affine' transform matrix

Description

Check if an object is a 3D 'affine' transform matrix

Usage

is_affine3D(x, ...)

# S3 method for default is_affine3D(x, strict = TRUE, ...)

# S3 method for ants.core.ants_transform.ANTsTransform is_affine3D(x, ...)

Value

A logical value whether the object can be loaded as a 4-by-4 matrix.

Arguments

x

R or Python object, accepted forms are numeric matrix, 'ANTsTransform', or character (path to transform matrix)

...

passed to other methods

strict

whether the last element should be always 1

Examples

Run this code

# not affine
is_affine3D(1)

# 3x3 matrix is not as it is treated as 2D transform
is_affine3D(matrix(rnorm(9), nrow = 3))

# 3x4 matrix
x <- matrix(rnorm(12), nrow = 3)
is_affine3D(x)

# 4x4 matrix
x <- rbind(x, c(0,0,0,1))
is_affine3D(x)

if(interactive() && ants_available()) {

  ants <- load_ants()
  x <- ants$new_ants_transform(dimension = 3L)
  is_affine3D(x)

  # save the parameters
  f <- tempfile(fileext = ".mat")
  ants$write_transform(x, f)
  is_affine3D(f)

}




Run the code above in your browser using DataLab