as.im3d: Convert a suitable object to an im3d object.

View source: R/im3d.R

as.im3dR Documentation

Convert a suitable object to an im3d object.


Convert a suitable object to an im3d object.


as.im3d(x, ...)

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

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



Object to turn into an im3d


Additional arguments to pass to methods.


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


the location (or centre) of the first voxel


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


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

im3d, ind2coord

im3d, as.im3d

Other im3d: boundingbox(), im3d-coords, im3d-io, im3d(), imexpand.grid(), imslice(), is.im3d(), mask(), origin(), projection(), threshold(), unmask(), voxdims()


## 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))
## Not run: 
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
im=as.im3d(xyzmatrix(kcs20), JFRC2)

## End(Not run)

nat documentation built on April 6, 2022, 5:06 p.m.