index_to_grid-methods: Convert 1d indices to n-dimensional grid coordinates

index_to_gridR Documentation

Convert 1d indices to n-dimensional grid coordinates

Description

Converts linear indices to 2D grid coordinates for a NeuroSlice object.

Usage

index_to_grid(x, idx)

## S4 method for signature 'NeuroSlice,numeric'
index_to_grid(x, idx)

## S4 method for signature 'NeuroSpace,numeric'
index_to_grid(x, idx)

## S4 method for signature 'NeuroVec,index'
index_to_grid(x, idx)

## S4 method for signature 'NeuroVec,integer'
index_to_grid(x, idx)

## S4 method for signature 'NeuroVol,index'
index_to_grid(x, idx)

## S4 method for signature 'NeuroVol,integer'
index_to_grid(x, idx)

Arguments

x

A NeuroSlice object

idx

Integer vector of linear indices to convert

Details

Convert Linear Indices to Grid Coordinates

Value

a matrix of grid coordinates

A matrix with 2 columns representing the (x,y) coordinates corresponding to the input indices

See Also

grid_to_index for the inverse operation

Examples


 bvol <- NeuroVol(array(0, c(10,10,10)), NeuroSpace(c(10,10,10), c(1,1,1)))
 idx <- 1:10
 g <- index_to_grid(bvol, idx)
 bvol[g]

slice_space <- NeuroSpace(c(10, 10))
slice_data <- matrix(1:100, 10, 10)
slice <- NeuroSlice(slice_data, slice_space)

# Convert single index
coords <- index_to_grid(slice, 55)

# Convert multiple indices
indices <- c(1, 25, 50, 75, 100)
coords_mat <- index_to_grid(slice, indices)


bbuchsbaum/neuroim2 documentation built on Jan. 2, 2025, 3:38 p.m.