Convert a suitable object to an im3d object.

as.im3d(x, ...)

# S3 method for im3d
as.im3d(x, ...)

# S3 method for matrix
as.im3d(x, voxdims, origin = NULL, BoundingBox = NULL, ...)

Arguments

x

Object to turn into an im3d

...

Additional arguments to pass to methods.

voxdims

Numeric vector of length 3 or an im3d compatible object (see details) completely specifying the required space.

origin

the location (or centre) of the first voxel

BoundingBox

Physical extent of image. See the details section of boundingbox's help for the distinction.

Details

At present the only interesting method in nat is as.im3d.matrix which can be used to convert a matrix of 3D points into a 3D volume representation. ind2coord can be used to do the reverse: convert a set of 3D coords to an im3d volume.

Other than that, this is a largely a placeholder function with the expectation that other packages may wish to provide suitable methods.

as.im3d.matrix can accept any object that can be converted to an im3d object in the voxdims argument This will completely specify the dims, voxdims, origin etc. Any value passed to those parameters will be ignored. This can be useful for producing a new im3d to match a target image on disk or a nat.templatebrains::templatebrain object. See examples.

See also

Examples

## convert a list of neurons into an image volume
im=as.im3d(xyzmatrix(kcs20), voxdims=c(1, 1, 1), 
  BoundingBox=c(250, 410, 0, 130, 0, 120))
if (FALSE) {
write.im3d(im, 'kc20volume.nrrd')

## use image dimensions of an image on disk
# nb note use of ReadData = FALSE so that we just fetch the dimensions of
# the target image
diskim=read.im3d("/path/to/my/image.nrrd", ReadData = FALSE)
im=as.im3d(xyzmatrix(kcs20), diskim)

## use image dimensions of JFRC2 template brain to define the image space
library(nat.flybrains)
im=as.im3d(xyzmatrix(kcs20), JFRC2)
}