grid_to_index | R Documentation |
Converts 2D grid coordinates to linear indices for a NeuroSlice
object.
grid_to_index(x, coords)
## S4 method for signature 'NeuroSlice,matrix'
grid_to_index(x, coords)
## S4 method for signature 'NeuroSlice,numeric'
grid_to_index(x, coords)
## S4 method for signature 'NeuroSpace,matrix'
grid_to_index(x, coords)
## S4 method for signature 'NeuroSpace,numeric'
grid_to_index(x, coords)
## S4 method for signature 'NeuroVol,matrix'
grid_to_index(x, coords)
## S4 method for signature 'NeuroVol,numeric'
grid_to_index(x, coords)
x |
A |
coords |
Either a numeric vector of length 2 or a matrix with 2 columns, representing (x,y) coordinates in the slice grid |
Convert Grid Coordinates to Linear Indices
a vector of indices
Integer vector of linear indices corresponding to the input coordinates
index_to_grid
for the inverse operation
slice_space <- NeuroSpace(c(10, 10))
slice_data <- matrix(1:100, 10, 10)
slice <- NeuroSlice(slice_data, slice_space)
# Convert single coordinate
idx <- grid_to_index(slice, c(5, 5))
# Convert multiple coordinates
coords <- matrix(c(1,1, 2,2, 3,3), ncol=2, byrow=TRUE)
indices <- grid_to_index(slice, coords)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.