coord_to_index-methods: convert n-dimensional real world coordinates to 1D indices

coord_to_indexR Documentation

convert n-dimensional real world coordinates to 1D indices

Description

convert n-dimensional real world coordinates to 1D indices

Usage

coord_to_index(x, coords)

## S4 method for signature 'NeuroSpace,matrix'
coord_to_index(x, coords)

## S4 method for signature 'NeuroSpace,numeric'
coord_to_index(x, coords)

## S4 method for signature 'NeuroVol,matrix'
coord_to_index(x, coords)

Arguments

x

the object

coords

a matrix of real world coordinates

Value

An integer vector of 1D indices corresponding to coords.

Examples

bvol <- NeuroVol(array(0, c(10,10,10)), NeuroSpace(c(10,10,10), c(1,1,1)))
coords <- matrix(c(.5,.5,.5, 1.5,1.5,1.5), ncol=3, byrow=TRUE)
idx <- coord_to_index(bvol, coords)
coords2 <- index_to_coord(bvol, idx)
all.equal(coords, coords2)

bbuchsbaum/neuroim2 documentation built on Feb. 26, 2025, 3:49 p.m.