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

mirror.character handles images on disk

mirror(x, ...)

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

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

# S3 method for 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 error. For other values, see details.

Value

Object with transformed points

Details

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

  • a single number equal to x0+x1

  • a 2-vector c(x0, x1) (recommended)

  • the boundingbox for the 3D data to be mirrored: the relevant axis specified by mirrorAxis will be extracted.

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.

Examples

nopen3d()
x=Cell07PNs[[1]]
mx=mirror(x,168)
# \donttest{
plot3d(x,col='red')
plot3d(mx,col='green')
# }

# also works with dotprops objects
nclear3d()
y=kcs20[[1]]
my=mirror(y,mirrorAxisSize=564.2532,transform='flip')
# \donttest{
plot3d(y, col='red')
plot3d(my, col='green')
# }

if (FALSE) {
## 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')
}