mirror {nat}R Documentation

Mirror 3D object about a given axis, optionally using a warping registration

Description

mirroring with a warping registration can be used to account e.g. for the asymmetry between brain hemispheres.

mirror.character handles images on disk

Usage

mirror(x, ...)

## S3 method for class 'character'
mirror(x, output, mirrorAxisSize = NULL, target = x, ...)

## Default S3 method:
mirror(
  x,
  mirrorAxisSize,
  mirrorAxis = c("X", "Y", "Z"),
  warpfile = NULL,
  transform = c("warp", "affine", "flip"),
  ...
)

## S3 method for class 'neuronlist'
mirror(x, subset = NULL, OmitFailures = NA, ...)

Arguments

x

Object with 3D points (with named cols X,Y,Z) or path to image on disk.

...

additional arguments passed to methods or eventually to xform

output

Path to the output image

mirrorAxisSize

A single number specifying the size of the axis to mirror or a 2 vector (recommended) or 2x3 matrix specifying the boundingbox (see details).

target

Path to the image defining the target grid (defaults to the input image - hard to see when this would not be wanted).

mirrorAxis

Axis to mirror (default "X"). Can also be an integer in range 1:3.

warpfile

Optional registration or reglist to be applied after the simple mirroring.. It is called warpfile for historical reasons, since it is normally the path to a CMTK registration that specifies a non-rigid transformation to correct asymmetries in an image.

transform

whether to use warp (default) or affine component of registration, or simply flip about midplane of axis.

subset

For mirror.neuronlist indices (character/logical/integer) that specify a subset of the members of x to be transformed.

OmitFailures

Whether to omit neurons for which FUN gives an error. The default value (NA) will result in nlapply stopping with an error message the moment there is an eror. For other values, see details.

Details

The mirrorAxisSize argument can be specified in 3 ways for the x axis with extreme values, x0+x1:

This function is agnostic re node vs cell data, but for node data BoundingBox should be supplied while for cell, it should be bounds. See boundingbox for details of BoundingBox vs bounds.

See nlapply for details of the subset and OmitFailures arguments.

Value

Object with transformed points

See Also

xform, boundingbox

nlapply

Examples

nopen3d()
x=Cell07PNs[[1]]
mx=mirror(x,168)

plot3d(x,col='red')
plot3d(mx,col='green')


# also works with dotprops objects
clear3d()
y=kcs20[[1]]
my=mirror(y,mirrorAxisSize=564.2532,transform='flip')

plot3d(y, col='red')
plot3d(my, col='green')


## Not run: 
## Example with an image
# note that we must specify an output image (obviously) but that as a
# convenience mirror calculates the mirrorAxisSize for us
mirror('myimage.nrrd', output='myimage-mirrored.nrrd', 
  warpfile='myimage_mirror.list')

# Simple flip along a different axis
mirror('myimage.nrrd', output='myimage-flipped.nrrd', mirrorAxis="Y", 
  transform='flip')

## End(Not run)

[Package nat version 1.8.24 Index]