Find 1D indices into a 3D image given spatial coordinates

coord2ind(coords, ...)

# S3 method for default
coord2ind(
coords,
imdims,
voxdims = NULL,
origin = NULL,
aperm,
Clamp = FALSE,
CheckRanges = !Clamp,
...
)

## Arguments

coords spatial coordinates of image voxels. extra arguments passed to methods. array dimensions of 3D image OR an object for which a as.im3d object has been defined (see Details). vector of 3 voxels dimensions (width, height, depth). the origin of the 3D image. permutation order for axes. ??? whether to check if coordinates are out of range.

## Details

coord2ind is designed to cope with any user-defined class for which an as.im3d method exists. Presently the only example in the nat.* ecosystem is nat.templatebrains::as.im3d.templatebrain. The existence of an as.im3d method implies that voxdims,origin, and dim functions can be called. This is the necessary information required to convert i,j,k logical indices into x,y,z spatial indices.

ind2coord, sub2ind, ijkpos
coord2ind(cbind(1,2,3), imdims = c(1024,512,218),
}