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, ...)
| coords | spatial coordinates of image voxels. |
|---|---|
| ... | extra arguments passed to methods. |
| imdims | array dimensions of 3D image OR an object for which a
|
| voxdims | vector of 3 voxels dimensions (width, height, depth). |
| origin | the origin of the 3D image. |
| aperm | permutation order for axes. |
| Clamp | ??? |
| CheckRanges | whether to check if coordinates are out of range. |
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.
coord2ind(cbind(1,2,3), imdims = c(1024,512,218), voxdims = c(0.622088, 0.622088, 0.622088), origin = c(0,0,0))#> [1] 2624515# NOT RUN { ## repeat but using a templatebrain object to specify the coordinate system library(nat.flybrains) coord2ind(cbind(1,2,3), JFRC2) # }