| geometry | R Documentation |
Accessors for the geometry of an image: the number of spatial dimensions, the voxel size and the placement of the image in world space.
isImage(x)
spatial(x)
voxelSize(x)
voxelSize(x) <- value
worldTransform(x)
worldTransform(x) <- value
toVoxel(points, x, type = "world", round = "none", bounds = NULL)
fromVoxel(points, x, type = "world")
x |
An image, or for |
value |
A replacement value. |
points |
A matrix of points, one per row and three columns. Where
|
type |
The coordinate convention of |
round |
Rounding strategy: |
bounds |
Optional image extents, used only by probabilistic rounding to avoid selecting a location beyond the end of the image. |
These are deliberately free of any dependency on a file format, and of any assumption that geometry is anatomical: an image with no meaningful spatial interpretation is free to leave it at the identity default and never think about it again.
Voxel size and world placement are stored, and can be set, independently of
one another, unlike a NIfTI xform, which bakes voxel size into the same
matrix that carries rotation and translation and so has to be kept in sync
by hand. Here, voxelSize<- never touches rotation or translation, and
the stored placement is always a rigid transform (rotation or reflection
plus translation; no scale and no shear) so that the two cannot drift out
of agreement.
worldTransform() composes the two into the single 4x4 affine that other
packages expect. Setting it back decomposes the matrix into rotation and
scale; a matrix that doesn't decompose that way (i.e. one with genuine
shear) is rejected rather than silently mangled. In practice a sheared
NIfTI sform usually means the field is being used to carry an affine
registration or normalisation result (to Talairach or MNI space, say)
rather than to describe voxel storage geometry, which is a different kind
of information than this package models.
toVoxel() and fromVoxel() use one-based voxel coordinates, matching
x[i, j, k] indexing. The affine itself, and the rest of the package's C++
API, is zero-based throughout.
isImage() returns a Boolean value indicating whether its argument
is one of the package's image types. spatial() returns the index of the
last spatial dimension. voxelSize() returns a vector of sizes in each
spatial dimension. worldTransform() returns a numeric affine transform
matrix. toVoxel() and fromVoxel() return matrices of transformed
points, one per row. The assignment functions are called for their
side-effects.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.