# Create a NeuroSpace object
space <- NeuroSpace(dim = c(2L, 2L, 2L), origin = c(0, 0, 0), spacing = c(1, 1, 1))
# Create a 3D mask
mask <- array(c(TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE), dim = c(2, 2, 2))
# Create indices and map for the IndexLookupVol
indices <- which(mask)
map <- seq_along(indices)
# Create an IndexLookupVol object
ilv <- IndexLookupVol(space = space, indices = as.integer(indices))
# Access the indices
print(ilv@indices)
# Access the map
print(ilv@map)
# Create a 64x64x64 space
space <- NeuroSpace(c(64, 64, 64), c(1, 1, 1), c(0, 0, 0))
# Create a lookup volume with random indices
indices <- sample(1:262144, 10000) # Select 10000 random voxels
ilv <- IndexLookupVol(space, indices)
# Look up coordinates for specific indices
coords <- coords(ilv, indices[1:10])
Run the code above in your browser using DataLab