NeuroSpace {neuroim2}R Documentation

NeuroSpace: Spatial Reference System for Neuroimaging Data

Description

The NeuroSpace class defines the spatial properties and coordinate system of neuroimaging data. It encapsulates all information needed to map between voxel indices and real-world coordinates, including dimensions, voxel spacing, origin, axis orientation, and coordinate transformations.

Usage

NeuroSpace(dim, spacing = NULL, origin = NULL, axes = NULL, trans = NULL)

Arguments

dim

An integer vector specifying the dimensions of the image grid. Must be positive.

spacing

A numeric vector specifying the physical size of each voxel (typically in millimeters). Must be positive. If NULL, defaults to ones.

origin

A numeric vector specifying the real-world coordinates of the first voxel. If NULL, defaults to zeros.

axes

An AxisSet object defining the orientation and ordering of the coordinate axes. If NULL, defaults to standard neurological convention (Left-Posterior-Inferior for 3D).

trans

A transformation matrix mapping voxel indices to world coordinates. If NULL, constructed from spacing and origin.

Details

Spatial Reference System for Neuroimaging Data

Value

A new NeuroSpace object

Coordinate Systems

NeuroSpace manages two coordinate systems:

The transformation between these systems is defined by:

Validation

The constructor performs extensive validation:

References

For details on neuroimaging coordinate systems:

See Also

AxisSet for axis orientation specification, coord_to_index for coordinate conversion, index_to_coord for inverse coordinate conversion, NeuroObj for objects using NeuroSpace

Examples

# Create a standard 3D space (64x64x40 voxels, 2mm isotropic)
space_3d <- NeuroSpace(
  dim = c(64L, 64L, 40L),
  spacing = c(2, 2, 2),
  origin = c(-90, -126, -72)
)

# Check properties
dim(space_3d)           # Image dimensions
spacing(space_3d)       # Voxel sizes
origin(space_3d)        # World-space origin

# Create a 2D slice space
space_2d <- NeuroSpace(
  dim = c(128L, 128L),
  spacing = c(1.5, 1.5),
  origin = c(-96, -96)
)

# Convert between coordinate systems
world_coords <- c(0, 0, 0)
vox_idx <- coord_to_index(space_3d, world_coords)
back_to_world <- index_to_coord(space_3d, vox_idx)


[Package neuroim2 version 0.8.1 Index]